|
2 | 2 | * @file |
3 | 3 | * This file handles work with docusign maestro and esign services. |
4 | 4 | * Scenarios implemented: |
5 | | - * - Workflow definition creation. |
6 | | - * - Workflow definition publishing. |
7 | 5 | * - Workflow definition triggering, which create workflow instance. |
8 | | - * - Workflow instance cancellation. |
9 | | - * - Workflow instance fetching. |
| 6 | + * - Workflow definitions fetching. |
| 7 | + * - Workflow trigger requirements fetching. |
10 | 8 | */ |
11 | 9 |
|
12 | | -const { initMaestroApi } = require('../api'); |
| 10 | +const iam = require('@docusign/iam-sdk'); |
13 | 11 |
|
14 | 12 | class WorkflowsService { |
15 | 13 | static getWorkflowDefinitions = async args => { |
16 | | - const api = initMaestroApi(args.accountId, args.basePath, args.accessToken); |
17 | | - const definitions = await api.getWorkflowDefinitions({}); |
| 14 | + const client = new iam.IamClient({ accessToken: args.accessToken }); |
| 15 | + const definitions = await client.maestro.workflows.getWorkflowsList({ accountId: args.accountId }); |
18 | 16 |
|
19 | 17 | return definitions; |
20 | 18 | }; |
21 | 19 |
|
22 | 20 | static getWorkflowTriggerRequirements = async args => { |
23 | | - const api = initMaestroApi(args.accountId, args.basePath, args.accessToken); |
24 | | - const triggerRequirements = await api.getTriggerRequirements(args.workflowId); |
| 21 | + const client = new iam.IamClient({ accessToken: args.accessToken }); |
| 22 | + const triggerRequirements = await client.maestro.workflows.getWorkflowTriggerRequirements({ |
| 23 | + accountId: args.accountId, |
| 24 | + workflowId: args.workflowId, |
| 25 | + }); |
25 | 26 |
|
26 | 27 | return triggerRequirements; |
27 | 28 | }; |
28 | 29 |
|
29 | | - static triggerWorkflowInstance = async (args, payload, triggerRequirements) => { |
30 | | - const api = initMaestroApi(args.accountId, args.basePath, args.accessToken); |
| 30 | + static triggerWorkflowInstance = async (args, payload) => { |
| 31 | + const client = new iam.IamClient({ accessToken: args.accessToken }); |
31 | 32 | const triggerPayload = { |
32 | | - instance_name: 'test', |
33 | | - trigger_inputs: payload, |
| 33 | + instanceName: 'test', |
| 34 | + triggerInputs: payload, |
34 | 35 | }; |
35 | | - const triggerResponse = await api.triggerWorkflow(triggerPayload, triggerRequirements.trigger_http_config.url); |
| 36 | + const triggerResponse = await client.maestro.workflows.triggerWorkflow({ |
| 37 | + accountId: args.accountId, |
| 38 | + workflowId: args.workflowId, |
| 39 | + triggerWorkflow: triggerPayload, |
| 40 | + }); |
36 | 41 |
|
37 | 42 | return triggerResponse; |
38 | 43 | }; |
|
0 commit comments