Skip to content

Commit 35034fe

Browse files
authored
feat: add nextWorkflow method to Verify2 (#1032)
1 parent d7253e6 commit 35034fe

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
import {
3+
SDKTestCase,
4+
keyAuth,
5+
validateBearerAuth,
6+
} from '../../../../testHelpers';
7+
import {
8+
Verify2,
9+
} from '../../lib/';
10+
11+
export default [
12+
{
13+
label: 'next workflow request',
14+
baseUrl: 'https://api.nexmo.com',
15+
reqHeaders: {
16+
authorization: validateBearerAuth,
17+
},
18+
client: new Verify2(keyAuth),
19+
generator: false,
20+
error: false,
21+
requests: [
22+
['/v2/verify/091e717f-8715-41a0-a3f0-cc04912deaa1/next_workflow', 'POST'],
23+
],
24+
responses: [
25+
[200],
26+
],
27+
method: 'post',
28+
clientMethod: 'nextWorkflow',
29+
parameters: ['091e717f-8715-41a0-a3f0-cc04912deaa1'],
30+
expected: true,
31+
},
32+
{
33+
label: 'error when request Id not found',
34+
baseUrl: 'https://api.nexmo.com',
35+
reqHeaders: {
36+
authorization: validateBearerAuth,
37+
},
38+
client: new Verify2(keyAuth),
39+
generator: false,
40+
error: false,
41+
requests: [
42+
['/v2/verify/091e717f-8715-41a0-a3f0-cc04912deaa1/next_workflow', 'POST'],
43+
],
44+
responses: [
45+
[
46+
404,
47+
{
48+
title: 'Not Found',
49+
type: 'https://developer.vonage.com/api-errors#not-found',
50+
detail: 'Request <id> was not found or it has been verified already.',
51+
instance: 'bf0ca0bf927b3b52e3cb03217e1a1ddf',
52+
},
53+
],
54+
],
55+
clientMethod: 'nextWorkflow',
56+
parameters: ['091e717f-8715-41a0-a3f0-cc04912deaa1'],
57+
expected: false,
58+
},
59+
] as SDKTestCase<Verify2>[];

packages/verify2/lib/verify2.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,24 @@ export class Verify2 extends Client {
6161
return resp.data.status;
6262
}
6363

64+
/**
65+
* Move the request to the next workflow step, if available.
66+
* @param {string} requestId - The ID of the verification request.
67+
* @return {boolean} `true` if the request was successful.
68+
*/
69+
async nextWorkflow(requestId: string): Promise<boolean> {
70+
try {
71+
await this.sendPostRequest(
72+
`${this.config.apiHost}/v2/verify/${requestId}/next_workflow`,
73+
);
74+
return true;
75+
76+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
77+
} catch (_) {
78+
return false;
79+
}
80+
}
81+
6482
/**
6583
* Cancels a verification request.
6684
* @param {string} requestId - The ID of the verification request to cancel.

0 commit comments

Comments
 (0)