Skip to content

Commit

Permalink
fix(verify2): check code not returning status (#823)
Browse files Browse the repository at this point in the history
  • Loading branch information
manchuck committed May 19, 2023
1 parent 15bfc32 commit 3e04e19
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions packages/verify2/__tests__/__dataSets__/check.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CheckCodeRequest } from '../../lib/types';
import { CheckCodeRequest, CheckRequestResponse } from '../../lib/types';

export default [
{
Expand All @@ -10,11 +10,17 @@ export default [
code: '123456',
} as CheckCodeRequest,
],
response: [200],
response: [
200,
{
request_id: '091e717f-8715-41a0-a3f0-cc04912deaa1',
status: 'complete',
} as CheckRequestResponse,
],
method: 'post',
clientMethod: 'checkCode',
parameters: ['091e717f-8715-41a0-a3f0-cc04912deaa1', '123456'],
expected: true,
expected: 'complete',
},
{
label: 'error when request not found',
Expand Down
4 changes: 4 additions & 0 deletions packages/verify2/lib/types/checkRequestResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type CheckRequestResponse = {
request_id: string
status: string
}
1 change: 1 addition & 0 deletions packages/verify2/lib/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './checkCodeRequest';
export * from './checkRequestResponse';
export * from './emailWorkflow';
export * from './eventCallback';
export * from './request';
Expand Down
7 changes: 4 additions & 3 deletions packages/verify2/lib/verify2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Request,
VerificationRequestParams,
VerificationResponse,
CheckRequestResponse,
} from './types';

export class Verify2 extends Client {
Expand All @@ -21,14 +22,14 @@ export class Verify2 extends Client {
};
}

public async checkCode(requestId: string, code: string): Promise<true> {
await this.sendPostRequest(
public async checkCode(requestId: string, code: string): Promise<string> {
const resp = await this.sendPostRequest<CheckRequestResponse>(
`${this.config.apiHost}/v2/verify/${requestId}`,
{
code: code,
},
);

return true;
return resp.data.status;
}
}

0 comments on commit 3e04e19

Please sign in to comment.