Skip to content

Commit

Permalink
DEVEXP-558: Add snippets for Verification API (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
asein-sinch authored Sep 23, 2024
1 parent 31a8f08 commit 1958848
Show file tree
Hide file tree
Showing 15 changed files with 3,965 additions and 754 deletions.
4,455 changes: 3,701 additions & 754 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions snippets/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"strict": true,
"moduleResolution": "node",
"pretty": true,
"baseUrl": ".",
"noEmit": true,
"skipLibCheck": true
},
"include": [
"**/*.js"
],
"exclude": [
"node_modules"
]
}
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)}`);
};
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)}`);
};
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)}`);
};
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)}`);
};
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)}`);
};
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)}`);
};
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)}`);
};
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)}`);
};
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)}`);
};
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)}`);
};
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)}`);
};
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)}`);
};
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)}`);
};

0 comments on commit 1958848

Please sign in to comment.