Skip to content

Commit

Permalink
DEVEXP-382: Numbers API - Change package exports (#59)
Browse files Browse the repository at this point in the history
DEVEXP-382: SMS API - Change package exports (#60)
DEVEXP-382: Verification API - Change package exports (#61)
DEVEXP-382: Voice API - Change package exports (#62)
DEVEXP-382: Conversation API - Change package exports (#63)
  • Loading branch information
asein-sinch authored Apr 12, 2024
1 parent fcf3d83 commit 8710f4e
Show file tree
Hide file tree
Showing 260 changed files with 2,192 additions and 2,238 deletions.
32 changes: 13 additions & 19 deletions examples/integrated-flows-examples/src/numbers/app.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import {
SinchClient,
ActiveNumber,
GetActiveNumberRequestData, ListActiveNumbersRequestData,
ListAvailableNumbersRequestData,
ListAvailableRegionsRequestData,
NumberTypeEnum,
RegionNumberTypeEnum, ReleaseNumberRequestData, RentAnyNumberRequestData,
RentNumberRequestData, UpdateActiveNumberRequestData,
Numbers,
} from '@sinch/sdk-core';
import dotenv from 'dotenv';
dotenv.config();
Expand All @@ -24,15 +18,15 @@ dotenv.config();
const keySecret = process.env.SINCH_KEY_SECRET || '';
const sinchClient = new SinchClient({ projectId, keyId, keySecret });

const regionType: RegionNumberTypeEnum = 'LOCAL';
const type: NumberTypeEnum = 'LOCAL';
const regionType: Numbers.RegionNumberTypeEnum = 'LOCAL';
const type: Numbers.NumberTypeEnum = 'LOCAL';

console.log('+------------------------------------------------------------------------------+');
console.log('| Step 1: List the available regions and store the first one from the response |');
console.log('+------------------------------------------------------------------------------+');

// Build the request data
const availableRegionsRequestData: ListAvailableRegionsRequestData = {
const availableRegionsRequestData: Numbers.ListAvailableRegionsRequestData = {
types: [regionType],
};

Expand Down Expand Up @@ -64,7 +58,7 @@ dotenv.config();
console.log('+-----------------------------------------------+');

// Build the request data
const listAvailableNumbersRequestData: ListAvailableNumbersRequestData = {
const listAvailableNumbersRequestData: Numbers.ListAvailableNumbersRequestData = {
regionCode,
type,
};
Expand Down Expand Up @@ -97,7 +91,7 @@ dotenv.config();
console.log('+-------------------------------+');

// Build the request data
const rentNumberRequestData: RentNumberRequestData = {
const rentNumberRequestData: Numbers.RentNumberRequestData = {
phoneNumber: phoneNumber1,
rentNumberRequestBody: {},
};
Expand All @@ -119,7 +113,7 @@ dotenv.config();
console.log('+------------------------------------------------------------+');

// Build the request data
const rentAnyNumberRequestData: RentAnyNumberRequestData = {
const rentAnyNumberRequestData: Numbers.RentAnyNumberRequestData = {
rentAnyNumberRequestBody: {
regionCode,
type,
Expand Down Expand Up @@ -150,7 +144,7 @@ dotenv.config();
console.log('+-----------------------------------------------------------------------------------------------+');

// Build the request data
const getActiveNumberRequestData: GetActiveNumberRequestData = {
const getActiveNumberRequestData: Numbers.GetActiveNumberRequestData = {
phoneNumber: phoneNumber1,
};

Expand All @@ -171,13 +165,13 @@ dotenv.config();
console.log('+----------------------------------------------------------------------------------------------+');

// Build the request data
const listActiveNumbersRequestData: ListActiveNumbersRequestData = {
const listActiveNumbersRequestData: Numbers.ListActiveNumbersRequestData = {
regionCode,
type,
};

// The ActiveNumbersResponse is paginated. Let's fetch all the pages using the iterator functionality
const activeNumbersList: ActiveNumber[] = [];
const activeNumbersList: Numbers.ActiveNumber[] = [];
for await (const activeNumber of sinchClient.numbers.activeNumber.list(listActiveNumbersRequestData)) {
activeNumbersList.push(activeNumber);
}
Expand All @@ -195,9 +189,9 @@ dotenv.config();
console.log('+---------------------------------+');

// Build the request data
const updateActiveNumberRequestData: UpdateActiveNumberRequestData = {
const updateActiveNumberRequestData: Numbers.UpdateActiveNumberRequestData = {
phoneNumber: phoneNumber1,
activeNumberRequestBody: {
updateActiveNumberRequestBody: {
displayName: 'Sample number 1',
},
};
Expand All @@ -221,7 +215,7 @@ dotenv.config();
console.log('+---------------------------------------+');

// Build the request data
let releaseActiveNumberRequestData: ReleaseNumberRequestData = {
let releaseActiveNumberRequestData: Numbers.ReleaseNumberRequestData = {
phoneNumber: phoneNumber1,
};

Expand Down
18 changes: 9 additions & 9 deletions examples/integrated-flows-examples/src/verification/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import inquirer from 'inquirer';
import { SinchClient, verificationsHelper, VerificationStatusByIdRequestData } from '@sinch/sdk-core';
import { SinchClient, Verification } from '@sinch/sdk-core';
import dotenv from 'dotenv';
dotenv.config();

Expand Down Expand Up @@ -54,7 +54,7 @@ dotenv.config();
});

const startSmsVerificationFlow = async (phoneNumber: string) => {
const requestData = verificationsHelper.buildStartSmsVerificationRequest(phoneNumber);
const requestData = Verification.startVerificationHelper.buildSmsRequest(phoneNumber);
const response = await sinch.verification.verifications.startSms(requestData);
console.log('Verification request sent! Please check the SMS on your you phone to get the OTP.');
const answers = await inquirer.prompt([
Expand All @@ -64,7 +64,7 @@ dotenv.config();
message: 'Enter the verification code:',
},
]);
const reportRequestData = verificationsHelper.buildReportSmsVerificationByIdRequest(
const reportRequestData = Verification.reportVerificationByIdHelper.buildSmsRequest(
response.id!, answers.code);
const reportResponse = await sinch.verification.verifications.reportSmsById(reportRequestData);
console.log(`Verification status: ${reportResponse.status}${reportResponse.status === 'SUCCESSFUL' ? '' : ' - Reason: ' + reportResponse.reason}`);
Expand All @@ -73,7 +73,7 @@ dotenv.config();
};

const startCalloutVerificationFlow = async (phoneNumber: string) => {
const requestData = verificationsHelper.buildStartCalloutVerificationRequest(phoneNumber);
const requestData = Verification.startVerificationHelper.buildCalloutRequest(phoneNumber);
const response = await sinch.verification.verifications.startCallout(requestData);
console.log('Verification request sent! Please answer to the phone call ans listen to the OTP.');
const answers = await inquirer.prompt([
Expand All @@ -83,14 +83,14 @@ dotenv.config();
message: 'Enter the verification code:',
},
]);
const reportRequestData = verificationsHelper.buildReportCalloutVerificationByIdRequest(
const reportRequestData = Verification.reportVerificationByIdHelper.buildCalloutRequest(
response.id!, answers.code);
const reportResponse = await sinch.verification.verifications.reportCalloutById(reportRequestData);
console.log(`Verification status: ${reportResponse.status}${reportResponse.status === 'SUCCESSFUL'?'':' - Reason: ' + reportResponse.reason}`);
};

const startFlashCallVerificationFlow = async (phoneNumber: string) => {
const requestData = verificationsHelper.buildStartFlashCallVerificationRequest(phoneNumber);
const requestData = Verification.startVerificationHelper.buildFlashCallRequest(phoneNumber);
const response = await sinch.verification.verifications.startFlashCall(requestData);
console.log('Verification request sent! Please check the phone number calling you.');
const answers = await inquirer.prompt([
Expand All @@ -100,7 +100,7 @@ dotenv.config();
message: 'Enter the caller ID:',
},
]);
const reportRequestData = verificationsHelper.buildReportFlashCallVerificationByIdRequest(
const reportRequestData = Verification.reportVerificationByIdHelper.buildFlashCallRequest(
response.id!,
answers.cli,
);
Expand All @@ -109,15 +109,15 @@ dotenv.config();
};

const startSeamlessVerificationFlow = async (phoneNumber: string) => {
const requestData = verificationsHelper.buildStartSeamlessVerificationRequest(phoneNumber);
const requestData = Verification.startVerificationHelper.buildSeamlessRequest(phoneNumber);
let response;
try {
response = await sinch.verification.verifications.startSeamless(requestData);
} catch (error: any) {
console.log(`Impossible to process the seamless verification: ${error.data})`);
return;
}
const verificationStatusRequestData: VerificationStatusByIdRequestData = {
const verificationStatusRequestData: Verification.VerificationStatusByIdRequestData = {
id: response.id!,
};
const statusResponse = await sinch.verification.verificationStatus.getById(verificationStatusRequestData);
Expand Down
4 changes: 2 additions & 2 deletions examples/simple-examples/src/conversation/app/create.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CreateAppRequestData } from '@sinch/sdk-core';
import { Conversation } from '@sinch/sdk-core';
import {
getMessengerTokenFormConfig,
getPrintFormat,
Expand All @@ -13,7 +13,7 @@ import {

const messengerToken = getMessengerTokenFormConfig();

const requestData: CreateAppRequestData = {
const requestData: Conversation.CreateAppRequestData = {
appCreateRequestBody: {
display_name: 'New app created with the Node.js SDK',
channel_credentials: [
Expand Down
4 changes: 2 additions & 2 deletions examples/simple-examples/src/conversation/app/delete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeleteAppRequestData } from '@sinch/sdk-core';
import { Conversation } from '@sinch/sdk-core';
import { getAppIdFromConfig, initConversationService, printFullResponse } from '../../config';

(async () => {
Expand All @@ -8,7 +8,7 @@ import { getAppIdFromConfig, initConversationService, printFullResponse } from '

const appId = getAppIdFromConfig();

const requestData: DeleteAppRequestData = {
const requestData: Conversation.DeleteAppRequestData = {
app_id: appId,
};

Expand Down
4 changes: 2 additions & 2 deletions examples/simple-examples/src/conversation/app/get.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GetAppRequestData } from '@sinch/sdk-core';
import { Conversation } from '@sinch/sdk-core';
import {
getAppIdFromConfig,
getPrintFormat,
Expand All @@ -13,7 +13,7 @@ import {

const appId = getAppIdFromConfig();

const requestData: GetAppRequestData = {
const requestData: Conversation.GetAppRequestData = {
app_id: appId,
};

Expand Down
4 changes: 2 additions & 2 deletions examples/simple-examples/src/conversation/app/list.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ListAppsRequestData } from '@sinch/sdk-core';
import { Conversation } from '@sinch/sdk-core';
import { getPrintFormat, initConversationService, printFullResponse } from '../../config';

(async () => {
console.log('****************');
console.log('* App_ListApps *');
console.log('****************');

const requestData: ListAppsRequestData= {};
const requestData: Conversation.ListAppsRequestData= {};

const conversationService = initConversationService();
const response = await conversationService.app.list(requestData);
Expand Down
4 changes: 2 additions & 2 deletions examples/simple-examples/src/conversation/app/update.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UpdateAppRequestData } from '@sinch/sdk-core';
import { Conversation } from '@sinch/sdk-core';
import {
getAppIdFromConfig,
getMessengerTokenFormConfig,
Expand All @@ -14,7 +14,7 @@ import {

const appId = getAppIdFromConfig();

const requestData: UpdateAppRequestData = {
const requestData: Conversation.UpdateAppRequestData = {
app_id: appId,
update_mask: ['display_name', 'conversation_metadata_report_view'],
appUpdateRequestBody: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContactId, LookupCapabilityRequestData } from '@sinch/sdk-core';
import { Conversation } from '@sinch/sdk-core';
import {
getAppIdFromConfig,
getContactIdFromConfig,
Expand All @@ -14,7 +14,7 @@ import {
const appId = getAppIdFromConfig();
const contactId = getContactIdFromConfig();

const requestData: LookupCapabilityRequestData<ContactId> = {
const requestData: Conversation.LookupCapabilityRequestData<Conversation.ContactId> = {
lookupCapabilityRequestBody: {
app_id: appId,
recipient: {
Expand Down
4 changes: 2 additions & 2 deletions examples/simple-examples/src/conversation/contact/create.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CreateContactRequestData } from '@sinch/sdk-core';
import { Conversation } from '@sinch/sdk-core';
import {
getAppIdFromConfig,
getMessengerUserIdFromConfig,
Expand All @@ -17,7 +17,7 @@ import {
const messengerUserId = getMessengerUserIdFromConfig();
const appId = getAppIdFromConfig();

const requestData: CreateContactRequestData = {
const requestData: Conversation.CreateContactRequestData = {
contactCreateRequestBody: {
display_name: 'New contact created with the Node.js SDK',
channel_identities: [
Expand Down
4 changes: 2 additions & 2 deletions examples/simple-examples/src/conversation/contact/delete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeleteContactRequestData } from '@sinch/sdk-core';
import { Conversation } from '@sinch/sdk-core';
import { getContactIdFromConfig, initConversationService, printFullResponse } from '../../config';

(async () => {
Expand All @@ -8,7 +8,7 @@ import { getContactIdFromConfig, initConversationService, printFullResponse } fr

const contactId = getContactIdFromConfig();

const requestData: DeleteContactRequestData = {
const requestData: Conversation.DeleteContactRequestData = {
contact_id: contactId,
};

Expand Down
4 changes: 2 additions & 2 deletions examples/simple-examples/src/conversation/contact/get.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GetContactRequestData } from '@sinch/sdk-core';
import { Conversation } from '@sinch/sdk-core';
import { getContactIdFromConfig, getPrintFormat, initConversationService, printFullResponse } from '../../config';

(async () => {
Expand All @@ -8,7 +8,7 @@ import { getContactIdFromConfig, getPrintFormat, initConversationService, printF

const contactId = getContactIdFromConfig();

const requestData: GetContactRequestData = {
const requestData: Conversation.GetContactRequestData = {
contact_id: contactId,
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GetChannelProfileRequestData, IdentifiedBy } from '@sinch/sdk-core';
import { Conversation } from '@sinch/sdk-core';
import {
getAppIdFromConfig,
getMessengerUserIdFromConfig,
Expand All @@ -14,7 +14,7 @@ import {
const appId = getAppIdFromConfig();
const messengerUserId = getMessengerUserIdFromConfig();

const requestData: GetChannelProfileRequestData<IdentifiedBy> = {
const requestData: Conversation.GetChannelProfileRequestData<Conversation.IdentifiedBy> = {
getChannelProfileRequestBody: {
app_id: appId,
channel: 'MESSENGER',
Expand Down
12 changes: 6 additions & 6 deletions examples/simple-examples/src/conversation/contact/list.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Contact, ListContactsRequestData, PageResult } from '@sinch/sdk-core';
import { Conversation, PageResult } from '@sinch/sdk-core';
import { getPrintFormat, initConversationService, printFullResponse } from '../../config';

const populateContactsList = (
contactPage: PageResult<Contact>,
contactList: Contact[],
contactPage: PageResult<Conversation.Contact>,
contactList: Conversation.Contact[],
contactDetailsList: string[],
) => {
contactPage.data?.map((contact: Contact) => {
contactPage.data?.map((contact: Conversation.Contact) => {
contactList.push(contact);
contactDetailsList.push(`${contact.id} - ${contact.display_name}`);
});
Expand All @@ -17,7 +17,7 @@ const populateContactsList = (
console.log('* Contact_ListContacts *');
console.log('************************');

const requestData: ListContactsRequestData = {
const requestData: Conversation.ListContactsRequestData = {
page_size: 2,
};

Expand All @@ -28,7 +28,7 @@ const populateContactsList = (
// ----------------------------------------------
let response = await conversationService.contact.list(requestData);

const contactList: Contact[] = [];
const contactList: Conversation.Contact[] = [];
const contactDetailsList: string[] = [];

// Loop on all the pages to get all the active numbers
Expand Down
Loading

0 comments on commit 8710f4e

Please sign in to comment.