-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEVEXP-558: Add snippets for Verification API
- Loading branch information
1 parent
104f676
commit 1591a88
Showing
13 changed files
with
246 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
snippets/verification/report-verification/report-flashcall-verification-by-id.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// eslint-disable-next-line no-unused-vars | ||
import { Verification, VerificationService } from '@sinch/sdk-core'; | ||
|
||
/** @param {VerificationService} verificationService */ | ||
export const execute = async (verificationService) => { | ||
|
||
const verificationID = 'the_verification_ID'; | ||
const verificationCLI = 'the_phone_number_calling_for_verification'; | ||
|
||
/** @type {Verification.ReportFlashCallVerificationByIdRequestData} */ | ||
const requestData = Verification.reportVerificationByIdHelper.buildFlashCallRequest( | ||
verificationID, | ||
verificationCLI, | ||
); | ||
|
||
const response = await verificationService.verifications.reportFlashCallById(requestData); | ||
|
||
console.log(`Response:\n${JSON.stringify(response, null, 2)}`); | ||
}; |
19 changes: 19 additions & 0 deletions
19
snippets/verification/report-verification/report-flashcall-verification-by-identity.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// eslint-disable-next-line no-unused-vars | ||
import { Verification, VerificationService } from '@sinch/sdk-core'; | ||
|
||
/** @param {VerificationService} verificationService */ | ||
export const execute = async (verificationService) => { | ||
|
||
const phoneNumber = 'the_phone_number_to_verify'; | ||
const verificationCLI = 'the_phone_number_calling_for_verification'; | ||
|
||
/** @type {Verification.ReportFlashCallVerificationByIdentityRequestData} */ | ||
const requestData = Verification.reportVerificationByIdentityHelper.buildFlashCallRequest( | ||
phoneNumber, | ||
verificationCLI, | ||
); | ||
|
||
const response = await verificationService.verifications.reportFlashCallByIdentity(requestData); | ||
|
||
console.log(`Response:\n${JSON.stringify(response, null, 2)}`); | ||
}; |
19 changes: 19 additions & 0 deletions
19
snippets/verification/report-verification/report-phonecall-verification-by-id.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// eslint-disable-next-line no-unused-vars | ||
import { Verification, VerificationService } from '@sinch/sdk-core'; | ||
|
||
/** @param {VerificationService} verificationService */ | ||
export const execute = async (verificationService) => { | ||
|
||
const verificationID = 'the_verification_ID'; | ||
const verificationCode = 'the_verification_code_received_by_phone_call'; | ||
|
||
/** @type {Verification.ReportCalloutVerificationByIdRequestData} */ | ||
const requestData = Verification.reportVerificationByIdHelper.buildCalloutRequest( | ||
verificationID, | ||
verificationCode, | ||
); | ||
|
||
const response = await verificationService.verifications.reportCalloutById(requestData); | ||
|
||
console.log(`Response:\n${JSON.stringify(response, null, 2)}`); | ||
}; |
19 changes: 19 additions & 0 deletions
19
snippets/verification/report-verification/report-phonecall-verification-by-identity.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// eslint-disable-next-line no-unused-vars | ||
import { Verification, VerificationService } from '@sinch/sdk-core'; | ||
|
||
/** @param {VerificationService} verificationService */ | ||
export const execute = async (verificationService) => { | ||
|
||
const phoneNumber = 'the_phone_number_to_verify'; | ||
const verificationCode = 'the_verification_code_received_by_phone_call'; | ||
|
||
/** @type {Verification.ReportCalloutVerificationByIdentityRequestData} */ | ||
const requestData = Verification.reportVerificationByIdentityHelper.buildCalloutRequest( | ||
phoneNumber, | ||
verificationCode, | ||
); | ||
|
||
const response = await verificationService.verifications.reportCalloutByIdentity(requestData); | ||
|
||
console.log(`Response:\n${JSON.stringify(response, null, 2)}`); | ||
}; |
19 changes: 19 additions & 0 deletions
19
snippets/verification/report-verification/report-sms-verification-by-id.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// eslint-disable-next-line no-unused-vars | ||
import { Verification, VerificationService } from '@sinch/sdk-core'; | ||
|
||
/** @param {VerificationService} verificationService */ | ||
export const execute = async (verificationService) => { | ||
|
||
const verificationID = 'the_verification_ID'; | ||
const verificationCode = 'the_verification_code_received_by_SMS'; | ||
|
||
/** @type {Verification.ReportSmsVerificationByIdRequestData} */ | ||
const requestData = Verification.reportVerificationByIdHelper.buildSmsRequest( | ||
verificationID, | ||
verificationCode, | ||
); | ||
|
||
const response = await verificationService.verifications.reportSmsById(requestData); | ||
|
||
console.log(`Response:\n${JSON.stringify(response, null, 2)}`); | ||
}; |
19 changes: 19 additions & 0 deletions
19
snippets/verification/report-verification/report-sms-verification-by-identity.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// eslint-disable-next-line no-unused-vars | ||
import { Verification, VerificationService } from '@sinch/sdk-core'; | ||
|
||
/** @param {VerificationService} verificationService */ | ||
export const execute = async (verificationService) => { | ||
|
||
const phoneNumber = 'the_phone_number_to_verify'; | ||
const verificationCode = 'the_verification_code_received_by_SMS'; | ||
|
||
/** @type {Verification.ReportSmsVerificationByIdentityRequestData} */ | ||
const requestData = Verification.reportVerificationByIdentityHelper.buildSmsRequest( | ||
phoneNumber, | ||
verificationCode, | ||
); | ||
|
||
const response = await verificationService.verifications.reportSmsByIdentity(requestData); | ||
|
||
console.log(`Response:\n${JSON.stringify(response, null, 2)}`); | ||
}; |
19 changes: 19 additions & 0 deletions
19
snippets/verification/start-verification/start-data-verification.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// eslint-disable-next-line no-unused-vars | ||
import { Verification, VerificationService } from '@sinch/sdk-core'; | ||
|
||
/** @param {VerificationService} verificationService */ | ||
export const execute = async (verificationService) => { | ||
|
||
const phoneNumber = 'the_phone_number_to_verify'; | ||
const reference = 'the_verification_reference'; | ||
|
||
/** @type {Verification.StartSeamlessVerificationRequestData} */ | ||
const requestData = Verification.startVerificationHelper.buildSeamlessRequest( | ||
phoneNumber, | ||
reference, | ||
); | ||
|
||
const response = await verificationService.verifications.startSeamless(requestData); | ||
|
||
console.log(`Response:\n${JSON.stringify(response, null, 2)}`); | ||
}; |
19 changes: 19 additions & 0 deletions
19
snippets/verification/start-verification/start-flashcall-verification.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// eslint-disable-next-line no-unused-vars | ||
import { Verification, VerificationService } from '@sinch/sdk-core'; | ||
|
||
/** @param {VerificationService} verificationService */ | ||
export const execute = async (verificationService) => { | ||
|
||
const phoneNumber = 'the_phone_number_to_verify'; | ||
const reference = 'the_verification_reference'; | ||
|
||
/** @type {Verification.StartFlashCallVerificationRequestData} */ | ||
const requestData = Verification.startVerificationHelper.buildFlashCallRequest( | ||
phoneNumber, | ||
reference, | ||
); | ||
|
||
const response = await verificationService.verifications.startFlashCall(requestData); | ||
|
||
console.log(`Response:\n${JSON.stringify(response, null, 2)}`); | ||
}; |
20 changes: 20 additions & 0 deletions
20
snippets/verification/start-verification/start-phonecall-verification.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// eslint-disable-next-line no-unused-vars | ||
import { Verification, VerificationService } from '@sinch/sdk-core'; | ||
|
||
/** @param {VerificationService} verificationService */ | ||
export const execute = async (verificationService) => { | ||
|
||
const phoneNumber = 'the_phone_number_to_verify'; | ||
const reference = 'the_verification_reference'; | ||
|
||
/** @type {Verification.StartCalloutVerificationRequestData} */ | ||
const requestData = Verification.startVerificationHelper.buildCalloutRequest( | ||
phoneNumber, | ||
reference, | ||
'fr-FR', | ||
); | ||
|
||
const response = await verificationService.verifications.startCallout(requestData); | ||
|
||
console.log(`Response:\n${JSON.stringify(response, null, 2)}`); | ||
}; |
22 changes: 22 additions & 0 deletions
22
snippets/verification/start-verification/start-sms-verification.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// eslint-disable-next-line no-unused-vars | ||
import { Verification, VerificationService } from '@sinch/sdk-core'; | ||
|
||
/** @param {VerificationService} verificationService */ | ||
export const execute = async (verificationService) => { | ||
|
||
const phoneNumber = 'the_phone_number_to_verify'; | ||
const reference = 'the_verification_reference'; | ||
|
||
/** @type {Verification.StartSmsVerificationRequestData} */ | ||
const requestData = Verification.startVerificationHelper.buildSmsRequest( | ||
phoneNumber, | ||
reference, | ||
{ | ||
codeType: 'Alphanumeric', | ||
}, | ||
); | ||
|
||
const response = await verificationService.verifications.startSms(requestData); | ||
|
||
console.log(`Response:\n${JSON.stringify(response, null, 2)}`); | ||
}; |
17 changes: 17 additions & 0 deletions
17
snippets/verification/verification-status/verification-by-id.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// eslint-disable-next-line no-unused-vars | ||
import { Verification, VerificationService } from '@sinch/sdk-core'; | ||
|
||
/** @param {VerificationService} verificationService */ | ||
export const execute = async (verificationService) => { | ||
|
||
const verificationID = 'the_verification_ID'; | ||
|
||
/** @type {Verification.VerificationStatusByIdRequestData} */ | ||
const requestData = { | ||
id: verificationID, | ||
}; | ||
|
||
const response = await verificationService.verificationStatus.getById(requestData); | ||
|
||
console.log(`Verification status:\n${JSON.stringify(response, null, 2)}`); | ||
}; |
18 changes: 18 additions & 0 deletions
18
snippets/verification/verification-status/verification-by-identity.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// eslint-disable-next-line no-unused-vars | ||
import { Verification, VerificationService } from '@sinch/sdk-core'; | ||
|
||
/** @param {VerificationService} verificationService */ | ||
export const execute = async (verificationService) => { | ||
|
||
const phoneNumber = 'the_phone_number_to_verify'; | ||
|
||
/** @type {Verification.VerificationStatusByIdentityRequestData} */ | ||
const requestData = { | ||
method: 'sms', | ||
endpoint: phoneNumber, | ||
}; | ||
|
||
const response = await verificationService.verificationStatus.getByIdentity(requestData); | ||
|
||
console.log(`Verification status:\n${JSON.stringify(response, null, 2)}`); | ||
}; |
17 changes: 17 additions & 0 deletions
17
snippets/verification/verification-status/verification-by-reference.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// eslint-disable-next-line no-unused-vars | ||
import { Verification, VerificationService } from '@sinch/sdk-core'; | ||
|
||
/** @param {VerificationService} verificationService */ | ||
export const execute = async (verificationService) => { | ||
|
||
const verificationReference = 'the_verification_reference'; | ||
|
||
/** @type {Verification.VerificationStatusByReferenceRequestData} */ | ||
const requestData = { | ||
reference: verificationReference, | ||
}; | ||
|
||
const response = await verificationService.verificationStatus.getByReference(requestData); | ||
|
||
console.log(`Verification status:\n${JSON.stringify(response, null, 2)}`); | ||
}; |