Skip to content

Commit

Permalink
DEVEXP-558: Add snippets for Verification API
Browse files Browse the repository at this point in the history
  • Loading branch information
asein-sinch committed Sep 16, 2024
1 parent 104f676 commit 1591a88
Show file tree
Hide file tree
Showing 13 changed files with 246 additions and 0 deletions.
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)}`);
};
22 changes: 22 additions & 0 deletions snippets/verification/start-verification/start-sms-verification.js
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 snippets/verification/verification-status/verification-by-id.js
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 1591a88

Please sign in to comment.