From 0522f6caf7d0268093b0731503d25dba77776762 Mon Sep 17 00:00:00 2001 From: Antoine Sein Date: Fri, 22 Dec 2023 19:15:10 +0100 Subject: [PATCH 1/4] DEVEXP-248: Voice API - Generate models --- packages/verification/README.md | 6 +- .../verification/src/models/v1/error/index.ts | 1 - packages/verification/src/models/v1/index.ts | 2 +- .../src/models/v1/verification-error/index.ts | 1 + .../verification-error/verification-error.ts | 21 +++ .../verifications-api.jest.fixture.ts | 8 +- packages/voice/README.md | 136 ++++++++++++++++++ packages/voice/package.json | 37 +++++ packages/voice/src/models/index.ts | 1 + .../v1/ace-request-amd/ace-request-amd.ts | 22 +++ .../src/models/v1/ace-request-amd/index.ts | 1 + .../src/models/v1/ace-request/ace-request.ts | 29 ++++ .../voice/src/models/v1/ace-request/index.ts | 1 + .../src/models/v1/call-header/call-header.ts | 20 +++ .../voice/src/models/v1/call-header/index.ts | 1 + .../v1/callout-request/callout-request.ts | 28 ++++ .../src/models/v1/callout-request/index.ts | 1 + ...callout-request-conference-dtmf-options.ts | 22 +++ .../index.ts | 1 + .../conference-callout-request.ts | 45 ++++++ .../v1/conference-callout-request/index.ts | 1 + .../custom-callout-request.ts | 33 +++++ .../models/v1/custom-callout-request/index.ts | 1 + .../src/models/v1/destination/destination.ts | 21 +++ .../voice/src/models/v1/destination/index.ts | 1 + .../dice-request-debit/dice-request-debit.ts | 20 +++ .../src/models/v1/dice-request-debit/index.ts | 1 + .../dice-request-user-rate.ts | 20 +++ .../models/v1/dice-request-user-rate/index.ts | 1 + .../models/v1/dice-request/dice-request.ts | 48 +++++++ .../voice/src/models/v1/dice-request/index.ts | 1 + packages/voice/src/models/v1/enums.ts | 31 ++++ .../get-call-response-obj.ts | 41 ++++++ .../models/v1/get-call-response-obj/index.ts | 1 + .../v1/get-callbacks-url/get-callbacks-url.ts | 20 +++ .../src/models/v1/get-callbacks-url/index.ts | 1 + .../models/v1/get-callbacks/get-callbacks.ts | 16 +++ .../src/models/v1/get-callbacks/index.ts | 1 + .../get-callout-response-obj.ts | 18 +++ .../v1/get-callout-response-obj/index.ts | 1 + ...erence-info-response-participants-inner.ts | 21 +++ .../index.ts | 1 + .../get-conference-info-response.ts | 19 +++ .../v1/get-conference-info-response/index.ts | 1 + .../get-numbers-response-obj-numbers-inner.ts | 20 +++ .../index.ts | 1 + .../get-numbers-response-obj.ts | 16 +++ .../v1/get-numbers-response-obj/index.ts | 1 + .../get-query-number-number-item-rate.ts | 20 +++ .../index.ts | 1 + .../get-query-number-number-item.ts | 28 ++++ .../v1/get-query-number-number-item/index.ts | 1 + .../v1/get-query-number/get-query-number.ts | 18 +++ .../src/models/v1/get-query-number/index.ts | 1 + .../get-recording-file-info.ts | 18 +++ .../v1/get-recording-file-info/index.ts | 1 + .../v1/ice-request-to/ice-request-to.ts | 20 +++ .../src/models/v1/ice-request-to/index.ts | 1 + .../ice-request-user-rate.ts | 20 +++ .../models/v1/ice-request-user-rate/index.ts | 1 + .../src/models/v1/ice-request/ice-request.ts | 49 +++++++ .../voice/src/models/v1/ice-request/index.ts | 1 + packages/voice/src/models/v1/index.ts | 62 ++++++++ .../index.ts | 1 + .../manage-conference-participant-request.ts | 28 ++++ packages/voice/src/models/v1/menu/index.ts | 1 + packages/voice/src/models/v1/menu/menu.ts | 33 +++++ .../models/v1/notify-error-request/index.ts | 1 + .../notify-error-request.ts | 32 +++++ .../src/models/v1/notify-request/index.ts | 1 + .../v1/notify-request/notify-request.ts | 26 ++++ packages/voice/src/models/v1/option/index.ts | 1 + packages/voice/src/models/v1/option/option.ts | 20 +++ .../v1/pie-request-menu-result/index.ts | 1 + .../pie-request-menu-result.ts | 24 ++++ .../voice/src/models/v1/pie-request/index.ts | 1 + .../src/models/v1/pie-request/pie-request.ts | 29 ++++ .../index.ts | 1 + ...on-connect-conf-conference-dtmf-options.ts | 22 +++ .../v1/svaml-action-connect-conf/index.ts | 1 + .../svaml-action-connect-conf.ts | 25 ++++ .../index.ts | 1 + .../svaml-action-connect-mxp-destination.ts | 20 +++ .../v1/svaml-action-connect-mxp/index.ts | 1 + .../svaml-action-connect-mxp.ts | 24 ++++ .../v1/svaml-action-connect-pstn-amd/index.ts | 1 + .../svaml-action-connect-pstn-amd.ts | 18 +++ .../v1/svaml-action-connect-pstn/index.ts | 1 + .../svaml-action-connect-pstn.ts | 37 +++++ .../index.ts | 1 + .../svaml-action-connect-sip-destination.ts | 18 +++ .../v1/svaml-action-connect-sip/index.ts | 1 + .../svaml-action-connect-sip.ts | 34 +++++ .../models/v1/svaml-action-continue/index.ts | 1 + .../svaml-action-continue.ts | 18 +++ .../models/v1/svaml-action-hangup/index.ts | 1 + .../svaml-action-hangup.ts | 18 +++ .../src/models/v1/svaml-action-park/index.ts | 1 + .../v1/svaml-action-park/svaml-action-park.ts | 26 ++++ .../models/v1/svaml-action-run-menu/index.ts | 1 + .../svaml-action-run-menu.ts | 29 ++++ .../voice/src/models/v1/svaml-action/index.ts | 1 + .../models/v1/svaml-action/svaml-action.ts | 27 ++++ .../v1/svaml-instruction-answer/index.ts | 1 + .../svaml-instruction-answer.ts | 18 +++ .../v1/svaml-instruction-play-files/index.ts | 1 + .../svaml-instruction-play-files.ts | 22 +++ .../models/v1/svaml-instruction-say/index.ts | 1 + .../svaml-instruction-say.ts | 22 +++ .../v1/svaml-instruction-send-dtmf/index.ts | 1 + .../svaml-instruction-send-dtmf.ts | 20 +++ .../v1/svaml-instruction-set-cookie/index.ts | 1 + .../svaml-instruction-set-cookie.ts | 22 +++ .../index.ts | 1 + .../svaml-instruction-start-recording.ts | 20 +++ .../svaml-instruction-stop-recording/index.ts | 1 + .../svaml-instruction-stop-recording.ts | 18 +++ .../src/models/v1/svaml-instruction/index.ts | 1 + .../v1/svaml-instruction/svaml-instruction.ts | 25 ++++ .../src/models/v1/svaml-request-body/index.ts | 1 + .../svaml-request-body/svaml-request-body.ts | 22 +++ .../models/v1/tts-callout-request/index.ts | 1 + .../tts-callout-request.ts | 40 ++++++ .../src/models/v1/unassign-numbers/index.ts | 1 + .../v1/unassign-numbers/unassign-numbers.ts | 20 +++ .../models/v1/update-callbacks-url/index.ts | 1 + .../update-callbacks-url.ts | 20 +++ .../src/models/v1/update-callbacks/index.ts | 1 + .../v1/update-callbacks/update-callbacks.ts | 16 +++ .../src/models/v1/update-numbers/index.ts | 1 + .../v1/update-numbers/update-numbers.ts | 20 +++ .../voice/src/models/v1/voice-error/index.ts | 1 + .../src/models/v1/voice-error/voice-error.ts} | 4 +- packages/voice/tsconfig.build.json | 17 +++ packages/voice/tsconfig.json | 11 ++ packages/voice/tsconfig.tests.json | 17 +++ 136 files changed, 1869 insertions(+), 12 deletions(-) delete mode 100644 packages/verification/src/models/v1/error/index.ts create mode 100644 packages/verification/src/models/v1/verification-error/index.ts create mode 100644 packages/verification/src/models/v1/verification-error/verification-error.ts create mode 100644 packages/voice/README.md create mode 100644 packages/voice/package.json create mode 100644 packages/voice/src/models/index.ts create mode 100644 packages/voice/src/models/v1/ace-request-amd/ace-request-amd.ts create mode 100644 packages/voice/src/models/v1/ace-request-amd/index.ts create mode 100644 packages/voice/src/models/v1/ace-request/ace-request.ts create mode 100644 packages/voice/src/models/v1/ace-request/index.ts create mode 100644 packages/voice/src/models/v1/call-header/call-header.ts create mode 100644 packages/voice/src/models/v1/call-header/index.ts create mode 100644 packages/voice/src/models/v1/callout-request/callout-request.ts create mode 100644 packages/voice/src/models/v1/callout-request/index.ts create mode 100644 packages/voice/src/models/v1/conference-callout-request-conference-dtmf-options/conference-callout-request-conference-dtmf-options.ts create mode 100644 packages/voice/src/models/v1/conference-callout-request-conference-dtmf-options/index.ts create mode 100644 packages/voice/src/models/v1/conference-callout-request/conference-callout-request.ts create mode 100644 packages/voice/src/models/v1/conference-callout-request/index.ts create mode 100644 packages/voice/src/models/v1/custom-callout-request/custom-callout-request.ts create mode 100644 packages/voice/src/models/v1/custom-callout-request/index.ts create mode 100644 packages/voice/src/models/v1/destination/destination.ts create mode 100644 packages/voice/src/models/v1/destination/index.ts create mode 100644 packages/voice/src/models/v1/dice-request-debit/dice-request-debit.ts create mode 100644 packages/voice/src/models/v1/dice-request-debit/index.ts create mode 100644 packages/voice/src/models/v1/dice-request-user-rate/dice-request-user-rate.ts create mode 100644 packages/voice/src/models/v1/dice-request-user-rate/index.ts create mode 100644 packages/voice/src/models/v1/dice-request/dice-request.ts create mode 100644 packages/voice/src/models/v1/dice-request/index.ts create mode 100644 packages/voice/src/models/v1/enums.ts create mode 100644 packages/voice/src/models/v1/get-call-response-obj/get-call-response-obj.ts create mode 100644 packages/voice/src/models/v1/get-call-response-obj/index.ts create mode 100644 packages/voice/src/models/v1/get-callbacks-url/get-callbacks-url.ts create mode 100644 packages/voice/src/models/v1/get-callbacks-url/index.ts create mode 100644 packages/voice/src/models/v1/get-callbacks/get-callbacks.ts create mode 100644 packages/voice/src/models/v1/get-callbacks/index.ts create mode 100644 packages/voice/src/models/v1/get-callout-response-obj/get-callout-response-obj.ts create mode 100644 packages/voice/src/models/v1/get-callout-response-obj/index.ts create mode 100644 packages/voice/src/models/v1/get-conference-info-response-participants-inner/get-conference-info-response-participants-inner.ts create mode 100644 packages/voice/src/models/v1/get-conference-info-response-participants-inner/index.ts create mode 100644 packages/voice/src/models/v1/get-conference-info-response/get-conference-info-response.ts create mode 100644 packages/voice/src/models/v1/get-conference-info-response/index.ts create mode 100644 packages/voice/src/models/v1/get-numbers-response-obj-numbers-inner/get-numbers-response-obj-numbers-inner.ts create mode 100644 packages/voice/src/models/v1/get-numbers-response-obj-numbers-inner/index.ts create mode 100644 packages/voice/src/models/v1/get-numbers-response-obj/get-numbers-response-obj.ts create mode 100644 packages/voice/src/models/v1/get-numbers-response-obj/index.ts create mode 100644 packages/voice/src/models/v1/get-query-number-number-item-rate/get-query-number-number-item-rate.ts create mode 100644 packages/voice/src/models/v1/get-query-number-number-item-rate/index.ts create mode 100644 packages/voice/src/models/v1/get-query-number-number-item/get-query-number-number-item.ts create mode 100644 packages/voice/src/models/v1/get-query-number-number-item/index.ts create mode 100644 packages/voice/src/models/v1/get-query-number/get-query-number.ts create mode 100644 packages/voice/src/models/v1/get-query-number/index.ts create mode 100644 packages/voice/src/models/v1/get-recording-file-info/get-recording-file-info.ts create mode 100644 packages/voice/src/models/v1/get-recording-file-info/index.ts create mode 100644 packages/voice/src/models/v1/ice-request-to/ice-request-to.ts create mode 100644 packages/voice/src/models/v1/ice-request-to/index.ts create mode 100644 packages/voice/src/models/v1/ice-request-user-rate/ice-request-user-rate.ts create mode 100644 packages/voice/src/models/v1/ice-request-user-rate/index.ts create mode 100644 packages/voice/src/models/v1/ice-request/ice-request.ts create mode 100644 packages/voice/src/models/v1/ice-request/index.ts create mode 100644 packages/voice/src/models/v1/index.ts create mode 100644 packages/voice/src/models/v1/manage-conference-participant-request/index.ts create mode 100644 packages/voice/src/models/v1/manage-conference-participant-request/manage-conference-participant-request.ts create mode 100644 packages/voice/src/models/v1/menu/index.ts create mode 100644 packages/voice/src/models/v1/menu/menu.ts create mode 100644 packages/voice/src/models/v1/notify-error-request/index.ts create mode 100644 packages/voice/src/models/v1/notify-error-request/notify-error-request.ts create mode 100644 packages/voice/src/models/v1/notify-request/index.ts create mode 100644 packages/voice/src/models/v1/notify-request/notify-request.ts create mode 100644 packages/voice/src/models/v1/option/index.ts create mode 100644 packages/voice/src/models/v1/option/option.ts create mode 100644 packages/voice/src/models/v1/pie-request-menu-result/index.ts create mode 100644 packages/voice/src/models/v1/pie-request-menu-result/pie-request-menu-result.ts create mode 100644 packages/voice/src/models/v1/pie-request/index.ts create mode 100644 packages/voice/src/models/v1/pie-request/pie-request.ts create mode 100644 packages/voice/src/models/v1/svaml-action-connect-conf-conference-dtmf-options/index.ts create mode 100644 packages/voice/src/models/v1/svaml-action-connect-conf-conference-dtmf-options/svaml-action-connect-conf-conference-dtmf-options.ts create mode 100644 packages/voice/src/models/v1/svaml-action-connect-conf/index.ts create mode 100644 packages/voice/src/models/v1/svaml-action-connect-conf/svaml-action-connect-conf.ts create mode 100644 packages/voice/src/models/v1/svaml-action-connect-mxp-destination/index.ts create mode 100644 packages/voice/src/models/v1/svaml-action-connect-mxp-destination/svaml-action-connect-mxp-destination.ts create mode 100644 packages/voice/src/models/v1/svaml-action-connect-mxp/index.ts create mode 100644 packages/voice/src/models/v1/svaml-action-connect-mxp/svaml-action-connect-mxp.ts create mode 100644 packages/voice/src/models/v1/svaml-action-connect-pstn-amd/index.ts create mode 100644 packages/voice/src/models/v1/svaml-action-connect-pstn-amd/svaml-action-connect-pstn-amd.ts create mode 100644 packages/voice/src/models/v1/svaml-action-connect-pstn/index.ts create mode 100644 packages/voice/src/models/v1/svaml-action-connect-pstn/svaml-action-connect-pstn.ts create mode 100644 packages/voice/src/models/v1/svaml-action-connect-sip-destination/index.ts create mode 100644 packages/voice/src/models/v1/svaml-action-connect-sip-destination/svaml-action-connect-sip-destination.ts create mode 100644 packages/voice/src/models/v1/svaml-action-connect-sip/index.ts create mode 100644 packages/voice/src/models/v1/svaml-action-connect-sip/svaml-action-connect-sip.ts create mode 100644 packages/voice/src/models/v1/svaml-action-continue/index.ts create mode 100644 packages/voice/src/models/v1/svaml-action-continue/svaml-action-continue.ts create mode 100644 packages/voice/src/models/v1/svaml-action-hangup/index.ts create mode 100644 packages/voice/src/models/v1/svaml-action-hangup/svaml-action-hangup.ts create mode 100644 packages/voice/src/models/v1/svaml-action-park/index.ts create mode 100644 packages/voice/src/models/v1/svaml-action-park/svaml-action-park.ts create mode 100644 packages/voice/src/models/v1/svaml-action-run-menu/index.ts create mode 100644 packages/voice/src/models/v1/svaml-action-run-menu/svaml-action-run-menu.ts create mode 100644 packages/voice/src/models/v1/svaml-action/index.ts create mode 100644 packages/voice/src/models/v1/svaml-action/svaml-action.ts create mode 100644 packages/voice/src/models/v1/svaml-instruction-answer/index.ts create mode 100644 packages/voice/src/models/v1/svaml-instruction-answer/svaml-instruction-answer.ts create mode 100644 packages/voice/src/models/v1/svaml-instruction-play-files/index.ts create mode 100644 packages/voice/src/models/v1/svaml-instruction-play-files/svaml-instruction-play-files.ts create mode 100644 packages/voice/src/models/v1/svaml-instruction-say/index.ts create mode 100644 packages/voice/src/models/v1/svaml-instruction-say/svaml-instruction-say.ts create mode 100644 packages/voice/src/models/v1/svaml-instruction-send-dtmf/index.ts create mode 100644 packages/voice/src/models/v1/svaml-instruction-send-dtmf/svaml-instruction-send-dtmf.ts create mode 100644 packages/voice/src/models/v1/svaml-instruction-set-cookie/index.ts create mode 100644 packages/voice/src/models/v1/svaml-instruction-set-cookie/svaml-instruction-set-cookie.ts create mode 100644 packages/voice/src/models/v1/svaml-instruction-start-recording/index.ts create mode 100644 packages/voice/src/models/v1/svaml-instruction-start-recording/svaml-instruction-start-recording.ts create mode 100644 packages/voice/src/models/v1/svaml-instruction-stop-recording/index.ts create mode 100644 packages/voice/src/models/v1/svaml-instruction-stop-recording/svaml-instruction-stop-recording.ts create mode 100644 packages/voice/src/models/v1/svaml-instruction/index.ts create mode 100644 packages/voice/src/models/v1/svaml-instruction/svaml-instruction.ts create mode 100644 packages/voice/src/models/v1/svaml-request-body/index.ts create mode 100644 packages/voice/src/models/v1/svaml-request-body/svaml-request-body.ts create mode 100644 packages/voice/src/models/v1/tts-callout-request/index.ts create mode 100644 packages/voice/src/models/v1/tts-callout-request/tts-callout-request.ts create mode 100644 packages/voice/src/models/v1/unassign-numbers/index.ts create mode 100644 packages/voice/src/models/v1/unassign-numbers/unassign-numbers.ts create mode 100644 packages/voice/src/models/v1/update-callbacks-url/index.ts create mode 100644 packages/voice/src/models/v1/update-callbacks-url/update-callbacks-url.ts create mode 100644 packages/voice/src/models/v1/update-callbacks/index.ts create mode 100644 packages/voice/src/models/v1/update-callbacks/update-callbacks.ts create mode 100644 packages/voice/src/models/v1/update-numbers/index.ts create mode 100644 packages/voice/src/models/v1/update-numbers/update-numbers.ts create mode 100644 packages/voice/src/models/v1/voice-error/index.ts rename packages/{verification/src/models/v1/error/error.ts => voice/src/models/v1/voice-error/voice-error.ts} (87%) create mode 100644 packages/voice/tsconfig.build.json create mode 100644 packages/voice/tsconfig.json create mode 100644 packages/voice/tsconfig.tests.json diff --git a/packages/verification/README.md b/packages/verification/README.md index 1ea1dfcb..00badf3d 100644 --- a/packages/verification/README.md +++ b/packages/verification/README.md @@ -51,7 +51,7 @@ const credentials: SinchClientParameters = { const sinch = new SinchClient(credentials); const requestData: StartVerificationRequestData = { - InitiateVerificationResource: { + initiateVerificationRequestBody: { identity: { type: 'number', endpoint: '+17813334444', @@ -67,7 +67,7 @@ const verificationInitResponse: InitiateVerificationResponse ### Standalone -The SDK can be used standalone if you need to use only the Verification APIs. You will need to import the `XTimestampRequest` and `SigningRequest` plugins from the `@sinch/sdk-client` package to manage the authentication. +The SDK can be used standalone if you need to use only the Verification APIs. ```typescript import { @@ -88,7 +88,7 @@ const credentials: SinchClientParameters = { const verification = new Verification(credentials); const requestData: StartVerificationRequestData = { - InitiateVerificationResource: { + initiateVerificationRequestBody: { identity: { type: 'number', endpoint: '+17813334444', diff --git a/packages/verification/src/models/v1/error/index.ts b/packages/verification/src/models/v1/error/index.ts deleted file mode 100644 index db34bea2..00000000 --- a/packages/verification/src/models/v1/error/index.ts +++ /dev/null @@ -1 +0,0 @@ -export type { Error } from './error'; diff --git a/packages/verification/src/models/v1/index.ts b/packages/verification/src/models/v1/index.ts index ad470380..1818a308 100644 --- a/packages/verification/src/models/v1/index.ts +++ b/packages/verification/src/models/v1/index.ts @@ -7,7 +7,7 @@ export * from './callout-verification-report-request-callout'; export * from './callout-verification-report-response'; export * from './data-initiate-verification-response'; export * from './data-initiate-verification-response-seamless'; -export * from './error'; +export * from './verification-error'; export * from './flash-call-initiate-verification-response'; export * from './flash-call-initiate-verification-response-flash-call'; export * from './flash-call-request-event-response'; diff --git a/packages/verification/src/models/v1/verification-error/index.ts b/packages/verification/src/models/v1/verification-error/index.ts new file mode 100644 index 00000000..ca832d3b --- /dev/null +++ b/packages/verification/src/models/v1/verification-error/index.ts @@ -0,0 +1 @@ +export type { VerificationError } from './verification-error'; diff --git a/packages/verification/src/models/v1/verification-error/verification-error.ts b/packages/verification/src/models/v1/verification-error/verification-error.ts new file mode 100644 index 00000000..0d30c459 --- /dev/null +++ b/packages/verification/src/models/v1/verification-error/verification-error.ts @@ -0,0 +1,21 @@ +/** + * Model: VerificationError + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +export interface VerificationError { + + /** A summary of the HTTP error code and error type. */ + status?: string; + /** The HTTP error code. */ + errorCode?: string; + /** A simple description of the cause of the error. */ + message?: string; + /** If applicable, a reference ID for support to use with diagnosing the error. */ + reference?: string; +} + + diff --git a/packages/verification/src/rest/v1/verifications/verifications-api.jest.fixture.ts b/packages/verification/src/rest/v1/verifications/verifications-api.jest.fixture.ts index 73048b0f..554e860f 100644 --- a/packages/verification/src/rest/v1/verifications/verifications-api.jest.fixture.ts +++ b/packages/verification/src/rest/v1/verifications/verifications-api.jest.fixture.ts @@ -1,13 +1,12 @@ -import { VerificationsApi, ReportVerificationByIdRequestData, ReportVerificationByIdentityRequestData, StartVerificationRequestData } from './verifications-api'; import { InitiateVerificationResponse, VerificationResponse } from '../../../models'; +import { VerificationsApi, ReportVerificationByIdRequestData, ReportVerificationByIdentityRequestData, StartVerificationRequestData } from './verifications-api'; export class VerificationsApiFixture implements Partial> { /** * Fixture associated to function reportVerificationById */ - public reportById: jest.Mock, [ReportVerificationByIdRequestData]> - = jest.fn(); + public reportById: jest.Mock, [ReportVerificationByIdRequestData]> = jest.fn(); /** * Fixture associated to function reportVerificationByIdentity */ @@ -16,6 +15,5 @@ export class VerificationsApiFixture implements Partial, [StartVerificationRequestData]> - = jest.fn(); + public start: jest.Mock, [StartVerificationRequestData]> = jest.fn(); } diff --git a/packages/voice/README.md b/packages/voice/README.md new file mode 100644 index 00000000..51ce2a2c --- /dev/null +++ b/packages/voice/README.md @@ -0,0 +1,136 @@ +# Sinch Voice SDK for Node.js + +This package contains the Sinch Voice SDK for Node.js for use with [Sinch APIs](https://developers.sinch.com/). To use it, you will need a Sinch account. Please [sign up](https://dashboard.sinch.com/signup) or [log in](https://dashboard.sinch.com/login) if you already have one. + +Warning: +**This SDK is currently available for preview purposes only. It should not be used in production environments.** + + +## Installation + +We recommend to use this SDK as part of the `@sinch/sdk-core` package as it will take care about the authentication plugins to use. + +However, it's still possible to use this SDK standalone is you need to access the Verification API only. + +### With NPM + +```bash +npm install @sinch/voice +``` + +### With Yarn + +```bash +yarn add @sinch/voice +``` + +## Usage + +### Credentials + +The `Voice` API uses the Application Signed Request to authenticate against the server. You will need to provide the following credentials: +- applicationKey: one of the application keys that can be found in [Apps section](https://dashboard.sinch.com/voice/apps) of the Voice dashboard +- applicationSecret: the corresponding secret that can be found at the same place + +### As part of the Sinch SDK + +If you are using this SDK as part of the Sinch SDK (`@sinch/sdk-core`) you can access it as the `voice` property of the client that you would have instantiated. + +```typescript +import { + CalloutsRequestData, + GetCalloutResponseObj, + SinchClient, + SinchClientParameters, +} from '@sinch/sdk-core'; + +const credentials: SinchClientParameters = { + applicationKey: 'APPLICATION_ID', + applicationSecret: 'APPLICATION_SECRET', +}; +const sinch = new SinchClient(credentials); + +const requestData: CalloutsRequestData = { + calloutRequestBody: { + method: 'ttsCallout', + ttsCallout: { + destination: { + type: 'number', + endpoint: '+14045005000', + }, + cli: '+14045001000', + locale: 'en-US', + text: 'Hello, this is a call from Sinch.', + }, + }, +}; + +// Access the 'voice' domain registered on the Sinch Client +const calloutResponse: GetCalloutResponseObj + = await sinch.voice.callouts.callouts(requestData); +``` + +### Standalone + +The SDK can be used standalone if you need to use only the Voice APIs. + +```typescript +import { + SinchClientParameters + } from '@sinch/sdk-client'; +import { + CalloutsRequestData, + GetCalloutResponseObj, + Voice, +} from '@sinch/voice'; + +const credentials: SinchClientParameters = { + applicationKey: 'APPLICATION_ID', + applicationSecret: 'APPLICATION_SECRET', +}; + +// Declare the 'verification' in a standalone way +const voice = new Voice(credentials); + +const requestData: CalloutsRequestData = { + calloutRequestBody: { + method: 'ttsCallout', + ttsCallout: { + destination: { + type: 'number', + endpoint: '+14045005000', + }, + cli: '+14045001000', + locale: 'en-US', + text: 'Hello, this is a call from Sinch.', + }, + }, +}; + +// Use the standalone declaration of the 'verification' domain +const calloutResponse: GetCalloutResponseObj + = await voice.callouts.callouts(requestData); +``` + +## Promises + +All the methods that interact with the Sinch APIs use Promises. You can use `await` in an `async` method to wait for the response or you can resolve them yourself with `then()` / `catch()`. + +```typescript +// Method 1: Wait for the Promise to complete +let calloutResponse: GetCalloutResponseObj; +try { + calloutResponse = await sinch.voice.callouts.callouts(requestData); + console.log(`callId = ${response.callId}`); +} catch (error: any) { + console.error(`ERROR ${error.statusCode}: Impossible to make a call out to the number ${requestData.calloutRequestBody.ttsCallout.destination.endpoint}`); +} + +// Method 2: Resolve the promise +sinch.voice.callouts.callouts(requestData) + .then(response => console.log(`callId = ${response.callId}`)) + .catch(error => console.error(`ERROR ${error.statusCode}: Impossible to make a call out to the number ${requestData.calloutRequestBody.ttsCallout.destination.endpoint}`)); +``` + +## Contact +Developer Experience team: [devexp@sinch.com](mailto:devexp@sinch.com) diff --git a/packages/voice/package.json b/packages/voice/package.json new file mode 100644 index 00000000..26d9ee24 --- /dev/null +++ b/packages/voice/package.json @@ -0,0 +1,37 @@ +{ + "name": "@sinch/voice", + "version": "0.0.0", + "description": "Sinch Voice API", + "homepage": "", + "repository": { + "type": "git", + "url": "" + }, + "license": "Apache-2.0", + "author": "Sinch", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.js" + } + }, + "directories": { + "src": "dist", + "test": "tests" + }, + "files": ["/dist"], + "scripts": { + "build": "yarn run clean && yarn run compile", + "clean": "rimraf dist tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo", + "compile": "tsc -p tsconfig.build.json && tsc -p tsconfig.tests.json && rimraf dist/tests tsconfig.build.tsbuildinfo" + }, + "dependencies": { + "@sinch/sdk-client": "^0.0.0" + }, + "devDependencies": {}, + "publishConfig": { + "directory": "dist" + } +} diff --git a/packages/voice/src/models/index.ts b/packages/voice/src/models/index.ts new file mode 100644 index 00000000..5b98253d --- /dev/null +++ b/packages/voice/src/models/index.ts @@ -0,0 +1 @@ +export * from './v1'; diff --git a/packages/voice/src/models/v1/ace-request-amd/ace-request-amd.ts b/packages/voice/src/models/v1/ace-request-amd/ace-request-amd.ts new file mode 100644 index 00000000..ae3e201c --- /dev/null +++ b/packages/voice/src/models/v1/ace-request-amd/ace-request-amd.ts @@ -0,0 +1,22 @@ +/** + * Model: AceRequestAmd + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * If [Answering Machine Detection](/docs/voice/api-reference/amd_v2) (AMD) is enabled, this object contains information about whether the call was answered by a machine. + */ +export interface AceRequestAmd { + + /** The determination by the system of who answered the call. */ + status?: string; + /** The reason that the system used to determine who answered the call. */ + reason?: string; + /** The length of the call. */ + duration?: number; +} + + diff --git a/packages/voice/src/models/v1/ace-request-amd/index.ts b/packages/voice/src/models/v1/ace-request-amd/index.ts new file mode 100644 index 00000000..727d612e --- /dev/null +++ b/packages/voice/src/models/v1/ace-request-amd/index.ts @@ -0,0 +1 @@ +export type { AceRequestAmd } from './ace-request-amd'; diff --git a/packages/voice/src/models/v1/ace-request/ace-request.ts b/packages/voice/src/models/v1/ace-request/ace-request.ts new file mode 100644 index 00000000..d64a6d93 --- /dev/null +++ b/packages/voice/src/models/v1/ace-request/ace-request.ts @@ -0,0 +1,29 @@ +/** + * Model: AceRequest + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { AceRequestAmd } from '../ace-request-amd'; + +/** + * The request body of an Answered Call Event. + */ +export interface AceRequest { + + /** Must have the value `ace`. */ + event?: string; + /** The unique ID assigned to this call. */ + callId?: string; + /** The timestamp in UTC format. */ + timestamp?: Date; + /** The current API version. */ + version?: number; + /** A string that can be used to pass custom information related to the call. */ + custom?: string; + /** @see AceRequestAmd */ + amd?: AceRequestAmd; +} + + diff --git a/packages/voice/src/models/v1/ace-request/index.ts b/packages/voice/src/models/v1/ace-request/index.ts new file mode 100644 index 00000000..5ae17def --- /dev/null +++ b/packages/voice/src/models/v1/ace-request/index.ts @@ -0,0 +1 @@ +export type { AceRequest } from './ace-request'; diff --git a/packages/voice/src/models/v1/call-header/call-header.ts b/packages/voice/src/models/v1/call-header/call-header.ts new file mode 100644 index 00000000..e1ce5176 --- /dev/null +++ b/packages/voice/src/models/v1/call-header/call-header.ts @@ -0,0 +1,20 @@ +/** + * Model: CallHeader + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * Call Headers can be used to pass custom data from a Sinch SDK client to another, or specified in an ICE response to be made available to the receiving client. Further, if Call Headers is specified they will be available in ICE and DICE events. + */ +export interface CallHeader { + + /** The call header key of the key value pair. */ + key?: string; + /** The call header value of the key value pair. */ + value?: string; +} + + diff --git a/packages/voice/src/models/v1/call-header/index.ts b/packages/voice/src/models/v1/call-header/index.ts new file mode 100644 index 00000000..56298ee5 --- /dev/null +++ b/packages/voice/src/models/v1/call-header/index.ts @@ -0,0 +1 @@ +export type { CallHeader } from './call-header'; diff --git a/packages/voice/src/models/v1/callout-request/callout-request.ts b/packages/voice/src/models/v1/callout-request/callout-request.ts new file mode 100644 index 00000000..e920e00f --- /dev/null +++ b/packages/voice/src/models/v1/callout-request/callout-request.ts @@ -0,0 +1,28 @@ +/** + * Model: CalloutRequest + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { ConferenceCalloutRequest } from '../conference-callout-request'; +import { CustomCalloutRequest } from '../custom-callout-request'; +import { TtsCalloutRequest } from '../tts-callout-request'; + +/** + * Currently three types of callouts are supported: conference callouts, text-to-speech callouts and custom callouts. The custom callout is the most flexible, but text-to-speech and conference callouts are more convenient. + */ +export interface CalloutRequest { + + /** Sets the type of callout. */ + method: MethodEnum; + /** @see ConferenceCalloutRequest */ + conferenceCallout?: ConferenceCalloutRequest; + /** @see TtsCalloutRequest */ + ttsCallout?: TtsCalloutRequest; + /** @see CustomCalloutRequest */ + customCallout?: CustomCalloutRequest; +} + +export type MethodEnum = 'conferenceCallout' | 'ttsCallout' | 'customCallout'; + diff --git a/packages/voice/src/models/v1/callout-request/index.ts b/packages/voice/src/models/v1/callout-request/index.ts new file mode 100644 index 00000000..b71a5adc --- /dev/null +++ b/packages/voice/src/models/v1/callout-request/index.ts @@ -0,0 +1 @@ +export type { CalloutRequest } from './callout-request'; diff --git a/packages/voice/src/models/v1/conference-callout-request-conference-dtmf-options/conference-callout-request-conference-dtmf-options.ts b/packages/voice/src/models/v1/conference-callout-request-conference-dtmf-options/conference-callout-request-conference-dtmf-options.ts new file mode 100644 index 00000000..9c93bb24 --- /dev/null +++ b/packages/voice/src/models/v1/conference-callout-request-conference-dtmf-options/conference-callout-request-conference-dtmf-options.ts @@ -0,0 +1,22 @@ +/** + * Model: ConferenceCalloutRequestConferenceDtmfOptions + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * Options to control how DTMF signals are used by the participant in the conference. For information on how to use this feature, read more [here](../../../conference-dtmf). + */ +export interface ConferenceCalloutRequestConferenceDtmfOptions { + + /** Determines what DTMF mode the participant will use in the call. */ + mode?: string; + /** The maximum number of accepted digits before sending the collected input via a PIE callback. The default value is `1`. If the value is greater than `1`, the PIE callback is triggered by one of the three following events: - No additional digit is entered before the `timeoutMills` timeout period has elapsed. - The `#` character is entered. - The maximum number of digits has been entered. */ + maxDigits?: number; + /** The number of milliseconds that the system will wait between entered digits before triggering the PIE callback. The default value is `3000`. */ + timeoutMills?: number; +} + + diff --git a/packages/voice/src/models/v1/conference-callout-request-conference-dtmf-options/index.ts b/packages/voice/src/models/v1/conference-callout-request-conference-dtmf-options/index.ts new file mode 100644 index 00000000..f63d84da --- /dev/null +++ b/packages/voice/src/models/v1/conference-callout-request-conference-dtmf-options/index.ts @@ -0,0 +1 @@ +export type { ConferenceCalloutRequestConferenceDtmfOptions } from './conference-callout-request-conference-dtmf-options'; diff --git a/packages/voice/src/models/v1/conference-callout-request/conference-callout-request.ts b/packages/voice/src/models/v1/conference-callout-request/conference-callout-request.ts new file mode 100644 index 00000000..4faf30b1 --- /dev/null +++ b/packages/voice/src/models/v1/conference-callout-request/conference-callout-request.ts @@ -0,0 +1,45 @@ +/** + * Model: ConferenceCalloutRequest + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { ConferenceCalloutRequestConferenceDtmfOptions } from '../conference-callout-request-conference-dtmf-options'; +import { Destination } from '../destination'; + +/** + * The conference callout calls a phone number or a user. When the call is answered, it\'s connected to a conference room. + */ +export interface ConferenceCalloutRequest { + + /** The number that will be displayed as the incoming caller. To set your own CLI, you may use your verified number or your Dashboard number. The number must be in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format. */ + cli?: string; + /** @see Destination */ + destination: Destination; + /** The conferenceId of the conference to which you want the callee to join. If the conferenceId doesn\'t exist a conference room will be created. */ + conferenceId: string; + /** @see ConferenceCalloutRequestConferenceDtmfOptions */ + conferenceDtmfOptions?: ConferenceCalloutRequestConferenceDtmfOptions; + /** When the destination picks up, this DTMF tones will be played to the callee. Valid characters in the string are \"0\"-\"9\", \"#\" and \"w\". A \"w\" will render a 500 ms pause. Example: \"ww1234#w#\" will render a 1s pause, the DTMF tones \"1\", \"2\", \"3\", \"4\" and \"#\" followed by a 0.5s pause and finally the DTMF tone for \"#\". This can be used if the callout destination for instance require a conference PIN code or an extension to be entered. */ + dtmf?: string; + maxDuration?: number; + /** If `enableAce` is set to true and the application has a callback URL specified, you will receive an ACE callback when the call is answered. When the callback is received, your platform must respond with a svamlet containing the `connectConf` action in order to add the call to a conference or create the conference if it\'s the first call. If it\'s set to false, no ACE event will be sent to your backend.
Note if the call is towards an InApp destination `type:` `username`, then no ACE will be issued when the call is connected, even if `enableAce` is present in the callout request. */ + enableAce?: boolean; + /** If `enableDice` is set to true and the application has a callback URL specified, you will receive a DiCE callback when the call is disconnected. If it\'s set to false, no DiCE event will be sent to your backend.
Note if the call is towards an InApp destination `type:` `username`, then no DICE will be issued at the end of the call, even if `enableDice` is present in the callout request. */ + enableDice?: boolean; + /** If `enablePie` is set to true and the application has a callback URL specified, you will receive a PIE callback after a `runMenu` action, with the information of the action that the user took. If it\'s set to false, no PIE event will be sent to your backend. */ + enablePie?: boolean; + /** The voice and language you want to use for the prompts. This can either be defined by the ISO 639 locale and language code or by specifying a particular voice. Supported languages and voices are detailed [here](../../../voice-locales/) */ + locale?: string; + /** The text that will be spoken as a greeting. */ + greeting?: string; + /** Means \"music-on-hold.\" It\'s an optional parameter that specifies what the first participant should listen to while they\'re alone in the conference, waiting for other participants to join. It can take one of these pre-defined values:
  • `ring` (progress tone)
  • `music1` (music file)
  • `music2` (music file)
  • `music3` (music file)

If no “music-on-hold” is specified, the user will only hear silence. */ + mohClass?: string; + /** Used to input custom data. */ + custom?: string; + /** can be either “pstn” for PSTN endpoint or “mxp” for data (app or web) clients. */ + domain?: string; +} + + diff --git a/packages/voice/src/models/v1/conference-callout-request/index.ts b/packages/voice/src/models/v1/conference-callout-request/index.ts new file mode 100644 index 00000000..d1d3c1c9 --- /dev/null +++ b/packages/voice/src/models/v1/conference-callout-request/index.ts @@ -0,0 +1 @@ +export type { ConferenceCalloutRequest } from './conference-callout-request'; diff --git a/packages/voice/src/models/v1/custom-callout-request/custom-callout-request.ts b/packages/voice/src/models/v1/custom-callout-request/custom-callout-request.ts new file mode 100644 index 00000000..b182a096 --- /dev/null +++ b/packages/voice/src/models/v1/custom-callout-request/custom-callout-request.ts @@ -0,0 +1,33 @@ +/** + * Model: CustomCalloutRequest + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { Destination } from '../destination'; + +/** + * The custom callout, the server initiates a call from the servers that can be controlled by specifying how the call should progress at each call event. + */ +export interface CustomCalloutRequest { + + /** The number that will be displayed as the incoming caller, to set your own CLI, you may use your verified number or your Dashboard virtual number, it must be in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format. */ + cli?: string; + /** @see Destination */ + destination?: Destination; + /** When the destination picks up, this DTMF tones will be played to the callee. Valid characters in the string are \"0\"-\"9\", \"#\", and \"w\". A \"w\" will render a 500 ms pause. For example, \"ww1234#w#\" will render a 1s pause, the DTMF tones \"1\", \"2\", \"3\", \"4\" and \"#\" followed by a 0.5s pause and finally the DTMF tone for \"#\". This can be used if the callout destination for instance require a conference PIN code or an extension to be entered. */ + dtmf?: string; + /** Can be used to input custom data. */ + custom?: string; + /** The maximum amount of time in seconds that the call will last. */ + maxDuration?: number; + /** You can use inline SVAML to replace a callback URL when using custom callouts. Ensure that the JSON object is escaped correctly. If inline ICE SVAML is passed, exclude *cli* and *destination* properties from the *customCallout* request body. Example: ```\"{\\\"action\\\":{\\\"name\\\":\\\"connectPstn\\\",\\\"number\\\":\\\"46000000001\\\",\\\"maxDuration\\\":90}}\"``` */ + ice?: string; + /** You can use inline SVAML to replace a callback URL when using custom callouts. Ensure that the JSON object is escaped correctly. Example: ```\"{\\\"action\\\": {\\\"name\\\": \\\"RunMenu\\\",\\\"locale\\\": \\\"en-US\\\",\\\"menus\\\": [{\\\"id\\\": \\\"main\\\",\\\"mainPrompt\\\": \\\"#tts[ Welcome to the main menu. Press 1 for a callback or 2 for a cancel]\\\",\\\"timeoutMills\\\": 5000,\\\"options\\\": [ {\\\"dtmf\\\": \\\"1\\\",\\\"action\\\": \\\"return(callback)\\\"}, {\\\"dtmf\\\": \\\"2\\\",\\\"action\\\": \\\"return(cancel)\\\"}]}]}}\"``` */ + ace?: string; + /** Note: PIE callbacks are not available for DATA Calls; only PSTN and SIP calls. You can use inline SVAML to replace a callback URL when using custom callouts. Ensure that the JSON object is escaped correctly. A PIE event will contain a value chosen from an IVR choice. Usually a PIE event wil contain a URL to a callback sever that will receive the choice and be able to parse it. This could result in further SVAML or some other application logic function. Example: ```\"https://your-application-server-host/application\"``` */ + pie?: string; +} + + diff --git a/packages/voice/src/models/v1/custom-callout-request/index.ts b/packages/voice/src/models/v1/custom-callout-request/index.ts new file mode 100644 index 00000000..8359858f --- /dev/null +++ b/packages/voice/src/models/v1/custom-callout-request/index.ts @@ -0,0 +1 @@ +export type { CustomCalloutRequest } from './custom-callout-request'; diff --git a/packages/voice/src/models/v1/destination/destination.ts b/packages/voice/src/models/v1/destination/destination.ts new file mode 100644 index 00000000..498f03af --- /dev/null +++ b/packages/voice/src/models/v1/destination/destination.ts @@ -0,0 +1,21 @@ +/** + * Model: Destination + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * The type of device and number or endpoint to call. + */ +export interface Destination { + + /** Can be of type `number` for PSTN endpoints or of type `username` for data endpoints. */ + type: TypeEnum; + /** If the type is `number` the value of the endpoint is a phone number. If the type is `username` the value is the username for a data endpoint. */ + endpoint: string; +} + +export type TypeEnum = 'number' | 'username'; + diff --git a/packages/voice/src/models/v1/destination/index.ts b/packages/voice/src/models/v1/destination/index.ts new file mode 100644 index 00000000..eea5c14e --- /dev/null +++ b/packages/voice/src/models/v1/destination/index.ts @@ -0,0 +1 @@ +export type { Destination } from './destination'; diff --git a/packages/voice/src/models/v1/dice-request-debit/dice-request-debit.ts b/packages/voice/src/models/v1/dice-request-debit/dice-request-debit.ts new file mode 100644 index 00000000..f80a87de --- /dev/null +++ b/packages/voice/src/models/v1/dice-request-debit/dice-request-debit.ts @@ -0,0 +1,20 @@ +/** + * Model: DiceRequestDebit + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * An object containing currency and total amount charged for the call. + */ +export interface DiceRequestDebit { + + /** The currency ID of the rate, for example, `USD`. */ + currencyId?: string; + /** The total amount debited for the call. */ + amount?: number; +} + + diff --git a/packages/voice/src/models/v1/dice-request-debit/index.ts b/packages/voice/src/models/v1/dice-request-debit/index.ts new file mode 100644 index 00000000..9c1de520 --- /dev/null +++ b/packages/voice/src/models/v1/dice-request-debit/index.ts @@ -0,0 +1 @@ +export type { DiceRequestDebit } from './dice-request-debit'; diff --git a/packages/voice/src/models/v1/dice-request-user-rate/dice-request-user-rate.ts b/packages/voice/src/models/v1/dice-request-user-rate/dice-request-user-rate.ts new file mode 100644 index 00000000..01fd42b2 --- /dev/null +++ b/packages/voice/src/models/v1/dice-request-user-rate/dice-request-user-rate.ts @@ -0,0 +1,20 @@ +/** + * Model: DiceRequestUserRate + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * An object containing currency and rate per minute for the call. + */ +export interface DiceRequestUserRate { + + /** The currency in which the call is charged. */ + currencyId?: string; + /** The rate per minute that was charged for the call. */ + amount?: number; +} + + diff --git a/packages/voice/src/models/v1/dice-request-user-rate/index.ts b/packages/voice/src/models/v1/dice-request-user-rate/index.ts new file mode 100644 index 00000000..efc97b50 --- /dev/null +++ b/packages/voice/src/models/v1/dice-request-user-rate/index.ts @@ -0,0 +1 @@ +export type { DiceRequestUserRate } from './dice-request-user-rate'; diff --git a/packages/voice/src/models/v1/dice-request/dice-request.ts b/packages/voice/src/models/v1/dice-request/dice-request.ts new file mode 100644 index 00000000..9613c2bd --- /dev/null +++ b/packages/voice/src/models/v1/dice-request/dice-request.ts @@ -0,0 +1,48 @@ +/** + * Model: DiceRequest + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { CallHeader } from '../call-header'; +import { DiceRequestDebit } from '../dice-request-debit'; +import { DiceRequestUserRate } from '../dice-request-user-rate'; +import { IceRequestTo } from '../ice-request-to'; + +/** + * The request body of a Disconnected Call Event. + */ +export interface DiceRequest { + + /** Must have the value `dice`. */ + event?: string; + /** The unique ID assigned to this call. */ + callId?: string; + /** The timestamp in UTC format. */ + timestamp?: Date; + /** The reason the call was disconnected. */ + reason?: string; + /** The result of the call. */ + result?: string; + /** The current API version. */ + version?: number; + /** A string that can be used to pass custom information related to the call. */ + custom?: string; + /** @see DiceRequestDebit */ + debit?: DiceRequestDebit; + /** @see DiceRequestUserRate */ + userRate?: DiceRequestUserRate; + /** @see IceRequestTo */ + to?: IceRequestTo; + /** The duration of the call in seconds. */ + duration?: number; + /** Information about the initiator of the call. */ + from?: string; + /** If the call was initiated by a Sinch SDK client, call headers are the headers specified by the *caller* client. Read more about call headers [here](../../../call-headers/). */ + callHeaders?: CallHeader[]; + /** The unique application key. You can find it in the Sinch [dashboard](https://dashboard.sinch.com/voice/apps). */ + applicationKey?: string; +} + + diff --git a/packages/voice/src/models/v1/dice-request/index.ts b/packages/voice/src/models/v1/dice-request/index.ts new file mode 100644 index 00000000..720f793d --- /dev/null +++ b/packages/voice/src/models/v1/dice-request/index.ts @@ -0,0 +1 @@ +export type { DiceRequest } from './dice-request'; diff --git a/packages/voice/src/models/v1/enums.ts b/packages/voice/src/models/v1/enums.ts new file mode 100644 index 00000000..07b2c921 --- /dev/null +++ b/packages/voice/src/models/v1/enums.ts @@ -0,0 +1,31 @@ +export type { + MethodEnum as CalloutRequestMethodEnum, +} from './callout-request/callout-request'; +export type { + TypeEnum as DestinationTypeEnum, +} from './destination/destination'; +export type { + DomainEnum as GetCallResponseObjDomainEnum, + StatusEnum as GetCallResponseObjStatusEnum, + ResultEnum as GetCallResponseObjResultEnum, + ReasonEnum as GetCallResponseObjReasonEnum, +} from './get-call-response-obj/get-call-response-obj'; +export type { + CapabilityEnum as GetNumbersResponseObjNumbersInnerCapabilityEnum, +} from './get-numbers-response-obj-numbers-inner/get-numbers-response-obj-numbers-inner'; +export type { + NumberTypeEnum as GetQueryNumberNumberItemNumberTypeEnum, +} from './get-query-number-number-item/get-query-number-number-item'; +export type { + DomainEnum as TtsCalloutRequestDomainEnum, +} from './tts-callout-request/tts-callout-request'; +export type { + CapabilityEnum as UnassignNumbersCapabilityEnum, +} from './unassign-numbers/unassign-numbers'; +export type { + CapabilityEnum as UpdateNumbersCapabilityEnum, +} from './update-numbers/update-numbers'; +export type { + CommandEnum as ManageConferenceParticipantRequestCommandEnum, + MohEnum as ManageConferenceParticipantRequestMohEnum, +} from './manage-conference-participant-request/manage-conference-participant-request'; diff --git a/packages/voice/src/models/v1/get-call-response-obj/get-call-response-obj.ts b/packages/voice/src/models/v1/get-call-response-obj/get-call-response-obj.ts new file mode 100644 index 00000000..c313f7df --- /dev/null +++ b/packages/voice/src/models/v1/get-call-response-obj/get-call-response-obj.ts @@ -0,0 +1,41 @@ +/** + * Model: GetCallResponseObj + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +export interface GetCallResponseObj { + + /** Contains the caller information. */ + from?: string; + /** Contains the callee information. */ + to?: string; + /** Must be `pstn` for PSTN. */ + domain?: DomainEnum; + /** The unique identifier of the call. */ + callId?: string; + /** The duration of the call in seconds. */ + duration?: number; + /** The status of the call. Either `ONGOING` or `FINAL` */ + status?: StatusEnum; + /** Contains the result of a call. */ + result?: ResultEnum; + /** Contains the reason why a call ended. */ + reason?: ReasonEnum; + /** The date and time of the call. */ + timestamp?: Date; + /** An object that can be used to pass custom information related to the call. */ + custom?: object; + /** The rate per minute that was charged for the call. */ + userRate?: string; + /** The total amount charged for the call. */ + debit?: string; +} + +export type DomainEnum = 'pstn'; +export type StatusEnum = 'ONGOING' | 'FINAL'; +export type ResultEnum = 'N/A' | 'ANSWERED' | 'BUSY' | 'NOANSWER' | 'FAILED'; +export type ReasonEnum = 'N/A' | 'TIMEOUT' | 'CALLERHANGUP' | 'CALLEEHANGUP' | 'BLOCKED' | 'NOCREDITPARTNER' | 'MANAGERHANGUP' | 'CANCEL' | 'GENERALERROR'; + diff --git a/packages/voice/src/models/v1/get-call-response-obj/index.ts b/packages/voice/src/models/v1/get-call-response-obj/index.ts new file mode 100644 index 00000000..b2baf4e9 --- /dev/null +++ b/packages/voice/src/models/v1/get-call-response-obj/index.ts @@ -0,0 +1 @@ +export type { GetCallResponseObj } from './get-call-response-obj'; diff --git a/packages/voice/src/models/v1/get-callbacks-url/get-callbacks-url.ts b/packages/voice/src/models/v1/get-callbacks-url/get-callbacks-url.ts new file mode 100644 index 00000000..b626dba3 --- /dev/null +++ b/packages/voice/src/models/v1/get-callbacks-url/get-callbacks-url.ts @@ -0,0 +1,20 @@ +/** + * Model: GetCallbacksUrl + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * Gets primary and if configured fallback callback URLs + */ +export interface GetCallbacksUrl { + + /** Your primary callback URL */ + primary?: string; + /** Your fallback callback URL (returned if configured). It is used only if Sinch platform gets a timeout or error from your primary callback URL. */ + fallback?: string; +} + + diff --git a/packages/voice/src/models/v1/get-callbacks-url/index.ts b/packages/voice/src/models/v1/get-callbacks-url/index.ts new file mode 100644 index 00000000..0b028827 --- /dev/null +++ b/packages/voice/src/models/v1/get-callbacks-url/index.ts @@ -0,0 +1 @@ +export type { GetCallbacksUrl } from './get-callbacks-url'; diff --git a/packages/voice/src/models/v1/get-callbacks/get-callbacks.ts b/packages/voice/src/models/v1/get-callbacks/get-callbacks.ts new file mode 100644 index 00000000..45bc51df --- /dev/null +++ b/packages/voice/src/models/v1/get-callbacks/get-callbacks.ts @@ -0,0 +1,16 @@ +/** + * Model: GetCallbacks + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { GetCallbacksUrl } from '../get-callbacks-url'; + +export interface GetCallbacks { + + /** @see GetCallbacksUrl */ + url?: GetCallbacksUrl; +} + + diff --git a/packages/voice/src/models/v1/get-callbacks/index.ts b/packages/voice/src/models/v1/get-callbacks/index.ts new file mode 100644 index 00000000..746f7acc --- /dev/null +++ b/packages/voice/src/models/v1/get-callbacks/index.ts @@ -0,0 +1 @@ +export type { GetCallbacks } from './get-callbacks'; diff --git a/packages/voice/src/models/v1/get-callout-response-obj/get-callout-response-obj.ts b/packages/voice/src/models/v1/get-callout-response-obj/get-callout-response-obj.ts new file mode 100644 index 00000000..2f3d5a6a --- /dev/null +++ b/packages/voice/src/models/v1/get-callout-response-obj/get-callout-response-obj.ts @@ -0,0 +1,18 @@ +/** + * Model: GetCalloutResponseObj + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * The returned call ID. + */ +export interface GetCalloutResponseObj { + + /** The returned call identifier. */ + callId?: string; +} + + diff --git a/packages/voice/src/models/v1/get-callout-response-obj/index.ts b/packages/voice/src/models/v1/get-callout-response-obj/index.ts new file mode 100644 index 00000000..ecfec137 --- /dev/null +++ b/packages/voice/src/models/v1/get-callout-response-obj/index.ts @@ -0,0 +1 @@ +export type { GetCalloutResponseObj } from './get-callout-response-obj'; diff --git a/packages/voice/src/models/v1/get-conference-info-response-participants-inner/get-conference-info-response-participants-inner.ts b/packages/voice/src/models/v1/get-conference-info-response-participants-inner/get-conference-info-response-participants-inner.ts new file mode 100644 index 00000000..a406af88 --- /dev/null +++ b/packages/voice/src/models/v1/get-conference-info-response-participants-inner/get-conference-info-response-participants-inner.ts @@ -0,0 +1,21 @@ +/** + * Model: GetConferenceInfoResponseParticipantsInner + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +export interface GetConferenceInfoResponseParticipantsInner { + + /** The phone number of the PSTN participant that was connected in the conference, or whatever was passed as CLI for data originated/terminated calls. */ + cli?: string; + /** The callId of the call leg that the participant joined the conference. */ + id?: string; + /** The number of seconds that the participant has been connected to the conference. */ + duration?: number; + muted?: boolean; + onhold?: boolean; +} + + diff --git a/packages/voice/src/models/v1/get-conference-info-response-participants-inner/index.ts b/packages/voice/src/models/v1/get-conference-info-response-participants-inner/index.ts new file mode 100644 index 00000000..fd4fc704 --- /dev/null +++ b/packages/voice/src/models/v1/get-conference-info-response-participants-inner/index.ts @@ -0,0 +1 @@ +export type { GetConferenceInfoResponseParticipantsInner } from './get-conference-info-response-participants-inner'; diff --git a/packages/voice/src/models/v1/get-conference-info-response/get-conference-info-response.ts b/packages/voice/src/models/v1/get-conference-info-response/get-conference-info-response.ts new file mode 100644 index 00000000..4a9a42f1 --- /dev/null +++ b/packages/voice/src/models/v1/get-conference-info-response/get-conference-info-response.ts @@ -0,0 +1,19 @@ +/** + * Model: GetConferenceInfoResponse + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { GetConferenceInfoResponseParticipantsInner } from '../get-conference-info-response-participants-inner'; + +/** + * The response returns information about the participants in the conference. + */ +export interface GetConferenceInfoResponse { + + /** List of GetConferenceInfoResponseParticipantsInners */ + participants?: GetConferenceInfoResponseParticipantsInner[]; +} + + diff --git a/packages/voice/src/models/v1/get-conference-info-response/index.ts b/packages/voice/src/models/v1/get-conference-info-response/index.ts new file mode 100644 index 00000000..41a8a82f --- /dev/null +++ b/packages/voice/src/models/v1/get-conference-info-response/index.ts @@ -0,0 +1 @@ +export type { GetConferenceInfoResponse } from './get-conference-info-response'; diff --git a/packages/voice/src/models/v1/get-numbers-response-obj-numbers-inner/get-numbers-response-obj-numbers-inner.ts b/packages/voice/src/models/v1/get-numbers-response-obj-numbers-inner/get-numbers-response-obj-numbers-inner.ts new file mode 100644 index 00000000..5ab29448 --- /dev/null +++ b/packages/voice/src/models/v1/get-numbers-response-obj-numbers-inner/get-numbers-response-obj-numbers-inner.ts @@ -0,0 +1,20 @@ +/** + * Model: GetNumbersResponseObjNumbersInner + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +export interface GetNumbersResponseObjNumbersInner { + + /** Numbers that you own in E.164 format. */ + number?: string; + /** Indicates the application where the number(s) will be assigned. If no number is assigned the applicationkey will not be returned. */ + applicationkey?: string; + /** indicates the DID capability that needs to be assigned to the chosen application. Valid values are \'voice\' and \'sms\'. Please note that the DID needs to support the selected capability. */ + capability?: CapabilityEnum; +} + +export type CapabilityEnum = 'voice' | 'sms'; + diff --git a/packages/voice/src/models/v1/get-numbers-response-obj-numbers-inner/index.ts b/packages/voice/src/models/v1/get-numbers-response-obj-numbers-inner/index.ts new file mode 100644 index 00000000..da3de84f --- /dev/null +++ b/packages/voice/src/models/v1/get-numbers-response-obj-numbers-inner/index.ts @@ -0,0 +1 @@ +export type { GetNumbersResponseObjNumbersInner } from './get-numbers-response-obj-numbers-inner'; diff --git a/packages/voice/src/models/v1/get-numbers-response-obj/get-numbers-response-obj.ts b/packages/voice/src/models/v1/get-numbers-response-obj/get-numbers-response-obj.ts new file mode 100644 index 00000000..516d2ba8 --- /dev/null +++ b/packages/voice/src/models/v1/get-numbers-response-obj/get-numbers-response-obj.ts @@ -0,0 +1,16 @@ +/** + * Model: GetNumbersResponseObj + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { GetNumbersResponseObjNumbersInner } from '../get-numbers-response-obj-numbers-inner'; + +export interface GetNumbersResponseObj { + + /** The object type. Will always be list of numbers, associated application keys and capabilities */ + numbers?: GetNumbersResponseObjNumbersInner[]; +} + + diff --git a/packages/voice/src/models/v1/get-numbers-response-obj/index.ts b/packages/voice/src/models/v1/get-numbers-response-obj/index.ts new file mode 100644 index 00000000..8cd685b8 --- /dev/null +++ b/packages/voice/src/models/v1/get-numbers-response-obj/index.ts @@ -0,0 +1 @@ +export type { GetNumbersResponseObj } from './get-numbers-response-obj'; diff --git a/packages/voice/src/models/v1/get-query-number-number-item-rate/get-query-number-number-item-rate.ts b/packages/voice/src/models/v1/get-query-number-number-item-rate/get-query-number-number-item-rate.ts new file mode 100644 index 00000000..4e09ed2c --- /dev/null +++ b/packages/voice/src/models/v1/get-query-number-number-item-rate/get-query-number-number-item-rate.ts @@ -0,0 +1,20 @@ +/** + * Model: GetQueryNumberNumberItemRate + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * The cost per minute to call the destination number. + */ +export interface GetQueryNumberNumberItemRate { + + /** The currency ID of the rate, for example, `USD`. */ + currencyId?: string; + /** The amount. */ + amount?: number; +} + + diff --git a/packages/voice/src/models/v1/get-query-number-number-item-rate/index.ts b/packages/voice/src/models/v1/get-query-number-number-item-rate/index.ts new file mode 100644 index 00000000..95eea515 --- /dev/null +++ b/packages/voice/src/models/v1/get-query-number-number-item-rate/index.ts @@ -0,0 +1 @@ +export type { GetQueryNumberNumberItemRate } from './get-query-number-number-item-rate'; diff --git a/packages/voice/src/models/v1/get-query-number-number-item/get-query-number-number-item.ts b/packages/voice/src/models/v1/get-query-number-number-item/get-query-number-number-item.ts new file mode 100644 index 00000000..b5608adb --- /dev/null +++ b/packages/voice/src/models/v1/get-query-number-number-item/get-query-number-number-item.ts @@ -0,0 +1,28 @@ +/** + * Model: GetQueryNumberNumberItem + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { GetQueryNumberNumberItemRate } from '../get-query-number-number-item-rate'; + +/** + * The number item object. + */ +export interface GetQueryNumberNumberItem { + + /** The ISO 3166-1 formatted country code. */ + countryId?: string; + /** The type of the number. */ + numberType?: NumberTypeEnum; + /** The number in E.164 format. */ + normalizedNumber?: string; + /** Concerns whether the call is restricted or not. */ + restricted?: boolean; + /** @see GetQueryNumberNumberItemRate */ + rate?: GetQueryNumberNumberItemRate; +} + +export type NumberTypeEnum = 'Unknown' | 'Fixed' | 'Mobile' | 'Other'; + diff --git a/packages/voice/src/models/v1/get-query-number-number-item/index.ts b/packages/voice/src/models/v1/get-query-number-number-item/index.ts new file mode 100644 index 00000000..109ee456 --- /dev/null +++ b/packages/voice/src/models/v1/get-query-number-number-item/index.ts @@ -0,0 +1 @@ +export type { GetQueryNumberNumberItem } from './get-query-number-number-item'; diff --git a/packages/voice/src/models/v1/get-query-number/get-query-number.ts b/packages/voice/src/models/v1/get-query-number/get-query-number.ts new file mode 100644 index 00000000..dd7f7619 --- /dev/null +++ b/packages/voice/src/models/v1/get-query-number/get-query-number.ts @@ -0,0 +1,18 @@ +/** + * Model: GetQueryNumber + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { GetQueryNumberNumberItem } from '../get-query-number-number-item'; + +export interface GetQueryNumber { + + /** The type of method. */ + method?: string; + /** @see GetQueryNumberNumberItem */ + numberItem?: GetQueryNumberNumberItem; +} + + diff --git a/packages/voice/src/models/v1/get-query-number/index.ts b/packages/voice/src/models/v1/get-query-number/index.ts new file mode 100644 index 00000000..b4b9b5a4 --- /dev/null +++ b/packages/voice/src/models/v1/get-query-number/index.ts @@ -0,0 +1 @@ +export type { GetQueryNumber } from './get-query-number'; diff --git a/packages/voice/src/models/v1/get-recording-file-info/get-recording-file-info.ts b/packages/voice/src/models/v1/get-recording-file-info/get-recording-file-info.ts new file mode 100644 index 00000000..903a2984 --- /dev/null +++ b/packages/voice/src/models/v1/get-recording-file-info/get-recording-file-info.ts @@ -0,0 +1,18 @@ +/** + * Model: GetRecordingFileInfo + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +export interface GetRecordingFileInfo { + + key?: string; + url?: string; + createdOn?: Date; + expiresOn?: Date; + headers?: object; +} + + diff --git a/packages/voice/src/models/v1/get-recording-file-info/index.ts b/packages/voice/src/models/v1/get-recording-file-info/index.ts new file mode 100644 index 00000000..9f1e7dac --- /dev/null +++ b/packages/voice/src/models/v1/get-recording-file-info/index.ts @@ -0,0 +1 @@ +export type { GetRecordingFileInfo } from './get-recording-file-info'; diff --git a/packages/voice/src/models/v1/ice-request-to/ice-request-to.ts b/packages/voice/src/models/v1/ice-request-to/ice-request-to.ts new file mode 100644 index 00000000..223ec843 --- /dev/null +++ b/packages/voice/src/models/v1/ice-request-to/ice-request-to.ts @@ -0,0 +1,20 @@ +/** + * Model: IceRequestTo + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * An object containing information about the recipient of the call. + */ +export interface IceRequestTo { + + /** The type of the destination. */ + type?: string; + /** The phone number, user name, or other identifier of the destination. */ + endpoint?: string; +} + + diff --git a/packages/voice/src/models/v1/ice-request-to/index.ts b/packages/voice/src/models/v1/ice-request-to/index.ts new file mode 100644 index 00000000..1b5ac9eb --- /dev/null +++ b/packages/voice/src/models/v1/ice-request-to/index.ts @@ -0,0 +1 @@ +export type { IceRequestTo } from './ice-request-to'; diff --git a/packages/voice/src/models/v1/ice-request-user-rate/ice-request-user-rate.ts b/packages/voice/src/models/v1/ice-request-user-rate/ice-request-user-rate.ts new file mode 100644 index 00000000..7c1035d9 --- /dev/null +++ b/packages/voice/src/models/v1/ice-request-user-rate/ice-request-user-rate.ts @@ -0,0 +1,20 @@ +/** + * Model: IceRequestUserRate + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * The rate that will be charged for the call established to the original destination. If the SVAML response specifies another destination, the same rate may not apply. + */ +export interface IceRequestUserRate { + + /** The currency ID of the rate, for example, `USD`. */ + currencyId?: string; + /** The amount of the rate. */ + amount?: number; +} + + diff --git a/packages/voice/src/models/v1/ice-request-user-rate/index.ts b/packages/voice/src/models/v1/ice-request-user-rate/index.ts new file mode 100644 index 00000000..312645fe --- /dev/null +++ b/packages/voice/src/models/v1/ice-request-user-rate/index.ts @@ -0,0 +1 @@ +export type { IceRequestUserRate } from './ice-request-user-rate'; diff --git a/packages/voice/src/models/v1/ice-request/ice-request.ts b/packages/voice/src/models/v1/ice-request/ice-request.ts new file mode 100644 index 00000000..ed81c5fa --- /dev/null +++ b/packages/voice/src/models/v1/ice-request/ice-request.ts @@ -0,0 +1,49 @@ +/** + * Model: IceRequest + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { CallHeader } from '../call-header'; +import { IceRequestTo } from '../ice-request-to'; +import { IceRequestUserRate } from '../ice-request-user-rate'; + +/** + * The request body of an Incoming Call Event. + */ +export interface IceRequest { + + /** Must have the value `ice`. */ + event?: string; + /** The unique ID assigned to this call. */ + callId?: string; + /** The path of the API resource. */ + callResourceUrl?: string; + /** The timestamp in UTC format. */ + timestamp?: Date; + /** The current API version. */ + version?: number; + /** A string that can be used to pass custom information related to the call. */ + custom?: string; + /** @see IceRequestUserRate */ + userRate?: IceRequestUserRate; + /** The number that will be displayed to the recipient of the call. To set your own CLI, you may use your verified number or your Dashboard virtual number and add it to the `connectPSTN` SVAML response to the Incoming Call Event request. It must be in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format. */ + cli?: string; + /** @see IceRequestTo */ + to?: IceRequestTo; + /** The domain destination of the incoming call. */ + domain?: string; + /** The unique application key. You can find it in the Sinch [dashboard](https://dashboard.sinch.com/voice/apps). */ + applicationKey?: string; + /** The origination domain of the incoming call. */ + originationType?: string; + /** The duration of the call in seconds. */ + duration?: number; + /** The redirected dialled number identification service. */ + rdnis?: string; + /** If the call is initiated by a Sinch SDK client, call headers are the headers specified by the *caller* client. Read more about call headers [here](../../../call-headers). */ + callHeaders?: CallHeader[]; +} + + diff --git a/packages/voice/src/models/v1/ice-request/index.ts b/packages/voice/src/models/v1/ice-request/index.ts new file mode 100644 index 00000000..ba97b4d9 --- /dev/null +++ b/packages/voice/src/models/v1/ice-request/index.ts @@ -0,0 +1 @@ +export type { IceRequest } from './ice-request'; diff --git a/packages/voice/src/models/v1/index.ts b/packages/voice/src/models/v1/index.ts new file mode 100644 index 00000000..f572f062 --- /dev/null +++ b/packages/voice/src/models/v1/index.ts @@ -0,0 +1,62 @@ +export * from './ace-request'; +export * from './ace-request-amd'; +export * from './call-header'; +export * from './callout-request'; +export * from './conference-callout-request'; +export * from './conference-callout-request-conference-dtmf-options'; +export * from './custom-callout-request'; +export * from './destination'; +export * from './dice-request'; +export * from './dice-request-debit'; +export * from './dice-request-user-rate'; +export * from './voice-error'; +export * from './get-call-response-obj'; +export * from './get-callbacks'; +export * from './get-callbacks-url'; +export * from './get-callout-response-obj'; +export * from './get-conference-info-response'; +export * from './get-conference-info-response-participants-inner'; +export * from './get-numbers-response-obj'; +export * from './get-numbers-response-obj-numbers-inner'; +export * from './get-query-number'; +export * from './get-query-number-number-item'; +export * from './get-query-number-number-item-rate'; +export * from './get-recording-file-info'; +export * from './ice-request'; +export * from './ice-request-to'; +export * from './ice-request-user-rate'; +export * from './manage-conference-participant-request'; +export * from './menu'; +export * from './notify-error-request'; +export * from './notify-request'; +export * from './option'; +export * from './pie-request'; +export * from './pie-request-menu-result'; +export * from './svaml-request-body'; +export * from './svaml-action'; +export * from './svaml-action-connect-conf'; +export * from './svaml-action-connect-conf-conference-dtmf-options'; +export * from './svaml-action-connect-mxp'; +export * from './svaml-action-connect-mxp-destination'; +export * from './svaml-action-connect-pstn'; +export * from './svaml-action-connect-pstn-amd'; +export * from './svaml-action-connect-sip'; +export * from './svaml-action-connect-sip-destination'; +export * from './svaml-action-continue'; +export * from './svaml-action-hangup'; +export * from './svaml-action-park'; +export * from './svaml-action-run-menu'; +export * from './svaml-instruction'; +export * from './svaml-instruction-answer'; +export * from './svaml-instruction-play-files'; +export * from './svaml-instruction-say'; +export * from './svaml-instruction-send-dtmf'; +export * from './svaml-instruction-set-cookie'; +export * from './svaml-instruction-start-recording'; +export * from './svaml-instruction-stop-recording'; +export * from './tts-callout-request'; +export * from './unassign-numbers'; +export * from './update-callbacks'; +export * from './update-callbacks-url'; +export * from './update-numbers'; +export * from './enums'; diff --git a/packages/voice/src/models/v1/manage-conference-participant-request/index.ts b/packages/voice/src/models/v1/manage-conference-participant-request/index.ts new file mode 100644 index 00000000..de763e08 --- /dev/null +++ b/packages/voice/src/models/v1/manage-conference-participant-request/index.ts @@ -0,0 +1 @@ +export type { ManageConferenceParticipantRequest } from './manage-conference-participant-request'; diff --git a/packages/voice/src/models/v1/manage-conference-participant-request/manage-conference-participant-request.ts b/packages/voice/src/models/v1/manage-conference-participant-request/manage-conference-participant-request.ts new file mode 100644 index 00000000..e5e62996 --- /dev/null +++ b/packages/voice/src/models/v1/manage-conference-participant-request/manage-conference-participant-request.ts @@ -0,0 +1,28 @@ +/** + * Model: ManageConferenceParticipantRequest + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * + */ +export interface ManageConferenceParticipantRequest { + + /** Action to apply on conference participant. */ + command: CommandEnum; + /** Means \"music on hold\". If this optional parameter is included, plays music to the first participant in a conference while they\'re alone and waiting for other participants to join. If `moh` isn\'t specified, the user will only hear silence while alone in the conference. This property is only available to use with the `onhold` command. */ + moh?: MohEnum; +} + +export type CommandEnum = 'mute' + | 'unmute' + | 'onhold' + | 'resume'; + +export type MohEnum = 'ring' + | 'music1' + | 'music2' + | 'music3'; diff --git a/packages/voice/src/models/v1/menu/index.ts b/packages/voice/src/models/v1/menu/index.ts new file mode 100644 index 00000000..e8102450 --- /dev/null +++ b/packages/voice/src/models/v1/menu/index.ts @@ -0,0 +1 @@ +export type { Menu } from './menu'; diff --git a/packages/voice/src/models/v1/menu/menu.ts b/packages/voice/src/models/v1/menu/menu.ts new file mode 100644 index 00000000..9f278288 --- /dev/null +++ b/packages/voice/src/models/v1/menu/menu.ts @@ -0,0 +1,33 @@ +/** + * Model: Menu + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { Option } from '../option'; + +/** + * An IVR menu that contains an audio prompt as well as configured options. + */ +export interface Menu { + + /** The identifier of a menu. One menu must have the ID value of `main`. */ + id: string; + /** The main voice prompt that the user hears when the menu starts the first time. You can use text-to-speech using the `#tts[]` element, SSML commands using the `#ssml[]` element, pre-recorded messages, or URL references to external media resources. You can use multiple prompts by separating each prompt with a semi-colon (`;`). If multiple prompts are used, they will be played in the order they are specified, without any pauses between playback. For external media resources, you can use an `#href[...]` or directly specify the full URL. Check the [Supported audio formats](/docs/voice/api-reference/supported-audio-formats) section for more information. */ + mainPrompt?: string; + /** The prompt that will be played if valid or expected DTMF digits are not entered. You can use text-to-speech using the `#tts[]` element, SSML commands using the `#ssml[]` element, pre-recorded messages, or URL references to external media resources. You can use multiple prompts by separating each prompt with a semi-colon (`;`). If multiple prompts are used, they will be played in the order they are specified, without any pauses between playback. For external media resources, you can use an `#href[...]` or directly specify the full URL. Check the [Supported audio formats](/docs/voice/api-reference/supported-audio-formats) section for more information. */ + repeatPrompt?: string; + /** The number of times that the `repeatPrompt` is played. */ + repeats?: number; + /** The maximum number of digits expected for a user to enter. Once these digits are collected, a [Prompt Input Event (PIE)](../../voice/tag/Callbacks/#tag/Callbacks/operation/pie) is triggered containing these digits. */ + maxDigits?: number; + /** Determines silence for the purposes of collecting a DTMF or voice response in milliseconds. If the timeout is reached, the response is considered completed and will be submitted. */ + timeoutMills?: number; + /** Sets a limit for the maximum amount of time allowed to collect voice input. */ + maxTimeoutMills?: number; + /** The set of options available in the menu. */ + options?: Option[]; +} + + diff --git a/packages/voice/src/models/v1/notify-error-request/index.ts b/packages/voice/src/models/v1/notify-error-request/index.ts new file mode 100644 index 00000000..ebba66d8 --- /dev/null +++ b/packages/voice/src/models/v1/notify-error-request/index.ts @@ -0,0 +1 @@ +export type { NotifyErrorRequest } from './notify-error-request'; diff --git a/packages/voice/src/models/v1/notify-error-request/notify-error-request.ts b/packages/voice/src/models/v1/notify-error-request/notify-error-request.ts new file mode 100644 index 00000000..91ad4472 --- /dev/null +++ b/packages/voice/src/models/v1/notify-error-request/notify-error-request.ts @@ -0,0 +1,32 @@ +/** + * Model: NotifyErrorRequest + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * The request body of Notify Event notifying of an error. + */ +export interface NotifyErrorRequest { + + /** Must have the value `notify`. */ + event?: string; + /** The current API version. */ + version?: number; + /** The type of information communicated in the notification. Must have the value `callingerror`. */ + type?: string; + /** The unique ID assigned to this call. */ + callId?: string; + /** The error code of the error. */ + errorCode?: number; + /** The error message of the error. */ + errorMsg?: string; + /** The user ID that initiated the call. */ + user?: string; + /** An optional parameter containing notification-specific information. */ + custom?: string; +} + + diff --git a/packages/voice/src/models/v1/notify-request/index.ts b/packages/voice/src/models/v1/notify-request/index.ts new file mode 100644 index 00000000..ceaa40fa --- /dev/null +++ b/packages/voice/src/models/v1/notify-request/index.ts @@ -0,0 +1 @@ +export type { NotifyRequest } from './notify-request'; diff --git a/packages/voice/src/models/v1/notify-request/notify-request.ts b/packages/voice/src/models/v1/notify-request/notify-request.ts new file mode 100644 index 00000000..ee5c9b4c --- /dev/null +++ b/packages/voice/src/models/v1/notify-request/notify-request.ts @@ -0,0 +1,26 @@ +/** + * Model: NotifyRequest + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * The request body of a Notify Event. + */ +export interface NotifyRequest { + + /** Must have the value `notify`. */ + event?: string; + /** The unique ID assigned to this call. */ + callId?: string; + /** The current API version. */ + version?: number; + /** The type of information communicated in the notification. */ + type?: string; + /** An optional parameter containing notification-specific information. */ + custom?: string; +} + + diff --git a/packages/voice/src/models/v1/option/index.ts b/packages/voice/src/models/v1/option/index.ts new file mode 100644 index 00000000..76947243 --- /dev/null +++ b/packages/voice/src/models/v1/option/index.ts @@ -0,0 +1 @@ +export type { Option } from './option'; diff --git a/packages/voice/src/models/v1/option/option.ts b/packages/voice/src/models/v1/option/option.ts new file mode 100644 index 00000000..e158b7b0 --- /dev/null +++ b/packages/voice/src/models/v1/option/option.ts @@ -0,0 +1,20 @@ +/** + * Model: Option + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * A configured option that the user can trigger to perform an action. + */ +export interface Option { + + /** A DTMF digit the user can press to trigger the configured action. */ + dtmf: string; + /** Determines which action is taken when the DTMF digit is pressed. */ + action: string; +} + + diff --git a/packages/voice/src/models/v1/pie-request-menu-result/index.ts b/packages/voice/src/models/v1/pie-request-menu-result/index.ts new file mode 100644 index 00000000..8e3dcc75 --- /dev/null +++ b/packages/voice/src/models/v1/pie-request-menu-result/index.ts @@ -0,0 +1 @@ +export type { PieRequestMenuResult } from './pie-request-menu-result'; diff --git a/packages/voice/src/models/v1/pie-request-menu-result/pie-request-menu-result.ts b/packages/voice/src/models/v1/pie-request-menu-result/pie-request-menu-result.ts new file mode 100644 index 00000000..d1b80fdf --- /dev/null +++ b/packages/voice/src/models/v1/pie-request-menu-result/pie-request-menu-result.ts @@ -0,0 +1,24 @@ +/** + * Model: PieRequestMenuResult + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * An object containing information about the returned menu result. + */ +export interface PieRequestMenuResult { + + /** The ID of the menu that triggered the prompt input event. */ + menuId?: string; + /** The type of information that\'s returned. */ + type?: string; + /** The value of the returned information. */ + value?: string; + /** The type of input received. */ + inputMethod?: string; +} + + diff --git a/packages/voice/src/models/v1/pie-request/index.ts b/packages/voice/src/models/v1/pie-request/index.ts new file mode 100644 index 00000000..fdfecd4d --- /dev/null +++ b/packages/voice/src/models/v1/pie-request/index.ts @@ -0,0 +1 @@ +export type { PieRequest } from './pie-request'; diff --git a/packages/voice/src/models/v1/pie-request/pie-request.ts b/packages/voice/src/models/v1/pie-request/pie-request.ts new file mode 100644 index 00000000..ba72d9a0 --- /dev/null +++ b/packages/voice/src/models/v1/pie-request/pie-request.ts @@ -0,0 +1,29 @@ +/** + * Model: PieRequest + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { PieRequestMenuResult } from '../pie-request-menu-result'; + +/** + * The request body of a Prompt Input Event. + */ +export interface PieRequest { + + /** Must have the value `pie`. */ + event?: string; + /** The unique ID assigned to this call. */ + callId?: string; + /** The timestamp in UTC format. */ + timestamp?: Date; + /** @see PieRequestMenuResult */ + menuResult?: PieRequestMenuResult; + /** The current API version. */ + version?: number; + /** The unique application key. You can find it in the Sinch [dashboard](https://dashboard.sinch.com/voice/apps). */ + applicationKey?: string; +} + + diff --git a/packages/voice/src/models/v1/svaml-action-connect-conf-conference-dtmf-options/index.ts b/packages/voice/src/models/v1/svaml-action-connect-conf-conference-dtmf-options/index.ts new file mode 100644 index 00000000..85f37c68 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-connect-conf-conference-dtmf-options/index.ts @@ -0,0 +1 @@ +export type { SvamlActionConnectConfConferenceDtmfOptions } from './svaml-action-connect-conf-conference-dtmf-options'; diff --git a/packages/voice/src/models/v1/svaml-action-connect-conf-conference-dtmf-options/svaml-action-connect-conf-conference-dtmf-options.ts b/packages/voice/src/models/v1/svaml-action-connect-conf-conference-dtmf-options/svaml-action-connect-conf-conference-dtmf-options.ts new file mode 100644 index 00000000..7e0f3198 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-connect-conf-conference-dtmf-options/svaml-action-connect-conf-conference-dtmf-options.ts @@ -0,0 +1,22 @@ +/** + * Model: SvamlActionConnectConfConferenceDtmfOptions + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * Options to control how DTMF signals are used by the participant in the conference. For information on how to use this feature, read more [here](../../conference-dtmf). + */ +export interface SvamlActionConnectConfConferenceDtmfOptions { + + /** Determines what DTMF mode the participant will use in the call. */ + mode?: string; + /** The maximum number of accepted digits before sending the collected input via a PIE callback. The default value is `1`. If the value is greater than `1`, the PIE callback is triggered by one of the three following events: - No additional digit is entered before the `timeoutMills` timeout period has elapsed. - The `#` character is entered. - The maximum number of digits has been entered. */ + maxDigits?: number; + /** The number of milliseconds that the system will wait between entered digits before triggering the PIE callback. The default value is `3000`. */ + timeoutMills?: number; +} + + diff --git a/packages/voice/src/models/v1/svaml-action-connect-conf/index.ts b/packages/voice/src/models/v1/svaml-action-connect-conf/index.ts new file mode 100644 index 00000000..3631ebbe --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-connect-conf/index.ts @@ -0,0 +1 @@ +export type { SvamlActionConnectConf } from './svaml-action-connect-conf'; diff --git a/packages/voice/src/models/v1/svaml-action-connect-conf/svaml-action-connect-conf.ts b/packages/voice/src/models/v1/svaml-action-connect-conf/svaml-action-connect-conf.ts new file mode 100644 index 00000000..902b3218 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-connect-conf/svaml-action-connect-conf.ts @@ -0,0 +1,25 @@ +/** + * Model: SvamlActionConnectConf + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { SvamlActionConnectConfConferenceDtmfOptions } from '../svaml-action-connect-conf-conference-dtmf-options'; + +/** + * Connects an incoming call to a conference. Available to use in a response to an [Incoming Call Event](../../voice/tag/Callbacks/#tag/Callbacks/operation/ice) callback. + */ +export interface SvamlActionConnectConf { + + /** The name property. Must have the value `connectConf`. */ + name: 'connectConf'; + /** The unique identifier of the conference. Shouldn't exceed 64 characters. */ + conferenceId: string; + /** @see SvamlActionConnectConfConferenceDtmfOptions */ + conferenceDtmfOptions?: SvamlActionConnectConfConferenceDtmfOptions; + /** Means "music on hold". If this optional parameter is included, plays music to the first participant in a conference while they\'re alone and waiting for other participants to join. If `moh` isn't specified, the user will only hear silence while alone in the conference. */ + moh?: string; +} + + diff --git a/packages/voice/src/models/v1/svaml-action-connect-mxp-destination/index.ts b/packages/voice/src/models/v1/svaml-action-connect-mxp-destination/index.ts new file mode 100644 index 00000000..a5b4c072 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-connect-mxp-destination/index.ts @@ -0,0 +1 @@ +export type { SvamlActionConnectMxpDestination } from './svaml-action-connect-mxp-destination'; diff --git a/packages/voice/src/models/v1/svaml-action-connect-mxp-destination/svaml-action-connect-mxp-destination.ts b/packages/voice/src/models/v1/svaml-action-connect-mxp-destination/svaml-action-connect-mxp-destination.ts new file mode 100644 index 00000000..b15ffce3 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-connect-mxp-destination/svaml-action-connect-mxp-destination.ts @@ -0,0 +1,20 @@ +/** + * Model: SvamlActionConnectMxpDestination + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * Allows you to specify or override the final destination of the call. If the final destination of the call is not dialed, this is a required parameter. + */ +export interface SvamlActionConnectMxpDestination { + + /** The type of the definition. */ + type: string; + /** The phone number or username of the desired call destination. */ + endpoint: string; +} + + diff --git a/packages/voice/src/models/v1/svaml-action-connect-mxp/index.ts b/packages/voice/src/models/v1/svaml-action-connect-mxp/index.ts new file mode 100644 index 00000000..314cab22 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-connect-mxp/index.ts @@ -0,0 +1 @@ +export type { SvamlActionConnectMxp } from './svaml-action-connect-mxp'; diff --git a/packages/voice/src/models/v1/svaml-action-connect-mxp/svaml-action-connect-mxp.ts b/packages/voice/src/models/v1/svaml-action-connect-mxp/svaml-action-connect-mxp.ts new file mode 100644 index 00000000..f119092d --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-connect-mxp/svaml-action-connect-mxp.ts @@ -0,0 +1,24 @@ +/** + * Model: SvamlActionConnectMxp + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { CallHeader } from '../call-header'; +import { SvamlActionConnectMxpDestination } from '../svaml-action-connect-mxp-destination'; + +/** + * Determines how an application-to-application call is connected. Available to use in a response to an [Incoming Call Event](../../voice/tag/Callbacks/#tag/Callbacks/operation/ice) callback. + */ +export interface SvamlActionConnectMxp { + + /** The name property. Must have the value `connectMxp`. */ + name: 'connectMxp'; + /** @see SvamlActionConnectMxpDestination */ + destination?: SvamlActionConnectMxpDestination; + /** An optional parameter that allows you to specify or override call headers provided to the receiving Sinch SDK client. Read more about call headers [here](../../call-headers/). */ + callheaders?: CallHeader[]; +} + + diff --git a/packages/voice/src/models/v1/svaml-action-connect-pstn-amd/index.ts b/packages/voice/src/models/v1/svaml-action-connect-pstn-amd/index.ts new file mode 100644 index 00000000..98538294 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-connect-pstn-amd/index.ts @@ -0,0 +1 @@ +export type { SvamlActionConnectPstnAmd } from './svaml-action-connect-pstn-amd'; diff --git a/packages/voice/src/models/v1/svaml-action-connect-pstn-amd/svaml-action-connect-pstn-amd.ts b/packages/voice/src/models/v1/svaml-action-connect-pstn-amd/svaml-action-connect-pstn-amd.ts new file mode 100644 index 00000000..ab24f2d6 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-connect-pstn-amd/svaml-action-connect-pstn-amd.ts @@ -0,0 +1,18 @@ +/** + * Model: SvamlActionConnectPstnAmd + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * An optional property used to enable [Answering Machine Detection](/docs/voice/api-reference/amd_v2) (AMD). + */ +export interface SvamlActionConnectPstnAmd { + + /** Sets whether AMD is enabled. */ + enabled?: boolean; +} + + diff --git a/packages/voice/src/models/v1/svaml-action-connect-pstn/index.ts b/packages/voice/src/models/v1/svaml-action-connect-pstn/index.ts new file mode 100644 index 00000000..2a0a19dd --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-connect-pstn/index.ts @@ -0,0 +1 @@ +export type { SvamlActionConnectPstn } from './svaml-action-connect-pstn'; diff --git a/packages/voice/src/models/v1/svaml-action-connect-pstn/svaml-action-connect-pstn.ts b/packages/voice/src/models/v1/svaml-action-connect-pstn/svaml-action-connect-pstn.ts new file mode 100644 index 00000000..a977b092 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-connect-pstn/svaml-action-connect-pstn.ts @@ -0,0 +1,37 @@ +/** + * Model: SvamlActionConnectPstn + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { SvamlActionConnectPstnAmd } from '../svaml-action-connect-pstn-amd'; + +/** + * Determines how a PSTN call is connected. Available to use in a response to an [Incoming Call Event](../../voice/tag/Callbacks/#tag/Callbacks/operation/ice) callback. + */ +export interface SvamlActionConnectPstn { + + /** The name property. Must have the value `connectPstn`. */ + name: 'connectPstn'; + /** Used to override where PSTN call is connected. If not specified, the extension the client called is used. */ + number?: string; + /** Specifies the locale. Uses the language code according to `ISO 639`, a dash (`-`), and a country code according to `ISO 3166-1 alpha-2`. If not specified, the default locale of `en-US` is used. */ + locale?: string; + /** The max duration of the call in seconds (max 14400 seconds). If the call is still connected at that time, it will be automatically disconnected. */ + maxDuration?: number; + /** The max duration the call will wait in ringing unanswered state before terminating with ```TIMEOUT/NO ANSWER``` on PSTN leg and ```NA/BUSY```on MXP leg. */ + dialTimeout?: number; + /** Used to override the CLI (or caller ID) of the client. The phone number of the person who initiated the call is shown as the CLI. To set your own CLI, you may use your verified number or your Dashboard virtual number. */ + cli?: string; + /** If enabled, suppresses [ACE](../../voice/tag/Callbacks/#tag/Callbacks/operation/ace) and [DICE](../../voice/tag/Callbacks/#tag/Callbacks/operation/dice) callbacks for the call. */ + suppressCallbacks?: boolean; + /** A string that determines the DTMF tones to play to the callee when the call is picked up. Valid characters are: `0-9`, `#`, and `w`. `w` renders a 500ms pause. For example, the string `ww1234#w#`, plays a 1-second pause, the DTMF tones for `1`, `2`, `3`, `4`, and `#`, followed by a 500ms pause and finally the `#` tone. This is useful if the callout destination requires a conference PIN code or an extension. If there is a calling party, it will hear progress while the DTMF is sent. */ + dtmf?: string; + /** The locale's tone to play while ringing. */ + indications?: string; + /** @see SvamlActionConnectPstnAmd */ + amd?: SvamlActionConnectPstnAmd; +} + + diff --git a/packages/voice/src/models/v1/svaml-action-connect-sip-destination/index.ts b/packages/voice/src/models/v1/svaml-action-connect-sip-destination/index.ts new file mode 100644 index 00000000..af4377c0 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-connect-sip-destination/index.ts @@ -0,0 +1 @@ +export type { SvamlActionConnectSipDestination } from './svaml-action-connect-sip-destination'; diff --git a/packages/voice/src/models/v1/svaml-action-connect-sip-destination/svaml-action-connect-sip-destination.ts b/packages/voice/src/models/v1/svaml-action-connect-sip-destination/svaml-action-connect-sip-destination.ts new file mode 100644 index 00000000..ef63a673 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-connect-sip-destination/svaml-action-connect-sip-destination.ts @@ -0,0 +1,18 @@ +/** + * Model: SvamlActionConnectSipDestination + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * Specifies where to route the SIP call. + */ +export interface SvamlActionConnectSipDestination { + + /** The SIP address. */ + endpoint: string; +} + + diff --git a/packages/voice/src/models/v1/svaml-action-connect-sip/index.ts b/packages/voice/src/models/v1/svaml-action-connect-sip/index.ts new file mode 100644 index 00000000..ffa2e326 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-connect-sip/index.ts @@ -0,0 +1 @@ +export type { SvamlActionConnectSip } from './svaml-action-connect-sip'; diff --git a/packages/voice/src/models/v1/svaml-action-connect-sip/svaml-action-connect-sip.ts b/packages/voice/src/models/v1/svaml-action-connect-sip/svaml-action-connect-sip.ts new file mode 100644 index 00000000..55a39938 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-connect-sip/svaml-action-connect-sip.ts @@ -0,0 +1,34 @@ +/** + * Model: SvamlActionConnectSip + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { CallHeader } from '../call-header'; +import { SvamlActionConnectSipDestination } from '../svaml-action-connect-sip-destination'; + +/** + * Determines how to route a call to a SIP server. Available to use in a response to an [Incoming Call Event](../../../voice/tag/Callbacks/#tag/Callbacks/operation/ice) callback. + */ +export interface SvamlActionConnectSip { + + /** The name property. Must have the value `connectSip`. */ + name: 'connectSip'; + /** @see SvamlActionConnectSipDestination */ + destination: SvamlActionConnectSipDestination; + /** The max duration of the call in seconds (max 14400 seconds). If the call is still connected at that time, it will be automatically disconnected. */ + maxDuration?: number; + /** Used to override the CLI (or caller ID) of the client. The phone number of the person who initiated the call is shown as the CLI. To set your own CLI, you may use your verified number or your Dashboard virtual number. */ + cli?: string; + /** An optional parameter to specify the SIP transport protocol. If unspecified, UDP is used. */ + transport?: string; + /** If enabled, suppresses [ACE](../../voice/tag/Callbacks/#tag/Callbacks/operation/ace) and [DICE](../../voice/tag/Callbacks/#tag/Callbacks/operation/dice) callbacks for the call. */ + suppressCallbacks?: boolean; + /** [Private SIP headers](../../sip-trunking/#receiving-calls-from-sinch-platform-to-your-sip-infrastructure) to send with the call. */ + callHeaders?: CallHeader[]; + /** Means \"music on hold\". If this optional parameter is included, plays music to the connected participant if the SIP call is placed on hold. If `moh` isn\'t specified and the SIP call is placed on hold, the user will only hear silence while during the holding period . */ + moh?: string; +} + + diff --git a/packages/voice/src/models/v1/svaml-action-continue/index.ts b/packages/voice/src/models/v1/svaml-action-continue/index.ts new file mode 100644 index 00000000..97359975 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-continue/index.ts @@ -0,0 +1 @@ +export type { SvamlActionContinue } from './svaml-action-continue'; diff --git a/packages/voice/src/models/v1/svaml-action-continue/svaml-action-continue.ts b/packages/voice/src/models/v1/svaml-action-continue/svaml-action-continue.ts new file mode 100644 index 00000000..c3362b76 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-continue/svaml-action-continue.ts @@ -0,0 +1,18 @@ +/** + * Model: SvamlActionContinue + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * Continues to set up a call. Available to use in a response to an [Answered Call Event](../../../voice/tag/Callbacks/#tag/Callbacks/operation/ace) callback. + */ +export interface SvamlActionContinue { + + /** The name property. Must have the value `continue`. */ + name: 'continue'; +} + + diff --git a/packages/voice/src/models/v1/svaml-action-hangup/index.ts b/packages/voice/src/models/v1/svaml-action-hangup/index.ts new file mode 100644 index 00000000..d6e3b2ec --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-hangup/index.ts @@ -0,0 +1 @@ +export type { SvamlActionHangup } from './svaml-action-hangup'; diff --git a/packages/voice/src/models/v1/svaml-action-hangup/svaml-action-hangup.ts b/packages/voice/src/models/v1/svaml-action-hangup/svaml-action-hangup.ts new file mode 100644 index 00000000..3af2ba90 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-hangup/svaml-action-hangup.ts @@ -0,0 +1,18 @@ +/** + * Model: SvamlActionHangup + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * Hangs up a call. Available to use in a response to an [Incoming Call Event](../../../docs/voice/api-reference/voice/tag/Callbacks/#tag/Callbacks/operation/ice) callback or an [Answered Call Event](../../../docs/voice/api-reference/voice/tag/Callbacks/#tag/Callbacks/operation/ace) callback. + */ +export interface SvamlActionHangup { + + /** The name property. Must have the value `hangup`. */ + name: 'hangup'; +} + + diff --git a/packages/voice/src/models/v1/svaml-action-park/index.ts b/packages/voice/src/models/v1/svaml-action-park/index.ts new file mode 100644 index 00000000..cf11773a --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-park/index.ts @@ -0,0 +1 @@ +export type { SvamlActionPark } from './svaml-action-park'; diff --git a/packages/voice/src/models/v1/svaml-action-park/svaml-action-park.ts b/packages/voice/src/models/v1/svaml-action-park/svaml-action-park.ts new file mode 100644 index 00000000..919aefdb --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-park/svaml-action-park.ts @@ -0,0 +1,26 @@ +/** + * Model: SvamlActionPark + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * Parks the call and places the caller on hold. The caller is placed into a loop, listening to an IVR prompt (either a pre-recorded audio file or generated by text to speech). If the call is unparked, prompts will stop playing immediately. If the max duration is reached, the last prompt will be fully played until the call ends. + */ +export interface SvamlActionPark { + + /** The name property. Must have the value `park`. */ + name: 'park'; + /** The voice and language you want to use for the text-to-speech message. This can either be defined by the ISO 639 locale and language code or by specifying a particular voice. Supported languages and voices are detailed [here](../../voice-locales). */ + locale?: string; + /** That prompt that is played when the call is first answered. You can use text-to-speech using the `#tts[]` element, SSML commands using the `#ssml[]` element. */ + introPrompt?: string; + /** The prompt that is played on repeat until the call is unparked or the until the `maxDuration` value is reached. You can use text-to-speech using the `#tts[]` element, SSML commands using the `#ssml[]` element. */ + holdPrompt?: string; + /** The maximum amount of time in seconds that the `holdPrompt` will be played. */ + maxDuration?: number; +} + + diff --git a/packages/voice/src/models/v1/svaml-action-run-menu/index.ts b/packages/voice/src/models/v1/svaml-action-run-menu/index.ts new file mode 100644 index 00000000..c1e95303 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-run-menu/index.ts @@ -0,0 +1 @@ +export type { SvamlActionRunMenu } from './svaml-action-run-menu'; diff --git a/packages/voice/src/models/v1/svaml-action-run-menu/svaml-action-run-menu.ts b/packages/voice/src/models/v1/svaml-action-run-menu/svaml-action-run-menu.ts new file mode 100644 index 00000000..53df0eef --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action-run-menu/svaml-action-run-menu.ts @@ -0,0 +1,29 @@ +/** + * Model: SvamlActionRunMenu + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { Menu } from '../menu'; + +/** + * Plays an interactive voice response (IVR) menu to the callee. This menu can play pre-recorded files or text-to-speech messages, collect DTMF tones, and trigger the [Prompt Input Event](../../voice/tag/Callbacks/#tag/Callbacks/operation/pie) (PIE) callback towards your backend, notifying you of the actions the callee took. Available to use in a response to an [Incoming Call Event](../../voice/tag/Callbacks/#tag/Callbacks/operation/ice) callback or an [Answered Call Event](../../voice/tag/Callbacks/#tag/Callbacks/operation/ace) callback. Also be used in combination with the [Conferences](/docs/voice/api-reference/voice/tag/Conferences/#tag/Conferences) endpoint of the Voice API. + */ +export interface SvamlActionRunMenu { + + /** The name property. Must have the value `runMenu`. */ + name: 'runMenu'; + /** 'Barging' means that the user can press a DTMF digit before the prompt has finished playing. If a valid input is pressed, the message will stop playing and accept the input. If `barge` is disabled, the user must listen to the entire prompt before input is accepted. By default, barging is enabled. */ + barge?: boolean; + /** The voice and language you want to use for the text-to-speech message. This can either be defined by the ISO 639 locale and language code or by specifying a particular voice. Supported languages and voices are detailed [here](../../voice-locales). If using the `enableVoice` to enable voice detection, the `locale` property is required in order to select the input language. */ + locale?: string; + /** Selects the menu item from the `menus` array to play first. */ + mainMenu?: string; + /** Enables voice detection. If enabled, users can say their answers to prompts in addition to entering them using the keypad. */ + enableVoice?: boolean; + /** The list of menus available. The menu with the `id` value of `main` will always play first. If no menu has an `id` value of `main`, an error is returned. */ + menus?: Menu[]; +} + + diff --git a/packages/voice/src/models/v1/svaml-action/index.ts b/packages/voice/src/models/v1/svaml-action/index.ts new file mode 100644 index 00000000..d4b2e1f9 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action/index.ts @@ -0,0 +1 @@ +export type { SvamlAction } from './svaml-action'; diff --git a/packages/voice/src/models/v1/svaml-action/svaml-action.ts b/packages/voice/src/models/v1/svaml-action/svaml-action.ts new file mode 100644 index 00000000..cf7d6058 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-action/svaml-action.ts @@ -0,0 +1,27 @@ +/** + * Model: SvamlAction + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { SvamlActionConnectConf } from '../svaml-action-connect-conf'; +import { SvamlActionConnectMxp } from '../svaml-action-connect-mxp'; +import { SvamlActionConnectPstn } from '../svaml-action-connect-pstn'; +import { SvamlActionConnectSip } from '../svaml-action-connect-sip'; +import { SvamlActionContinue } from '../svaml-action-continue'; +import { SvamlActionHangup } from '../svaml-action-hangup'; +import { SvamlActionPark } from '../svaml-action-park'; +import { SvamlActionRunMenu } from '../svaml-action-run-menu'; + +/** + * The action that will control the call. Each SVAML object can only include one action. + */ +export type SvamlAction = SvamlActionHangup + | SvamlActionContinue + | SvamlActionConnectPstn + | SvamlActionConnectMxp + | SvamlActionConnectConf + | SvamlActionConnectSip + | SvamlActionRunMenu + | SvamlActionPark; diff --git a/packages/voice/src/models/v1/svaml-instruction-answer/index.ts b/packages/voice/src/models/v1/svaml-instruction-answer/index.ts new file mode 100644 index 00000000..ad196fb6 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-instruction-answer/index.ts @@ -0,0 +1 @@ +export type { SvamlInstructionAnswer } from './svaml-instruction-answer'; diff --git a/packages/voice/src/models/v1/svaml-instruction-answer/svaml-instruction-answer.ts b/packages/voice/src/models/v1/svaml-instruction-answer/svaml-instruction-answer.ts new file mode 100644 index 00000000..c711f8ec --- /dev/null +++ b/packages/voice/src/models/v1/svaml-instruction-answer/svaml-instruction-answer.ts @@ -0,0 +1,18 @@ +/** + * Model: SvamlInstructionAnswer + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * Forces the callee to answer the call. + */ +export interface SvamlInstructionAnswer { + + /** The `name` property. Must have the value `answer`. */ + name: 'answer'; +} + + diff --git a/packages/voice/src/models/v1/svaml-instruction-play-files/index.ts b/packages/voice/src/models/v1/svaml-instruction-play-files/index.ts new file mode 100644 index 00000000..ad88d03a --- /dev/null +++ b/packages/voice/src/models/v1/svaml-instruction-play-files/index.ts @@ -0,0 +1 @@ +export type { SvamlInstructionPlayFiles } from './svaml-instruction-play-files'; diff --git a/packages/voice/src/models/v1/svaml-instruction-play-files/svaml-instruction-play-files.ts b/packages/voice/src/models/v1/svaml-instruction-play-files/svaml-instruction-play-files.ts new file mode 100644 index 00000000..98e9db31 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-instruction-play-files/svaml-instruction-play-files.ts @@ -0,0 +1,22 @@ +/** + * Model: SvamlInstructionPlayFiles + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * Plays Interactive Voice Response (IVR) files for the supported locale or SSML commands at the Sinch backend. An IVR message is played only on the caller\'s side. + */ +export interface SvamlInstructionPlayFiles { + + /** The `name` property. Must have the value `playFiles`. */ + name: 'playFiles'; + /** The IDs of the files which will be played. These can be a URL to a file, SSML commands using the `#ssml[]` element, or text using the `#tts[]` element. */ + ids: string[]; + /** If using SSML or TTS, this is a required field. The voice and language you want to use for the text-to-speech message. This can either be defined by the ISO 639 locale and language code or by specifying a particular voice. Supported languages and voices are detailed [here](../../voice-locales). */ + locale: string; +} + + diff --git a/packages/voice/src/models/v1/svaml-instruction-say/index.ts b/packages/voice/src/models/v1/svaml-instruction-say/index.ts new file mode 100644 index 00000000..444b50be --- /dev/null +++ b/packages/voice/src/models/v1/svaml-instruction-say/index.ts @@ -0,0 +1 @@ +export type { SvamlInstructionSay } from './svaml-instruction-say'; diff --git a/packages/voice/src/models/v1/svaml-instruction-say/svaml-instruction-say.ts b/packages/voice/src/models/v1/svaml-instruction-say/svaml-instruction-say.ts new file mode 100644 index 00000000..fdd9db85 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-instruction-say/svaml-instruction-say.ts @@ -0,0 +1,22 @@ +/** + * Model: SvamlInstructionSay + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * Plays a synthesized text-to-speech message to the end user. The message is provided in the text field. + */ +export interface SvamlInstructionSay { + + /** The `name` property. Must have the value `say`. */ + name: 'say'; + /** Contains the message that will be spoken. Default maximum length is 600 characters. To change this limit, please contact support. */ + text?: string; + /** The voice and language you want to use for the text-to-speech message. This can either be defined by the ISO 639 locale and language code or by specifying a particular voice. Supported languages and voices are detailed [here](../../voice-locales). */ + locale?: string; +} + + diff --git a/packages/voice/src/models/v1/svaml-instruction-send-dtmf/index.ts b/packages/voice/src/models/v1/svaml-instruction-send-dtmf/index.ts new file mode 100644 index 00000000..f621f54e --- /dev/null +++ b/packages/voice/src/models/v1/svaml-instruction-send-dtmf/index.ts @@ -0,0 +1 @@ +export type { SvamlInstructionSendDtmf } from './svaml-instruction-send-dtmf'; diff --git a/packages/voice/src/models/v1/svaml-instruction-send-dtmf/svaml-instruction-send-dtmf.ts b/packages/voice/src/models/v1/svaml-instruction-send-dtmf/svaml-instruction-send-dtmf.ts new file mode 100644 index 00000000..a40eb378 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-instruction-send-dtmf/svaml-instruction-send-dtmf.ts @@ -0,0 +1,20 @@ +/** + * Model: SvamlInstructionSendDtmf + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * Plays DTMF tones in the call. + */ +export interface SvamlInstructionSendDtmf { + + /** The `name` property. Must have the value `sendDtmf`. */ + name: 'sendDtmf'; + /** A string that determines the DTMF tones to play to the callee when the call is picked up. Valid characters are: `0-9`, `#`, and `w`. `w` renders a 500ms pause. For example, the string `ww1234#w#`, plays a 1 second pause, the DTMF tones for `1`, `2`, `3`, `4`, and `#`, followed by a 500ms pause and finally the `#` tone. This is useful if the callout destination requires a conference PIN code or an extension. If there is a calling party, it will hear progress while the DTMF is sent. */ + value?: string; +} + + diff --git a/packages/voice/src/models/v1/svaml-instruction-set-cookie/index.ts b/packages/voice/src/models/v1/svaml-instruction-set-cookie/index.ts new file mode 100644 index 00000000..70d1510a --- /dev/null +++ b/packages/voice/src/models/v1/svaml-instruction-set-cookie/index.ts @@ -0,0 +1 @@ +export type { SvamlInstructionSetCookie } from './svaml-instruction-set-cookie'; diff --git a/packages/voice/src/models/v1/svaml-instruction-set-cookie/svaml-instruction-set-cookie.ts b/packages/voice/src/models/v1/svaml-instruction-set-cookie/svaml-instruction-set-cookie.ts new file mode 100644 index 00000000..2624f5cc --- /dev/null +++ b/packages/voice/src/models/v1/svaml-instruction-set-cookie/svaml-instruction-set-cookie.ts @@ -0,0 +1,22 @@ +/** + * Model: SvamlInstructionSetCookie + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * Creates a cookie for the duration of the call. + */ +export interface SvamlInstructionSetCookie { + + /** The `name` property. Must have the value `setCookie`. */ + name: 'setCookie'; + /** The name of the cookie you want to set. */ + key?: string; + /** The value of the cookie you want to set. */ + value?: string; +} + + diff --git a/packages/voice/src/models/v1/svaml-instruction-start-recording/index.ts b/packages/voice/src/models/v1/svaml-instruction-start-recording/index.ts new file mode 100644 index 00000000..11fc634c --- /dev/null +++ b/packages/voice/src/models/v1/svaml-instruction-start-recording/index.ts @@ -0,0 +1 @@ +export type { SvamlInstructionStartRecording } from './svaml-instruction-start-recording'; diff --git a/packages/voice/src/models/v1/svaml-instruction-start-recording/svaml-instruction-start-recording.ts b/packages/voice/src/models/v1/svaml-instruction-start-recording/svaml-instruction-start-recording.ts new file mode 100644 index 00000000..08ced3d1 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-instruction-start-recording/svaml-instruction-start-recording.ts @@ -0,0 +1,20 @@ +/** + * Model: SvamlInstructionStartRecording + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * Starts a recording of the call. + */ +export interface SvamlInstructionStartRecording { + + /** The `name` property. Must have the value `startRecording`. */ + name: 'startRecording'; + /** An object that specifies details about the recording. For more details, see [Recording Options](../../recording/#recording-options). */ + options?: object; +} + + diff --git a/packages/voice/src/models/v1/svaml-instruction-stop-recording/index.ts b/packages/voice/src/models/v1/svaml-instruction-stop-recording/index.ts new file mode 100644 index 00000000..f47f7202 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-instruction-stop-recording/index.ts @@ -0,0 +1 @@ +export type { SvamlInstructionStopRecording } from './svaml-instruction-stop-recording'; diff --git a/packages/voice/src/models/v1/svaml-instruction-stop-recording/svaml-instruction-stop-recording.ts b/packages/voice/src/models/v1/svaml-instruction-stop-recording/svaml-instruction-stop-recording.ts new file mode 100644 index 00000000..f72424f9 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-instruction-stop-recording/svaml-instruction-stop-recording.ts @@ -0,0 +1,18 @@ +/** + * Model: SvamlInstructionStopRecording + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * Stops the recording of the call. + */ +export interface SvamlInstructionStopRecording { + + /** The `name` property. Must have the value `stopRecording`. */ + name: 'stopRecording'; +} + + diff --git a/packages/voice/src/models/v1/svaml-instruction/index.ts b/packages/voice/src/models/v1/svaml-instruction/index.ts new file mode 100644 index 00000000..3cfb941c --- /dev/null +++ b/packages/voice/src/models/v1/svaml-instruction/index.ts @@ -0,0 +1 @@ +export type { SvamlInstruction } from './svaml-instruction'; diff --git a/packages/voice/src/models/v1/svaml-instruction/svaml-instruction.ts b/packages/voice/src/models/v1/svaml-instruction/svaml-instruction.ts new file mode 100644 index 00000000..92dd647b --- /dev/null +++ b/packages/voice/src/models/v1/svaml-instruction/svaml-instruction.ts @@ -0,0 +1,25 @@ +/** + * Model: SvamlInstruction + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { SvamlInstructionAnswer } from '../svaml-instruction-answer'; +import { SvamlInstructionPlayFiles } from '../svaml-instruction-play-files'; +import { SvamlInstructionSay } from '../svaml-instruction-say'; +import { SvamlInstructionSendDtmf } from '../svaml-instruction-send-dtmf'; +import { SvamlInstructionSetCookie } from '../svaml-instruction-set-cookie'; +import { SvamlInstructionStartRecording } from '../svaml-instruction-start-recording'; +import { SvamlInstructionStopRecording } from '../svaml-instruction-stop-recording'; + +/** + * Instructions allow an application to play a message or file, start recording, and various other tasks. For more information about instructions, see the [SVAML](../../svaml/) documentation. + */ +export type SvamlInstruction = SvamlInstructionPlayFiles + | SvamlInstructionSay + | SvamlInstructionSendDtmf + | SvamlInstructionSetCookie + | SvamlInstructionAnswer + | SvamlInstructionStartRecording + | SvamlInstructionStopRecording; diff --git a/packages/voice/src/models/v1/svaml-request-body/index.ts b/packages/voice/src/models/v1/svaml-request-body/index.ts new file mode 100644 index 00000000..ffec7343 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-request-body/index.ts @@ -0,0 +1 @@ +export type { SVAMLRequestBody } from './svaml-request-body'; diff --git a/packages/voice/src/models/v1/svaml-request-body/svaml-request-body.ts b/packages/voice/src/models/v1/svaml-request-body/svaml-request-body.ts new file mode 100644 index 00000000..3c949b45 --- /dev/null +++ b/packages/voice/src/models/v1/svaml-request-body/svaml-request-body.ts @@ -0,0 +1,22 @@ +/** + * Model: SVAMLRequestBody + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { SvamlAction } from '../svaml-action'; +import { SvamlInstruction } from '../svaml-instruction'; + +/** + * SVAML is a call control markup language. When a server receives a callback event from the Sinch platform, it can respond with a SVAML object to control the voice call. The following is an example of a SVAML object type and its contents. + */ +export interface SVAMLRequestBody { + + /** The collection of instructions that can perform various tasks during the call. You can include as many instructions as necessary. */ + instructions?: SvamlInstruction[]; + /** @see SvamlAction */ + action?: SvamlAction; +} + + diff --git a/packages/voice/src/models/v1/tts-callout-request/index.ts b/packages/voice/src/models/v1/tts-callout-request/index.ts new file mode 100644 index 00000000..ef924357 --- /dev/null +++ b/packages/voice/src/models/v1/tts-callout-request/index.ts @@ -0,0 +1 @@ +export type { TtsCalloutRequest } from './tts-callout-request'; diff --git a/packages/voice/src/models/v1/tts-callout-request/tts-callout-request.ts b/packages/voice/src/models/v1/tts-callout-request/tts-callout-request.ts new file mode 100644 index 00000000..c84510f5 --- /dev/null +++ b/packages/voice/src/models/v1/tts-callout-request/tts-callout-request.ts @@ -0,0 +1,40 @@ +/** + * Model: TtsCalloutRequest + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { Destination } from '../destination'; + +/** + * The text-to-speech callout calls a phone number and plays a synthesized text messages or pre-recorded sound files. + */ +export interface TtsCalloutRequest { + + /** The number that will be displayed as the incoming caller. To set your own CLI, you may use your verified number or your Dashboard number. The number must be in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format. */ + cli?: string; + /** @see Destination */ + destination: Destination; + /** When the destination picks up, this DTMF tones will be played to the callee. Valid characters in the string are \"0\"-\"9\", \"#\", and \"w\". A \"w\" will render a 500 ms pause. For example, \"ww1234#w#\" will render a 1s pause, the DTMF tones \"1\", \"2\", \"3\", \"4\" and \"#\" followed by a 0.5s pause and finally the DTMF tone for \"#\". This can be used if the callout destination for instance require a conference PIN code or an extension to be entered. */ + dtmf?: string; + /** Can be either `pstn` for PSTN endpoint or `mxp` for data (app or web) clients. */ + domain?: DomainEnum; + /** Can be used to input custom data. */ + custom?: string; + /** The voice and language you want to use for the text-to-speech message. This can either be defined by the ISO 639 locale and language code or by specifying a particular voice. Supported languages and voices are detailed [here](../../../voice-locales/). */ + locale?: string; + /** The text that will be spoken in the text-to-speech message. _Every application\'s default maximum characters allowed in text-to-speech is 600 characters. Contact support if you wish this limit to be changed._ */ + text?: string; + /** An advanced alternative to using ```text```. __TTS__ _Text To Speech:_ The equivalent of text but within the prompt property. Example: _```#tts[Hello from Sinch]```_ __TTS with SSML__ _Text To Speech with Speech Synthesis Markup Language (SSML)._ This is an XML-based markup language for assisting the generation of synthetic speech in the Web and other applications. AWS Polly supports a sub-set of SSML. This allows us to use SSML-enhanced text for additional control over how Polly generates speech from the text. Details and examples of supported tags are [here](https://docs.aws.amazon.com/polly/latest/dg/supportedtags.html) __Externally hosted media:__ Provide a URL to your own hosted media. Please check [here](../../../supported-audio-formats/#limits) to read about audio content type and usage limits. _Every application\'s default maximum allowed in TTS or TTS SSML is 600 characters. Contact support if you wish this limit to be changed._ _Several prompts can be used, separated by a semi-colon_ ```;``` Example: _```#tts[Hello from Sinch];#ssml[Have a great day!]```_ */ + prompts?: string; + /** If `enableAce` is set to `true` and the application has a callback URL specified, you will receive an ACE callback when the call is answered. When the callback is received, your platform must respond with a svamlet, containing the “connectconf” action in order to add the call to a conference or create the conference if it\'s the first call. If it\'s set to `false`, no ACE event will be sent to your backend. */ + enableAce?: boolean; + /** If `enableDice` is set to `true` and the application has a callback URL specified, you will receive a DiCE callback when the call is disconnected. If it\'s set to `false`, no DiCE event will be sent to your backend. */ + enableDice?: boolean; + /** Note: PIE callbacks are not available for DATA Calls; only PSTN and SIP calls. If `enablePie` is set to `true` and the application has a callback URL specified, you will receive a PIE callback after the `runMenu` action executes and after the configured menu timeout has elapsed with no input. If it\'s set to `false`, no PIE events will be sent to your backend. */ + enablePie?: boolean; +} + +export type DomainEnum = 'pstn' | 'mxp'; + diff --git a/packages/voice/src/models/v1/unassign-numbers/index.ts b/packages/voice/src/models/v1/unassign-numbers/index.ts new file mode 100644 index 00000000..682e5c47 --- /dev/null +++ b/packages/voice/src/models/v1/unassign-numbers/index.ts @@ -0,0 +1 @@ +export type { UnassignNumbers } from './unassign-numbers'; diff --git a/packages/voice/src/models/v1/unassign-numbers/unassign-numbers.ts b/packages/voice/src/models/v1/unassign-numbers/unassign-numbers.ts new file mode 100644 index 00000000..39183562 --- /dev/null +++ b/packages/voice/src/models/v1/unassign-numbers/unassign-numbers.ts @@ -0,0 +1,20 @@ +/** + * Model: UnassignNumbers + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +export interface UnassignNumbers { + + /** The phone number in E.164 format (https://en.wikipedia.org/wiki/E.164) */ + number?: string; + /** Indicates the application where the number(s) was assigned. If empty, the application key that is used to sign the request will be used. */ + applicationkey?: string; + /** (optional) indicates the DID capability that was assigned to the chosen application. Please note that the DID needs to support the selected capability. */ + capability?: CapabilityEnum; +} + +export type CapabilityEnum = 'voice' | 'sms'; + diff --git a/packages/voice/src/models/v1/update-callbacks-url/index.ts b/packages/voice/src/models/v1/update-callbacks-url/index.ts new file mode 100644 index 00000000..22c3705c --- /dev/null +++ b/packages/voice/src/models/v1/update-callbacks-url/index.ts @@ -0,0 +1 @@ +export type { UpdateCallbacksUrl } from './update-callbacks-url'; diff --git a/packages/voice/src/models/v1/update-callbacks-url/update-callbacks-url.ts b/packages/voice/src/models/v1/update-callbacks-url/update-callbacks-url.ts new file mode 100644 index 00000000..919e8424 --- /dev/null +++ b/packages/voice/src/models/v1/update-callbacks-url/update-callbacks-url.ts @@ -0,0 +1,20 @@ +/** + * Model: UpdateCallbacksUrl + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +/** + * Contains primary and or fallback callback URLs + */ +export interface UpdateCallbacksUrl { + + /** Your primary callback URL */ + primary?: string; + /** Your fallback callback URL */ + fallback?: string; +} + + diff --git a/packages/voice/src/models/v1/update-callbacks/index.ts b/packages/voice/src/models/v1/update-callbacks/index.ts new file mode 100644 index 00000000..f5a75100 --- /dev/null +++ b/packages/voice/src/models/v1/update-callbacks/index.ts @@ -0,0 +1 @@ +export type { UpdateCallbacks } from './update-callbacks'; diff --git a/packages/voice/src/models/v1/update-callbacks/update-callbacks.ts b/packages/voice/src/models/v1/update-callbacks/update-callbacks.ts new file mode 100644 index 00000000..00793922 --- /dev/null +++ b/packages/voice/src/models/v1/update-callbacks/update-callbacks.ts @@ -0,0 +1,16 @@ +/** + * Model: UpdateCallbacks + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + +import { UpdateCallbacksUrl } from '../update-callbacks-url'; + +export interface UpdateCallbacks { + + /** @see UpdateCallbacksUrl */ + url?: UpdateCallbacksUrl; +} + + diff --git a/packages/voice/src/models/v1/update-numbers/index.ts b/packages/voice/src/models/v1/update-numbers/index.ts new file mode 100644 index 00000000..4152bee7 --- /dev/null +++ b/packages/voice/src/models/v1/update-numbers/index.ts @@ -0,0 +1 @@ +export type { UpdateNumbers } from './update-numbers'; diff --git a/packages/voice/src/models/v1/update-numbers/update-numbers.ts b/packages/voice/src/models/v1/update-numbers/update-numbers.ts new file mode 100644 index 00000000..5ff8eec8 --- /dev/null +++ b/packages/voice/src/models/v1/update-numbers/update-numbers.ts @@ -0,0 +1,20 @@ +/** + * Model: UpdateNumbers + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ + + +export interface UpdateNumbers { + + /** The phone number or list of numbers in E.164 format. */ + numbers?: string[]; + /** indicates the application where the number(s) will be assigned. If empty, the application key that is used to sign the request will be used. */ + applicationkey?: string; + /** indicates the DID capability that needs to be assigned to the chosen application. Valid values are \'voice\' and \'sms\'. Please note that the DID needs to support the selected capability. */ + capability?: CapabilityEnum; +} + +export type CapabilityEnum = 'voice' | 'sms'; + diff --git a/packages/voice/src/models/v1/voice-error/index.ts b/packages/voice/src/models/v1/voice-error/index.ts new file mode 100644 index 00000000..2d3c08c3 --- /dev/null +++ b/packages/voice/src/models/v1/voice-error/index.ts @@ -0,0 +1 @@ +export type { VoiceError } from './voice-error'; diff --git a/packages/verification/src/models/v1/error/error.ts b/packages/voice/src/models/v1/voice-error/voice-error.ts similarity index 87% rename from packages/verification/src/models/v1/error/error.ts rename to packages/voice/src/models/v1/voice-error/voice-error.ts index 8af30832..9b00b8d0 100644 --- a/packages/verification/src/models/v1/error/error.ts +++ b/packages/voice/src/models/v1/voice-error/voice-error.ts @@ -1,12 +1,12 @@ /** - * Model: Error + * Model: VerificationError * * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. * */ -export interface Error { +export interface VoiceError { /** A summary of the HTTP error code and error type. */ status?: string; diff --git a/packages/voice/tsconfig.build.json b/packages/voice/tsconfig.build.json new file mode 100644 index 00000000..73f1cf60 --- /dev/null +++ b/packages/voice/tsconfig.build.json @@ -0,0 +1,17 @@ +{ + "extends": "../../tsconfig.json", + + "compilerOptions": { + "rootDir": "src", + "outDir": "dist" + }, + + "include": ["src/**/*.ts"], + "exclude": ["node_modules", "dist"], + + "references": [{ "path": "../sdk-client" }], + + "ts-node": { + "esm": true + } +} diff --git a/packages/voice/tsconfig.json b/packages/voice/tsconfig.json new file mode 100644 index 00000000..2684d3e0 --- /dev/null +++ b/packages/voice/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.json", + "references": [ + { + "path": "tsconfig.build.json" + }, + { + "path": "tsconfig.tests.json" + } + ] +} diff --git a/packages/voice/tsconfig.tests.json b/packages/voice/tsconfig.tests.json new file mode 100644 index 00000000..2e454981 --- /dev/null +++ b/packages/voice/tsconfig.tests.json @@ -0,0 +1,17 @@ +{ + "extends": "../../tsconfig.json", + + "compilerOptions": { + "rootDir": ".", + "outDir": "dist/tests" + }, + + "include": ["src/**/*.ts", "tests/**/*.ts"], + "exclude": ["node_modules", "dist"], + + "references": [{ "path": "../sdk-client" }], + + "ts-node": { + "esm": true + } +} From 35d1136e5c789aea7a4bfa8d2b5262cee796fde2 Mon Sep 17 00:00:00 2001 From: Antoine Sein Date: Wed, 27 Dec 2023 14:18:44 +0100 Subject: [PATCH 2/4] Fix formatting in comments --- .../conference-callout-request.ts | 14 +++++++------- .../custom-callout-request.ts | 8 ++++---- .../get-numbers-response-obj-numbers-inner.ts | 2 +- .../manage-conference-participant-request.ts | 2 +- .../pie-request-menu-result.ts | 2 +- .../svaml-action-connect-conf.ts | 2 +- .../svaml-action-connect-sip.ts | 2 +- .../svaml-instruction-play-files.ts | 2 +- .../v1/tts-callout-request/tts-callout-request.ts | 12 ++++++------ .../src/models/v1/update-numbers/update-numbers.ts | 2 +- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/voice/src/models/v1/conference-callout-request/conference-callout-request.ts b/packages/voice/src/models/v1/conference-callout-request/conference-callout-request.ts index 4faf30b1..e838a4b6 100644 --- a/packages/voice/src/models/v1/conference-callout-request/conference-callout-request.ts +++ b/packages/voice/src/models/v1/conference-callout-request/conference-callout-request.ts @@ -9,7 +9,7 @@ import { ConferenceCalloutRequestConferenceDtmfOptions } from '../conference-cal import { Destination } from '../destination'; /** - * The conference callout calls a phone number or a user. When the call is answered, it\'s connected to a conference room. + * The conference callout calls a phone number or a user. When the call is answered, it's connected to a conference room. */ export interface ConferenceCalloutRequest { @@ -17,24 +17,24 @@ export interface ConferenceCalloutRequest { cli?: string; /** @see Destination */ destination: Destination; - /** The conferenceId of the conference to which you want the callee to join. If the conferenceId doesn\'t exist a conference room will be created. */ + /** The conferenceId of the conference to which you want the callee to join. If the conferenceId doesn't exist a conference room will be created. */ conferenceId: string; /** @see ConferenceCalloutRequestConferenceDtmfOptions */ conferenceDtmfOptions?: ConferenceCalloutRequestConferenceDtmfOptions; - /** When the destination picks up, this DTMF tones will be played to the callee. Valid characters in the string are \"0\"-\"9\", \"#\" and \"w\". A \"w\" will render a 500 ms pause. Example: \"ww1234#w#\" will render a 1s pause, the DTMF tones \"1\", \"2\", \"3\", \"4\" and \"#\" followed by a 0.5s pause and finally the DTMF tone for \"#\". This can be used if the callout destination for instance require a conference PIN code or an extension to be entered. */ + /** When the destination picks up, this DTMF tones will be played to the callee. Valid characters in the string are "0"-"9", "#" and "w". A "w" will render a 500 ms pause. Example: "ww1234#w#" will render a 1s pause, the DTMF tones "1", "2", "3", "4" and "#" followed by a 0.5s pause and finally the DTMF tone for "#". This can be used if the callout destination for instance require a conference PIN code or an extension to be entered. */ dtmf?: string; maxDuration?: number; - /** If `enableAce` is set to true and the application has a callback URL specified, you will receive an ACE callback when the call is answered. When the callback is received, your platform must respond with a svamlet containing the `connectConf` action in order to add the call to a conference or create the conference if it\'s the first call. If it\'s set to false, no ACE event will be sent to your backend.
Note if the call is towards an InApp destination `type:` `username`, then no ACE will be issued when the call is connected, even if `enableAce` is present in the callout request. */ + /** If `enableAce` is set to true and the application has a callback URL specified, you will receive an ACE callback when the call is answered. When the callback is received, your platform must respond with a svamlet containing the `connectConf` action in order to add the call to a conference or create the conference if it's the first call. If it's set to false, no ACE event will be sent to your backend.
Note if the call is towards an InApp destination `type:` `username`, then no ACE will be issued when the call is connected, even if `enableAce` is present in the callout request. */ enableAce?: boolean; - /** If `enableDice` is set to true and the application has a callback URL specified, you will receive a DiCE callback when the call is disconnected. If it\'s set to false, no DiCE event will be sent to your backend.
Note if the call is towards an InApp destination `type:` `username`, then no DICE will be issued at the end of the call, even if `enableDice` is present in the callout request. */ + /** If `enableDice` is set to true and the application has a callback URL specified, you will receive a DiCE callback when the call is disconnected. If it's set to false, no DiCE event will be sent to your backend.
Note if the call is towards an InApp destination `type:` `username`, then no DICE will be issued at the end of the call, even if `enableDice` is present in the callout request. */ enableDice?: boolean; - /** If `enablePie` is set to true and the application has a callback URL specified, you will receive a PIE callback after a `runMenu` action, with the information of the action that the user took. If it\'s set to false, no PIE event will be sent to your backend. */ + /** If `enablePie` is set to true and the application has a callback URL specified, you will receive a PIE callback after a `runMenu` action, with the information of the action that the user took. If it's set to false, no PIE event will be sent to your backend. */ enablePie?: boolean; /** The voice and language you want to use for the prompts. This can either be defined by the ISO 639 locale and language code or by specifying a particular voice. Supported languages and voices are detailed [here](../../../voice-locales/) */ locale?: string; /** The text that will be spoken as a greeting. */ greeting?: string; - /** Means \"music-on-hold.\" It\'s an optional parameter that specifies what the first participant should listen to while they\'re alone in the conference, waiting for other participants to join. It can take one of these pre-defined values:
  • `ring` (progress tone)
  • `music1` (music file)
  • `music2` (music file)
  • `music3` (music file)

If no “music-on-hold” is specified, the user will only hear silence. */ + /** Means "music-on-hold." It's an optional parameter that specifies what the first participant should listen to while they're alone in the conference, waiting for other participants to join. It can take one of these pre-defined values:
  • `ring` (progress tone)
  • `music1` (music file)
  • `music2` (music file)
  • `music3` (music file)

If no “music-on-hold” is specified, the user will only hear silence. */ mohClass?: string; /** Used to input custom data. */ custom?: string; diff --git a/packages/voice/src/models/v1/custom-callout-request/custom-callout-request.ts b/packages/voice/src/models/v1/custom-callout-request/custom-callout-request.ts index b182a096..db85252f 100644 --- a/packages/voice/src/models/v1/custom-callout-request/custom-callout-request.ts +++ b/packages/voice/src/models/v1/custom-callout-request/custom-callout-request.ts @@ -16,17 +16,17 @@ export interface CustomCalloutRequest { cli?: string; /** @see Destination */ destination?: Destination; - /** When the destination picks up, this DTMF tones will be played to the callee. Valid characters in the string are \"0\"-\"9\", \"#\", and \"w\". A \"w\" will render a 500 ms pause. For example, \"ww1234#w#\" will render a 1s pause, the DTMF tones \"1\", \"2\", \"3\", \"4\" and \"#\" followed by a 0.5s pause and finally the DTMF tone for \"#\". This can be used if the callout destination for instance require a conference PIN code or an extension to be entered. */ + /** When the destination picks up, this DTMF tones will be played to the callee. Valid characters in the string are "0"-"9", "#", and "w". A "w" will render a 500 ms pause. For example, "ww1234#w#" will render a 1s pause, the DTMF tones "1", "2", "3", "4" and "#" followed by a 0.5s pause and finally the DTMF tone for "#". This can be used if the callout destination for instance require a conference PIN code or an extension to be entered. */ dtmf?: string; /** Can be used to input custom data. */ custom?: string; /** The maximum amount of time in seconds that the call will last. */ maxDuration?: number; - /** You can use inline SVAML to replace a callback URL when using custom callouts. Ensure that the JSON object is escaped correctly. If inline ICE SVAML is passed, exclude *cli* and *destination* properties from the *customCallout* request body. Example: ```\"{\\\"action\\\":{\\\"name\\\":\\\"connectPstn\\\",\\\"number\\\":\\\"46000000001\\\",\\\"maxDuration\\\":90}}\"``` */ + /** You can use inline SVAML to replace a callback URL when using custom callouts. Ensure that the JSON object is escaped correctly. If inline ICE SVAML is passed, exclude *cli* and *destination* properties from the *customCallout* request body. Example: ```"{"action":{"name":"connectPstn","number":"46000000001","maxDuration":90}}"``` */ ice?: string; - /** You can use inline SVAML to replace a callback URL when using custom callouts. Ensure that the JSON object is escaped correctly. Example: ```\"{\\\"action\\\": {\\\"name\\\": \\\"RunMenu\\\",\\\"locale\\\": \\\"en-US\\\",\\\"menus\\\": [{\\\"id\\\": \\\"main\\\",\\\"mainPrompt\\\": \\\"#tts[ Welcome to the main menu. Press 1 for a callback or 2 for a cancel]\\\",\\\"timeoutMills\\\": 5000,\\\"options\\\": [ {\\\"dtmf\\\": \\\"1\\\",\\\"action\\\": \\\"return(callback)\\\"}, {\\\"dtmf\\\": \\\"2\\\",\\\"action\\\": \\\"return(cancel)\\\"}]}]}}\"``` */ + /** You can use inline SVAML to replace a callback URL when using custom callouts. Ensure that the JSON object is escaped correctly. Example: ```"{"action": {"name": "RunMenu","locale": "en-US","menus": [{"id": "main","mainPrompt": "#tts[ Welcome to the main menu. Press 1 for a callback or 2 for a cancel]","timeoutMills": 5000,"options": [ {"dtmf": "1","action": "return(callback)"}, {"dtmf": "2","action": "return(cancel)"}]}]}}"``` */ ace?: string; - /** Note: PIE callbacks are not available for DATA Calls; only PSTN and SIP calls. You can use inline SVAML to replace a callback URL when using custom callouts. Ensure that the JSON object is escaped correctly. A PIE event will contain a value chosen from an IVR choice. Usually a PIE event wil contain a URL to a callback sever that will receive the choice and be able to parse it. This could result in further SVAML or some other application logic function. Example: ```\"https://your-application-server-host/application\"``` */ + /** Note: PIE callbacks are not available for DATA Calls; only PSTN and SIP calls. You can use inline SVAML to replace a callback URL when using custom callouts. Ensure that the JSON object is escaped correctly. A PIE event will contain a value chosen from an IVR choice. Usually a PIE event wil contain a URL to a callback sever that will receive the choice and be able to parse it. This could result in further SVAML or some other application logic function. Example: ```"https://your-application-server-host/application"``` */ pie?: string; } diff --git a/packages/voice/src/models/v1/get-numbers-response-obj-numbers-inner/get-numbers-response-obj-numbers-inner.ts b/packages/voice/src/models/v1/get-numbers-response-obj-numbers-inner/get-numbers-response-obj-numbers-inner.ts index 5ab29448..07a3f2d3 100644 --- a/packages/voice/src/models/v1/get-numbers-response-obj-numbers-inner/get-numbers-response-obj-numbers-inner.ts +++ b/packages/voice/src/models/v1/get-numbers-response-obj-numbers-inner/get-numbers-response-obj-numbers-inner.ts @@ -12,7 +12,7 @@ export interface GetNumbersResponseObjNumbersInner { number?: string; /** Indicates the application where the number(s) will be assigned. If no number is assigned the applicationkey will not be returned. */ applicationkey?: string; - /** indicates the DID capability that needs to be assigned to the chosen application. Valid values are \'voice\' and \'sms\'. Please note that the DID needs to support the selected capability. */ + /** indicates the DID capability that needs to be assigned to the chosen application. Valid values are 'voice' and 'sms'. Please note that the DID needs to support the selected capability. */ capability?: CapabilityEnum; } diff --git a/packages/voice/src/models/v1/manage-conference-participant-request/manage-conference-participant-request.ts b/packages/voice/src/models/v1/manage-conference-participant-request/manage-conference-participant-request.ts index e5e62996..21863be7 100644 --- a/packages/voice/src/models/v1/manage-conference-participant-request/manage-conference-participant-request.ts +++ b/packages/voice/src/models/v1/manage-conference-participant-request/manage-conference-participant-request.ts @@ -13,7 +13,7 @@ export interface ManageConferenceParticipantRequest { /** Action to apply on conference participant. */ command: CommandEnum; - /** Means \"music on hold\". If this optional parameter is included, plays music to the first participant in a conference while they\'re alone and waiting for other participants to join. If `moh` isn\'t specified, the user will only hear silence while alone in the conference. This property is only available to use with the `onhold` command. */ + /** Means "music on hold". If this optional parameter is included, plays music to the first participant in a conference while they're alone and waiting for other participants to join. If `moh` isn't specified, the user will only hear silence while alone in the conference. This property is only available to use with the `onhold` command. */ moh?: MohEnum; } diff --git a/packages/voice/src/models/v1/pie-request-menu-result/pie-request-menu-result.ts b/packages/voice/src/models/v1/pie-request-menu-result/pie-request-menu-result.ts index d1b80fdf..403897d9 100644 --- a/packages/voice/src/models/v1/pie-request-menu-result/pie-request-menu-result.ts +++ b/packages/voice/src/models/v1/pie-request-menu-result/pie-request-menu-result.ts @@ -13,7 +13,7 @@ export interface PieRequestMenuResult { /** The ID of the menu that triggered the prompt input event. */ menuId?: string; - /** The type of information that\'s returned. */ + /** The type of information that's returned. */ type?: string; /** The value of the returned information. */ value?: string; diff --git a/packages/voice/src/models/v1/svaml-action-connect-conf/svaml-action-connect-conf.ts b/packages/voice/src/models/v1/svaml-action-connect-conf/svaml-action-connect-conf.ts index 902b3218..b287fcd3 100644 --- a/packages/voice/src/models/v1/svaml-action-connect-conf/svaml-action-connect-conf.ts +++ b/packages/voice/src/models/v1/svaml-action-connect-conf/svaml-action-connect-conf.ts @@ -18,7 +18,7 @@ export interface SvamlActionConnectConf { conferenceId: string; /** @see SvamlActionConnectConfConferenceDtmfOptions */ conferenceDtmfOptions?: SvamlActionConnectConfConferenceDtmfOptions; - /** Means "music on hold". If this optional parameter is included, plays music to the first participant in a conference while they\'re alone and waiting for other participants to join. If `moh` isn't specified, the user will only hear silence while alone in the conference. */ + /** Means "music on hold". If this optional parameter is included, plays music to the first participant in a conference while they're alone and waiting for other participants to join. If `moh` isn't specified, the user will only hear silence while alone in the conference. */ moh?: string; } diff --git a/packages/voice/src/models/v1/svaml-action-connect-sip/svaml-action-connect-sip.ts b/packages/voice/src/models/v1/svaml-action-connect-sip/svaml-action-connect-sip.ts index 55a39938..0b6baf8d 100644 --- a/packages/voice/src/models/v1/svaml-action-connect-sip/svaml-action-connect-sip.ts +++ b/packages/voice/src/models/v1/svaml-action-connect-sip/svaml-action-connect-sip.ts @@ -27,7 +27,7 @@ export interface SvamlActionConnectSip { suppressCallbacks?: boolean; /** [Private SIP headers](../../sip-trunking/#receiving-calls-from-sinch-platform-to-your-sip-infrastructure) to send with the call. */ callHeaders?: CallHeader[]; - /** Means \"music on hold\". If this optional parameter is included, plays music to the connected participant if the SIP call is placed on hold. If `moh` isn\'t specified and the SIP call is placed on hold, the user will only hear silence while during the holding period . */ + /** Means \"music on hold\". If this optional parameter is included, plays music to the connected participant if the SIP call is placed on hold. If `moh` isn't specified and the SIP call is placed on hold, the user will only hear silence while during the holding period . */ moh?: string; } diff --git a/packages/voice/src/models/v1/svaml-instruction-play-files/svaml-instruction-play-files.ts b/packages/voice/src/models/v1/svaml-instruction-play-files/svaml-instruction-play-files.ts index 98e9db31..fca14de5 100644 --- a/packages/voice/src/models/v1/svaml-instruction-play-files/svaml-instruction-play-files.ts +++ b/packages/voice/src/models/v1/svaml-instruction-play-files/svaml-instruction-play-files.ts @@ -7,7 +7,7 @@ /** - * Plays Interactive Voice Response (IVR) files for the supported locale or SSML commands at the Sinch backend. An IVR message is played only on the caller\'s side. + * Plays Interactive Voice Response (IVR) files for the supported locale or SSML commands at the Sinch backend. An IVR message is played only on the caller's side. */ export interface SvamlInstructionPlayFiles { diff --git a/packages/voice/src/models/v1/tts-callout-request/tts-callout-request.ts b/packages/voice/src/models/v1/tts-callout-request/tts-callout-request.ts index c84510f5..fa2b3f16 100644 --- a/packages/voice/src/models/v1/tts-callout-request/tts-callout-request.ts +++ b/packages/voice/src/models/v1/tts-callout-request/tts-callout-request.ts @@ -16,7 +16,7 @@ export interface TtsCalloutRequest { cli?: string; /** @see Destination */ destination: Destination; - /** When the destination picks up, this DTMF tones will be played to the callee. Valid characters in the string are \"0\"-\"9\", \"#\", and \"w\". A \"w\" will render a 500 ms pause. For example, \"ww1234#w#\" will render a 1s pause, the DTMF tones \"1\", \"2\", \"3\", \"4\" and \"#\" followed by a 0.5s pause and finally the DTMF tone for \"#\". This can be used if the callout destination for instance require a conference PIN code or an extension to be entered. */ + /** When the destination picks up, this DTMF tones will be played to the callee. Valid characters in the string are "0"-"9", "#", and "w". A "w" will render a 500 ms pause. For example, "ww1234#w#" will render a 1s pause, the DTMF tones "1", "2", "3", "4" and "#" followed by a 0.5s pause and finally the DTMF tone for "#". This can be used if the callout destination for instance require a conference PIN code or an extension to be entered. */ dtmf?: string; /** Can be either `pstn` for PSTN endpoint or `mxp` for data (app or web) clients. */ domain?: DomainEnum; @@ -24,15 +24,15 @@ export interface TtsCalloutRequest { custom?: string; /** The voice and language you want to use for the text-to-speech message. This can either be defined by the ISO 639 locale and language code or by specifying a particular voice. Supported languages and voices are detailed [here](../../../voice-locales/). */ locale?: string; - /** The text that will be spoken in the text-to-speech message. _Every application\'s default maximum characters allowed in text-to-speech is 600 characters. Contact support if you wish this limit to be changed._ */ + /** The text that will be spoken in the text-to-speech message. _Every application's default maximum characters allowed in text-to-speech is 600 characters. Contact support if you wish this limit to be changed._ */ text?: string; - /** An advanced alternative to using ```text```. __TTS__ _Text To Speech:_ The equivalent of text but within the prompt property. Example: _```#tts[Hello from Sinch]```_ __TTS with SSML__ _Text To Speech with Speech Synthesis Markup Language (SSML)._ This is an XML-based markup language for assisting the generation of synthetic speech in the Web and other applications. AWS Polly supports a sub-set of SSML. This allows us to use SSML-enhanced text for additional control over how Polly generates speech from the text. Details and examples of supported tags are [here](https://docs.aws.amazon.com/polly/latest/dg/supportedtags.html) __Externally hosted media:__ Provide a URL to your own hosted media. Please check [here](../../../supported-audio-formats/#limits) to read about audio content type and usage limits. _Every application\'s default maximum allowed in TTS or TTS SSML is 600 characters. Contact support if you wish this limit to be changed._ _Several prompts can be used, separated by a semi-colon_ ```;``` Example: _```#tts[Hello from Sinch];#ssml[Have a great day!]```_ */ + /** An advanced alternative to using ```text```. __TTS__ _Text To Speech:_ The equivalent of text but within the prompt property. Example: _```#tts[Hello from Sinch]```_ __TTS with SSML__ _Text To Speech with Speech Synthesis Markup Language (SSML)._ This is an XML-based markup language for assisting the generation of synthetic speech in the Web and other applications. AWS Polly supports a sub-set of SSML. This allows us to use SSML-enhanced text for additional control over how Polly generates speech from the text. Details and examples of supported tags are [here](https://docs.aws.amazon.com/polly/latest/dg/supportedtags.html) __Externally hosted media:__ Provide a URL to your own hosted media. Please check [here](../../../supported-audio-formats/#limits) to read about audio content type and usage limits. _Every application's default maximum allowed in TTS or TTS SSML is 600 characters. Contact support if you wish this limit to be changed._ _Several prompts can be used, separated by a semi-colon_ ```;``` Example: _```#tts[Hello from Sinch];#ssml[Have a great day!]```_ */ prompts?: string; - /** If `enableAce` is set to `true` and the application has a callback URL specified, you will receive an ACE callback when the call is answered. When the callback is received, your platform must respond with a svamlet, containing the “connectconf” action in order to add the call to a conference or create the conference if it\'s the first call. If it\'s set to `false`, no ACE event will be sent to your backend. */ + /** If `enableAce` is set to `true` and the application has a callback URL specified, you will receive an ACE callback when the call is answered. When the callback is received, your platform must respond with a svamlet, containing the “connectconf” action in order to add the call to a conference or create the conference if it's the first call. If it's set to `false`, no ACE event will be sent to your backend. */ enableAce?: boolean; - /** If `enableDice` is set to `true` and the application has a callback URL specified, you will receive a DiCE callback when the call is disconnected. If it\'s set to `false`, no DiCE event will be sent to your backend. */ + /** If `enableDice` is set to `true` and the application has a callback URL specified, you will receive a DiCE callback when the call is disconnected. If it's set to `false`, no DiCE event will be sent to your backend. */ enableDice?: boolean; - /** Note: PIE callbacks are not available for DATA Calls; only PSTN and SIP calls. If `enablePie` is set to `true` and the application has a callback URL specified, you will receive a PIE callback after the `runMenu` action executes and after the configured menu timeout has elapsed with no input. If it\'s set to `false`, no PIE events will be sent to your backend. */ + /** Note: PIE callbacks are not available for DATA Calls; only PSTN and SIP calls. If `enablePie` is set to `true` and the application has a callback URL specified, you will receive a PIE callback after the `runMenu` action executes and after the configured menu timeout has elapsed with no input. If it's set to `false`, no PIE events will be sent to your backend. */ enablePie?: boolean; } diff --git a/packages/voice/src/models/v1/update-numbers/update-numbers.ts b/packages/voice/src/models/v1/update-numbers/update-numbers.ts index 5ff8eec8..226a6f47 100644 --- a/packages/voice/src/models/v1/update-numbers/update-numbers.ts +++ b/packages/voice/src/models/v1/update-numbers/update-numbers.ts @@ -12,7 +12,7 @@ export interface UpdateNumbers { numbers?: string[]; /** indicates the application where the number(s) will be assigned. If empty, the application key that is used to sign the request will be used. */ applicationkey?: string; - /** indicates the DID capability that needs to be assigned to the chosen application. Valid values are \'voice\' and \'sms\'. Please note that the DID needs to support the selected capability. */ + /** indicates the DID capability that needs to be assigned to the chosen application. Valid values are 'voice' and 'sms'. Please note that the DID needs to support the selected capability. */ capability?: CapabilityEnum; } From b617ddbcd47d56df393a75022b8a3750aebae4b1 Mon Sep 17 00:00:00 2001 From: Antoine Sein Date: Fri, 29 Dec 2023 14:52:27 +0100 Subject: [PATCH 3/4] Fix linter --- .../index.ts | 4 +++- .../v1/get-call-response-obj/get-call-response-obj.ts | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/voice/src/models/v1/conference-callout-request-conference-dtmf-options/index.ts b/packages/voice/src/models/v1/conference-callout-request-conference-dtmf-options/index.ts index f63d84da..2a20883e 100644 --- a/packages/voice/src/models/v1/conference-callout-request-conference-dtmf-options/index.ts +++ b/packages/voice/src/models/v1/conference-callout-request-conference-dtmf-options/index.ts @@ -1 +1,3 @@ -export type { ConferenceCalloutRequestConferenceDtmfOptions } from './conference-callout-request-conference-dtmf-options'; +export type { + ConferenceCalloutRequestConferenceDtmfOptions, +} from './conference-callout-request-conference-dtmf-options'; diff --git a/packages/voice/src/models/v1/get-call-response-obj/get-call-response-obj.ts b/packages/voice/src/models/v1/get-call-response-obj/get-call-response-obj.ts index c313f7df..1eb1958e 100644 --- a/packages/voice/src/models/v1/get-call-response-obj/get-call-response-obj.ts +++ b/packages/voice/src/models/v1/get-call-response-obj/get-call-response-obj.ts @@ -37,5 +37,13 @@ export interface GetCallResponseObj { export type DomainEnum = 'pstn'; export type StatusEnum = 'ONGOING' | 'FINAL'; export type ResultEnum = 'N/A' | 'ANSWERED' | 'BUSY' | 'NOANSWER' | 'FAILED'; -export type ReasonEnum = 'N/A' | 'TIMEOUT' | 'CALLERHANGUP' | 'CALLEEHANGUP' | 'BLOCKED' | 'NOCREDITPARTNER' | 'MANAGERHANGUP' | 'CANCEL' | 'GENERALERROR'; +export type ReasonEnum = 'N/A' + | 'TIMEOUT' + | 'CALLERHANGUP' + | 'CALLEEHANGUP' + | 'BLOCKED' + | 'NOCREDITPARTNER' + | 'MANAGERHANGUP' + | 'CANCEL' + | 'GENERALERROR'; From 161757cd00eaaa2521994139d022727c797dd33d Mon Sep 17 00:00:00 2001 From: Antoine SEIN <142824551+asein-sinch@users.noreply.github.com> Date: Fri, 29 Dec 2023 15:06:47 +0100 Subject: [PATCH 4/4] DEVEXP-249: Voice API - Generate REST services (#4) * DEVEXP-249: Voice API - Generate REST services * DEVEXP-250: Voice API - Write tests * DEVEXP-251: Voice API - Integrate in SDK core * DEVEXP-252: Voice API - Write example files --- examples/simple-examples/README.md | 19 ++ examples/simple-examples/package.json | 18 +- examples/simple-examples/src/config.ts | 78 +++--- .../simple-examples/src/numbers/active/get.ts | 4 - .../src/numbers/active/release.ts | 4 - .../src/numbers/active/update.ts | 9 - .../numbers/available/checkAvailability.ts | 4 - .../src/numbers/available/rent.ts | 19 +- .../src/numbers/available/rentAny.ts | 10 +- .../src/numbers/callbacks/update.ts | 4 - .../simple-examples/src/sms/batches/cancel.ts | 4 - .../src/sms/batches/delivery-feedback.ts | 9 - .../src/sms/batches/dry-run.ts | 9 - .../simple-examples/src/sms/batches/get.ts | 4 - .../src/sms/batches/replace.ts | 14 -- .../simple-examples/src/sms/batches/send.ts | 9 - .../simple-examples/src/sms/batches/update.ts | 14 -- .../src/sms/delivery-reports/getByBatchId.ts | 4 - .../sms/delivery-reports/getByPhoneNumber.ts | 9 - .../src/sms/groups/delete/delete.ts | 4 - .../simple-examples/src/sms/groups/get/get.ts | 4 - .../groups/getPhoneNumbers/getPhoneNumbers.ts | 4 - .../src/sms/groups/replace/replace.ts | 4 - .../src/sms/groups/update/update.ts | 4 - .../simple-examples/src/sms/inbounds/get.ts | 4 - .../simple-examples/src/sms/inbounds/list.ts | 5 - .../verification-status/verification-by-id.ts | 8 +- .../verification-by-identity.ts | 9 +- .../verification-by-reference.ts | 9 +- .../callout/report-with-id_callout.ts | 9 - .../callout/report-with-identity_callout.ts | 9 - .../verifications/callout/start-callout.ts | 4 - .../flashcall/report-with-id_flashcall.ts | 9 - .../report-with-identity_flashcall.ts | 9 - .../flashcall/start-flashcall.ts | 4 - .../verifications/report-with-id.ts | 4 +- .../verifications/report-with-identity.ts | 4 +- .../verifications/seamless/start-seamless.ts | 4 - .../verifications/sms/report-with-id_sms.ts | 9 - .../sms/report-with-identity_sms.ts | 9 - .../verifications/sms/start_sms.ts | 4 - .../src/verification/verifications/start.ts | 4 +- .../src/voice/applications/assignNumbers.ts | 29 +++ .../src/voice/applications/getCallbackURLs.ts | 36 +++ .../src/voice/applications/getNumbers.ts | 27 +++ .../src/voice/applications/queryNumber.ts | 31 +++ .../src/voice/applications/unassignNumber.ts | 29 +++ .../voice/applications/updateCallbackURLs.ts | 34 +++ .../src/voice/callouts/conference.ts | 51 ++++ .../src/voice/callouts/custom.ts | 48 ++++ .../simple-examples/src/voice/callouts/tts.ts | 50 ++++ .../simple-examples/src/voice/calls/get.ts | 39 +++ .../src/voice/calls/manageWithCallLeg.ts | 41 ++++ .../simple-examples/src/voice/calls/update.ts | 40 +++ .../src/voice/conferences/get.ts | 37 +++ .../src/voice/conferences/kickAll.ts | 29 +++ .../src/voice/conferences/kickParticipant.ts | 32 +++ .../voice/conferences/manageParticipant.ts | 36 +++ jest.config.ts | 5 + .../client/api-client-pagination-helper.ts | 2 +- .../sdk-client/src/domain/domain-interface.ts | 24 ++ packages/sdk-core/package.json | 3 +- packages/sdk-core/src/index.ts | 1 + packages/sdk-core/src/sinch-client.ts | 5 + .../sms/src/rest/v1/batches/batches-api.ts | 2 +- packages/sms/src/rest/v1/groups/groups-api.ts | 2 +- packages/sms/src/rest/v1/sms-api.ts | 11 +- packages/voice/README.md | 24 +- packages/voice/src/index.ts | 2 + .../assign-numbers.ts} | 4 +- .../src/models/v1/assign-numbers/index.ts | 1 + packages/voice/src/models/v1/enums.ts | 2 +- .../get-call-response-obj.ts | 26 +- .../models/v1/get-call-response-obj/index.ts | 7 +- .../v1/get-query-number/get-query-number.ts | 2 +- packages/voice/src/models/v1/index.ts | 2 +- .../src/models/v1/update-numbers/index.ts | 1 - packages/voice/src/rest/index.ts | 1 + .../applications-api.jest.fixture.ts | 31 +++ .../rest/v1/applications/applications-api.ts | 228 ++++++++++++++++++ .../voice/src/rest/v1/applications/index.ts | 2 + .../v1/callouts/callouts-api.jest.fixture.ts | 26 ++ .../src/rest/v1/callouts/callouts-api.ts | 137 +++++++++++ packages/voice/src/rest/v1/callouts/index.ts | 2 + .../rest/v1/calls/calls-api.jest.fixture.ts | 19 ++ packages/voice/src/rest/v1/calls/calls-api.ts | 127 ++++++++++ packages/voice/src/rest/v1/calls/index.ts | 2 + .../conferences-api.jest.fixture.ts | 30 +++ .../rest/v1/conferences/conferences-api.ts | 159 ++++++++++++ .../voice/src/rest/v1/conferences/index.ts | 2 + packages/voice/src/rest/v1/enums.ts | 1 + packages/voice/src/rest/v1/fixtures.jest.ts | 4 + packages/voice/src/rest/v1/index.ts | 6 + packages/voice/src/rest/v1/voice-api.ts | 104 ++++++++ packages/voice/src/rest/v1/voice.ts | 41 ++++ .../v1/applications/applications-api.test.ts | 179 ++++++++++++++ .../rest/v1/callouts/callouts-api.test.ts | 115 +++++++++ .../tests/rest/v1/calls/calls-api.test.ts | 131 ++++++++++ .../v1/conferences/conferences-api.test.ts | 121 ++++++++++ 99 files changed, 2265 insertions(+), 300 deletions(-) create mode 100644 examples/simple-examples/src/voice/applications/assignNumbers.ts create mode 100644 examples/simple-examples/src/voice/applications/getCallbackURLs.ts create mode 100644 examples/simple-examples/src/voice/applications/getNumbers.ts create mode 100644 examples/simple-examples/src/voice/applications/queryNumber.ts create mode 100644 examples/simple-examples/src/voice/applications/unassignNumber.ts create mode 100644 examples/simple-examples/src/voice/applications/updateCallbackURLs.ts create mode 100644 examples/simple-examples/src/voice/callouts/conference.ts create mode 100644 examples/simple-examples/src/voice/callouts/custom.ts create mode 100644 examples/simple-examples/src/voice/callouts/tts.ts create mode 100644 examples/simple-examples/src/voice/calls/get.ts create mode 100644 examples/simple-examples/src/voice/calls/manageWithCallLeg.ts create mode 100644 examples/simple-examples/src/voice/calls/update.ts create mode 100644 examples/simple-examples/src/voice/conferences/get.ts create mode 100644 examples/simple-examples/src/voice/conferences/kickAll.ts create mode 100644 examples/simple-examples/src/voice/conferences/kickParticipant.ts create mode 100644 examples/simple-examples/src/voice/conferences/manageParticipant.ts create mode 100644 packages/voice/src/index.ts rename packages/voice/src/models/v1/{update-numbers/update-numbers.ts => assign-numbers/assign-numbers.ts} (91%) create mode 100644 packages/voice/src/models/v1/assign-numbers/index.ts delete mode 100644 packages/voice/src/models/v1/update-numbers/index.ts create mode 100644 packages/voice/src/rest/index.ts create mode 100644 packages/voice/src/rest/v1/applications/applications-api.jest.fixture.ts create mode 100644 packages/voice/src/rest/v1/applications/applications-api.ts create mode 100644 packages/voice/src/rest/v1/applications/index.ts create mode 100644 packages/voice/src/rest/v1/callouts/callouts-api.jest.fixture.ts create mode 100644 packages/voice/src/rest/v1/callouts/callouts-api.ts create mode 100644 packages/voice/src/rest/v1/callouts/index.ts create mode 100644 packages/voice/src/rest/v1/calls/calls-api.jest.fixture.ts create mode 100644 packages/voice/src/rest/v1/calls/calls-api.ts create mode 100644 packages/voice/src/rest/v1/calls/index.ts create mode 100644 packages/voice/src/rest/v1/conferences/conferences-api.jest.fixture.ts create mode 100644 packages/voice/src/rest/v1/conferences/conferences-api.ts create mode 100644 packages/voice/src/rest/v1/conferences/index.ts create mode 100644 packages/voice/src/rest/v1/enums.ts create mode 100644 packages/voice/src/rest/v1/fixtures.jest.ts create mode 100644 packages/voice/src/rest/v1/index.ts create mode 100644 packages/voice/src/rest/v1/voice-api.ts create mode 100644 packages/voice/src/rest/v1/voice.ts create mode 100644 packages/voice/tests/rest/v1/applications/applications-api.test.ts create mode 100644 packages/voice/tests/rest/v1/callouts/callouts-api.test.ts create mode 100644 packages/voice/tests/rest/v1/calls/calls-api.test.ts create mode 100644 packages/voice/tests/rest/v1/conferences/conferences-api.test.ts diff --git a/examples/simple-examples/README.md b/examples/simple-examples/README.md index 5d0f7575..edf64e8f 100644 --- a/examples/simple-examples/README.md +++ b/examples/simple-examples/README.md @@ -51,6 +51,8 @@ VERIFICATION_IDENTITY=verification-identity to fill with the identity of the use VERIFICATION_REFERENCE=verification-reference to add when starting a verification or getting its status VERIFICATION_CODE=verification-code received for a verification via SMS or callout VERIFICATION_CLI=verification-cli received for a verification via flashCall +CALL_ID=call_id to fill with one of the callouts created with the Voice API +CONFERENCE_ID=unique identifier of the conference you want to interact with ``` **Note**: If you prefer using environment variables, the sample app is also supporting them: they take precedence over the value from the `.env` file. @@ -113,3 +115,20 @@ yarn run numbers:regions:list | | Verification-status | [./src/verification/verification-status/verification-by-id.ts](./src/verification/verification-status/verification-by-id.ts) | `VERIFICATION_ID` | | | | [./src/verification/verification-status/verification-by-identity.ts](./src/verification/verification-status/verification-by-identity.ts) | `VERIFICATION_IDENTITY` | | | | [./src/verification/verification-status/verification-by-reference.ts](./src/verification/verification-status/verification-by-reference.ts) | `VERIFICATION_REFERENCE` | +| Voice | Applications | [./src/voice/applications/assignNumbers.ts](./src/voice/applications/assignNumbers.ts) | `PHONE_NUMBER` + `SINCH_APPLICATION_KEY` | +| | | [./src/voice/applications/getCallbackURLs.ts](./src/voice/applications/getCallbackURLs.ts) | `SINCH_APPLICATION_KEY` | +| | | [./src/voice/applications/getNumbers.ts](./src/voice/applications/getNumbers.ts) | | +| | | [./src/voice/applications/queryNumber.ts](./src/voice/applications/queryNumber.ts) | `PHONE_NUMBER` | +| | | [./src/voice/applications/unassignNumber.ts](./src/voice/applications/unassignNumber.ts) | `PHONE_NUMBER` + `SINCH_APPLICATION_KEY` | +| | | [./src/voice/applications/updateCallbackURLs.ts](./src/voice/applications/updateCallbackURLs.ts) | `SINCH_APPLICATION_KEY` | +| | Callouts | [./src/voice/callouts/conference.ts](./src/voice/callouts/conference.ts) | `PHONE_NUMBER` + `RECIPIENT_PHONE_NUMBER` + `CONFERENCE_ID` | +| | | [./src/voice/callouts/custom.ts](./src/voice/callouts/custom.ts) | `PHONE_NUMBER` + `RECIPIENT_PHONE_NUMBER` | +| | | [./src/voice/callouts/tts.ts](./src/voice/callouts/tts.ts) | `PHONE_NUMBER` + `RECIPIENT_PHONE_NUMBER` | +| | Calls | [./src/voice/calls/get.ts](./src/voice/calls/get.ts) | `CALL_ID` | +| | | [./src/voice/calls/manageWithCallLeg.ts](./src/voice/calls/manageWithCallLeg.ts) | `CALL_ID` | +| | | [./src/voice/calls/update.ts](./src/voice/calls/update.ts) | `CALL_ID` | +| | Conferences | [./src/voice/conferences/get.ts](./src/voice/conferences/get.ts) | `CONFERENCE_ID` | +| | | [./src/voice/conferences/kickAll.ts](./src/voice/conferences/kickAll.ts) | `CONFERENCE_ID` | +| | | [./src/voice/conferences/kickParticipant.ts](./src/voice/conferences/kickParticipant.ts) | `CONFERENCE_ID` + `CALL_ID` | +| | | [./src/voice/conferences/manageParticipant.ts](./src/voice/conferences/manageParticipant.ts) | `CONFERENCE_ID` + `CALL_ID` | + diff --git a/examples/simple-examples/package.json b/examples/simple-examples/package.json index 2818172a..46dded99 100644 --- a/examples/simple-examples/package.json +++ b/examples/simple-examples/package.json @@ -47,7 +47,23 @@ "verification:verifications:report-with-identity": "ts-node src/verification/verifications/report-with-identity.ts", "verification:verification-status:verification-by-id": "ts-node src/verification/verification-status/verification-by-id.ts", "verification:verification-status:verification-by-identity": "ts-node src/verification/verification-status/verification-by-identity.ts", - "verification:verification-status:verification-by-reference": "ts-node src/verification/verification-status/verification-by-reference.ts" + "verification:verification-status:verification-by-reference": "ts-node src/verification/verification-status/verification-by-reference.ts", + "voice:applications:getNumbers": "ts-node src/voice/applications/getNumbers.ts", + "voice:applications:queryNumber": "ts-node src/voice/applications/queryNumber.ts", + "voice:applications:assignNumbers": "ts-node src/voice/applications/assignNumbers.ts", + "voice:applications:unassignNumber": "ts-node src/voice/applications/unassignNumber.ts", + "voice:applications:getCallbackURLs": "ts-node src/voice/applications/getCallbackURLs.ts", + "voice:applications:updateCallbackURLs": "ts-node src/voice/applications/updateCallbackURLs.ts", + "voice:callouts:tts": "ts-node src/voice/callouts/tts.ts", + "voice:callouts:conference": "ts-node src/voice/callouts/conference.ts", + "voice:callouts:custom": "ts-node src/voice/callouts/custom.ts", + "voice:calls:get": "ts-node src/voice/calls/get.ts", + "voice:calls:update": "ts-node src/voice/calls/update.ts", + "voice:calls:manageWithCallLeg": "ts-node src/voice/calls/manageWithCallLeg.ts", + "voice:conferences:get": "ts-node src/voice/conferences/get.ts", + "voice:conferences:manageParticipant": "ts-node src/voice/conferences/manageParticipant.ts", + "voice:conferences:kickParticipant": "ts-node src/voice/conferences/kickParticipant.ts", + "voice:conferences:kickAll": "ts-node src/voice/conferences/kickAll.ts" }, "dependencies": { "@sinch/sdk-core": "^0.0.0", diff --git a/examples/simple-examples/src/config.ts b/examples/simple-examples/src/config.ts index d16be184..86612d43 100644 --- a/examples/simple-examples/src/config.ts +++ b/examples/simple-examples/src/config.ts @@ -15,7 +15,7 @@ export const initSmsClient = () => { return new SinchClient({ servicePlanId, apiToken, region }); }; -export const initVerificationClient = () => { +export const initApplicationClient = () => { const applicationKey = process.env.SINCH_APPLICATION_KEY || ''; const applicationSecret = process.env.SINCH_APPLICATION_SECRET || ''; return new SinchClient({ applicationKey, applicationSecret }); @@ -29,56 +29,80 @@ export const getPrintFormat = (args: string[]): 'pretty' | 'full' => { return 'full'; }; -export const getPhoneNumberFromConfig = (): string | undefined => { - return process.env.PHONE_NUMBER; +export const getPhoneNumberFromConfig = (): string => { + return readVariable('PHONE_NUMBER'); }; -export const getServicePlanIdFromConfig = (): string | undefined => { - return process.env.SINCH_SERVICE_PLAN_ID; +export const readServicePlanId = (): string | undefined => { + return process.env.SERVICE_PLAN_ID; }; -export const getApplicationKeyFromConfig = (): string | undefined => { - return process.env.APPLICATION_KEY; +export const readApplicationKey = (): string | undefined => { + return process.env.SINCH_APPLICATION_KEY; }; -export const getGroupIdFromConfig = (): string | undefined => { - return process.env.GROUP_ID; +export const getServicePlanIdFromConfig = (): string => { + return readVariable('SERVICE_PLAN_ID'); }; -export const getRecipientPhoneNumberFromConfig = (): string | undefined => { - return process.env.RECIPIENT_PHONE_NUMBER; +export const getApplicationKeyFromConfig = (): string => { + return readVariable('SINCH_APPLICATION_KEY'); }; -export const getBatchIdFromConfig = (): string | undefined => { - return process.env.BATCH_ID; +export const getGroupIdFromConfig = (): string => { + return readVariable('GROUP_ID'); }; -export const getInboundIdFromConfig = (): string | undefined => { - return process.env.INBOUND_ID; +export const getRecipientPhoneNumberFromConfig = (): string => { + return readVariable('RECIPIENT_PHONE_NUMBER'); }; -export const getHmacSecretFromConfig = (): string | undefined => { - return process.env.HMAC_SECRET; +export const getBatchIdFromConfig = (): string => { + return readVariable('BATCH_ID'); }; -export const getVerificationIdFromConfig = (): string | undefined => { - return process.env.VERIFICATION_ID; +export const getInboundIdFromConfig = (): string => { + return readVariable('INBOUND_ID'); }; -export const getVerificationIdentityFromConfig = (): string | undefined => { - return process.env.VERIFICATION_IDENTITY; +export const getHmacSecretFromConfig = (): string => { + return readVariable('HMAC_SECRET'); }; -export const getVerificationReferenceFromConfig = (): string | undefined => { - return process.env.VERIFICATION_REFERENCE; +export const getVerificationIdFromConfig = (): string => { + return readVariable('VERIFICATION_ID'); }; -export const getVerificationCodeFromConfig = (): string | undefined => { - return process.env.VERIFICATION_CODE; +export const getVerificationIdentityFromConfig = (): string => { + return readVariable('VERIFICATION_IDENTITY'); }; -export const getVerificationCliFromConfig = (): string | undefined => { - return process.env.VERIFICATION_CLI; +export const getVerificationReferenceFromConfig = (): string => { + return readVariable('VERIFICATION_REFERENCE'); +}; + +export const getVerificationCodeFromConfig = (): string => { + return readVariable('VERIFICATION_CODE'); +}; + +export const getVerificationCliFromConfig = (): string => { + return readVariable('VERIFICATION_CLI'); +}; + +export const getCallIdFromConfig = (): string => { + return readVariable('CALL_ID'); +}; + +export const getConferenceIdFromConfig = (): string => { + return readVariable('CONFERENCE_ID'); +}; + +const readVariable = ( name: string): string => { + const value = process.env[name]; + if (!value) { + throw new Error(`No "${name}" has been provided. Please update your .env file.`); + } + return value; }; export const printFullResponse = (response: any) => { diff --git a/examples/simple-examples/src/numbers/active/get.ts b/examples/simple-examples/src/numbers/active/get.ts index 471a6002..131aa814 100644 --- a/examples/simple-examples/src/numbers/active/get.ts +++ b/examples/simple-examples/src/numbers/active/get.ts @@ -7,10 +7,6 @@ import { GetActiveNumberRequestData } from '@sinch/sdk-core'; console.log('*********************************'); const phoneNumber = getPhoneNumberFromConfig(); - if (!phoneNumber) { - throw new Error('No phone number has been provided. ' - + 'Please update your .env file or edit the ./src/numbers/active/get.ts file'); - } const requestData: GetActiveNumberRequestData= { phoneNumber, diff --git a/examples/simple-examples/src/numbers/active/release.ts b/examples/simple-examples/src/numbers/active/release.ts index 9ef23c8d..4ca17422 100644 --- a/examples/simple-examples/src/numbers/active/release.ts +++ b/examples/simple-examples/src/numbers/active/release.ts @@ -7,10 +7,6 @@ import { ReleaseNumberRequestData } from '@sinch/sdk-core'; console.log('*******************************'); const phoneNumber = getPhoneNumberFromConfig(); - if (!phoneNumber) { - throw new Error('No phone number has been provided. ' - + 'Please update your .env file or edit the ./src/numbers/active/release.ts file'); - } const requestData: ReleaseNumberRequestData= { phoneNumber, diff --git a/examples/simple-examples/src/numbers/active/update.ts b/examples/simple-examples/src/numbers/active/update.ts index d22aa12e..af897dd6 100644 --- a/examples/simple-examples/src/numbers/active/update.ts +++ b/examples/simple-examples/src/numbers/active/update.ts @@ -13,16 +13,7 @@ import { UpdateActiveNumberRequestData } from '@sinch/sdk-core'; console.log('************************************'); const phoneNumber = getPhoneNumberFromConfig(); - if (!phoneNumber) { - throw new Error('No phone number has been provided. ' - + 'Please update your .env file or edit the ./src/numbers/active/update.ts file'); - } - const servicePlanId = getServicePlanIdFromConfig(); - if (!servicePlanId) { - throw new Error('No servicePlanId has been provided. ' - + 'Please update your .env file or edit the ./src/numbers/active/update.ts file'); - } const requestData: UpdateActiveNumberRequestData= { phoneNumber, diff --git a/examples/simple-examples/src/numbers/available/checkAvailability.ts b/examples/simple-examples/src/numbers/available/checkAvailability.ts index 4c2e1562..6ab0f0bc 100644 --- a/examples/simple-examples/src/numbers/available/checkAvailability.ts +++ b/examples/simple-examples/src/numbers/available/checkAvailability.ts @@ -8,10 +8,6 @@ import { GetAvailableNumberRequestData } from '@sinch/sdk-core'; // Use the phone number from the .env file const phoneNumber = getPhoneNumberFromConfig(); - if (!phoneNumber) { - throw new Error('No phone number has been provided. ' - + 'Please update your .env file or edit the ./src/numbers/available/checkAvailability.ts file'); - } const requestData: GetAvailableNumberRequestData= { phoneNumber, diff --git a/examples/simple-examples/src/numbers/available/rent.ts b/examples/simple-examples/src/numbers/available/rent.ts index 60c5e78d..233a30c4 100644 --- a/examples/simple-examples/src/numbers/available/rent.ts +++ b/examples/simple-examples/src/numbers/available/rent.ts @@ -1,8 +1,8 @@ import { - getApplicationKeyFromConfig, + readApplicationKey, getPhoneNumberFromConfig, getPrintFormat, - getServicePlanIdFromConfig, + readServicePlanId, initClient, printFullResponse, } from '../../config'; @@ -16,15 +16,8 @@ import { console.log('* NumberService_RentNumber *'); console.log('****************************'); - // Use the phone number from the .env file - const phoneNumber = getPhoneNumberFromConfig(); - if (!phoneNumber) { - throw new Error('No phone number has been provided. ' - + 'Please update your .env file or edit the ./src/numbers/available/rent.ts file'); - } - - const servicePlanId = getServicePlanIdFromConfig(); - const appId = getApplicationKeyFromConfig(); + const servicePlanId = readServicePlanId(); + const appId = readApplicationKey(); let rentNumberRequest: RentNumberRequest = { smsConfiguration: servicePlanId ? { servicePlanId } : undefined, @@ -34,9 +27,11 @@ import { if (!rentNumberRequest.smsConfiguration && !rentNumberRequest.voiceConfiguration) { rentNumberRequest = {}; console.error('Warning: no configuration has been provided for sms and voice configuration.' - + 'You may want to check the value of "SERVICE_PLAN_ID" and "APPLICATION_KEY" in the .env file'); + + 'You may want to check the value of "SINCH_SERVICE_PLAN_ID" and "SINCH_APPLICATION_KEY" in the .env file'); } + const phoneNumber = getPhoneNumberFromConfig(); + const requestData: RentNumberRequestData = { phoneNumber, rentNumberRequestBody: rentNumberRequest, diff --git a/examples/simple-examples/src/numbers/available/rentAny.ts b/examples/simple-examples/src/numbers/available/rentAny.ts index fe9517c4..4dadd50d 100644 --- a/examples/simple-examples/src/numbers/available/rentAny.ts +++ b/examples/simple-examples/src/numbers/available/rentAny.ts @@ -1,9 +1,9 @@ import { - getApplicationKeyFromConfig, getPrintFormat, - getServicePlanIdFromConfig, initClient, printFullResponse, + readApplicationKey, + readServicePlanId, } from '../../config'; import { RentAnyNumberRequest, @@ -15,12 +15,12 @@ import { console.log('* NumberService_RentAnyNumber *'); console.log('*******************************'); - const servicePlanId = getServicePlanIdFromConfig(); - const appId = getApplicationKeyFromConfig(); + const servicePlanId = readServicePlanId(); + const appId = readApplicationKey(); if (!servicePlanId && !appId) { console.error('Warning: no configuration has been provided for sms and voice configuration.' - + 'You may want to check the value of "SERVICE_PLAN_ID" and "APPLICATION_KEY" in the .env file'); + + 'You may want to check the value of "SINCH_SERVICE_PLAN_ID" and "SINCH_APPLICATION_KEY" in the .env file'); } const rentAnyNumberRequest: RentAnyNumberRequest = { diff --git a/examples/simple-examples/src/numbers/callbacks/update.ts b/examples/simple-examples/src/numbers/callbacks/update.ts index aa019780..09568897 100644 --- a/examples/simple-examples/src/numbers/callbacks/update.ts +++ b/examples/simple-examples/src/numbers/callbacks/update.ts @@ -8,10 +8,6 @@ import * as process from 'process'; console.log('*******************************'); const hmacSecret = getHmacSecretFromConfig(); - if (!hmacSecret) { - console.log('No HMAC secret has been provided. ' - + 'Please update your .env file or edit the ./src/numbers/callback/update.ts file'); - } const requestData: UpdateCallbackConfigurationRequestData = { callbackConfigurationUpdateRequestBody: { diff --git a/examples/simple-examples/src/sms/batches/cancel.ts b/examples/simple-examples/src/sms/batches/cancel.ts index 5c1d3ade..ae622747 100644 --- a/examples/simple-examples/src/sms/batches/cancel.ts +++ b/examples/simple-examples/src/sms/batches/cancel.ts @@ -7,10 +7,6 @@ import { CancelBatchMessageRequestData } from '@sinch/sdk-core'; console.log('**********************'); const batchIdInTheFuture = getBatchIdFromConfig(); - if (!batchIdInTheFuture) { - throw new Error('No batch id has been provided. ' - + 'Please update your .env file or edit the ./src/sms/batches/cancel.ts file'); - } const requestData: CancelBatchMessageRequestData= { batch_id: batchIdInTheFuture, diff --git a/examples/simple-examples/src/sms/batches/delivery-feedback.ts b/examples/simple-examples/src/sms/batches/delivery-feedback.ts index eb54a29a..46d33353 100644 --- a/examples/simple-examples/src/sms/batches/delivery-feedback.ts +++ b/examples/simple-examples/src/sms/batches/delivery-feedback.ts @@ -7,16 +7,7 @@ import { DeliveryFeedbackRequestData } from '@sinch/sdk-core'; console.log('********************'); const batchIdInTheFuture = getBatchIdFromConfig(); - if (!batchIdInTheFuture) { - throw new Error('No batch id has been provided. ' - + 'Please update your .env file or edit the ./src/sms/batches/delivery-feedback.ts file'); - } - const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); - if (!recipientPhoneNumber) { - throw new Error('No recipient phone number has been provided. ' - + 'Please update your .env file or edit the ./src/sms/batches/delivery-feedback.ts file'); - } const requestData: DeliveryFeedbackRequestData= { batch_id: batchIdInTheFuture, diff --git a/examples/simple-examples/src/sms/batches/dry-run.ts b/examples/simple-examples/src/sms/batches/dry-run.ts index 00ea2fc7..ce664be2 100644 --- a/examples/simple-examples/src/sms/batches/dry-run.ts +++ b/examples/simple-examples/src/sms/batches/dry-run.ts @@ -13,16 +13,7 @@ import { DryRunRequestData, TextRequest } from '@sinch/sdk-core'; console.log('***********'); const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); - if (!recipientPhoneNumber) { - throw new Error('No recipient phone number has been provided. ' - + 'Please update your .env file or edit the ./src/sms/batches/dry-run.ts file'); - } - const senderPhoneNumber = getPhoneNumberFromConfig(); - if (!senderPhoneNumber) { - throw new Error('No sender phone number has been provided. ' - + 'Please update your .env file or edit the ./src/sms/batches/dry-run.ts file'); - } const requestData: DryRunRequestData= { dryRunRequestBody: { diff --git a/examples/simple-examples/src/sms/batches/get.ts b/examples/simple-examples/src/sms/batches/get.ts index 644f8efd..a78db523 100644 --- a/examples/simple-examples/src/sms/batches/get.ts +++ b/examples/simple-examples/src/sms/batches/get.ts @@ -7,10 +7,6 @@ import { GetBatchMessageRequestData } from '@sinch/sdk-core'; console.log('*******************'); const batchId = getBatchIdFromConfig(); - if (!batchId) { - throw new Error('No batch id has been provided. ' - + 'Please update your .env file or edit the ./src/sms/batches/get.ts file'); - } const requestData: GetBatchMessageRequestData= { batch_id: batchId, diff --git a/examples/simple-examples/src/sms/batches/replace.ts b/examples/simple-examples/src/sms/batches/replace.ts index b9372725..679a4ab0 100644 --- a/examples/simple-examples/src/sms/batches/replace.ts +++ b/examples/simple-examples/src/sms/batches/replace.ts @@ -13,22 +13,8 @@ import { BinaryRequest, ReplaceBatchMessageRequestData, textToHex } from '@sinch console.log('****************'); const batchIdInTheFuture = getBatchIdFromConfig(); - if (!batchIdInTheFuture) { - throw new Error('No batch id has been provided. ' - + 'Please update your .env file or edit the ./src/sms/batches/replace.ts file'); - } - const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); - if (!recipientPhoneNumber) { - throw new Error('No recipient phone number has been provided. ' - + 'Please update your .env file or edit the ./src/sms/batches/replace.ts file'); - } - const senderPhoneNumber = getPhoneNumberFromConfig(); - if (!senderPhoneNumber) { - throw new Error('No sender phone number has been provided. ' - + 'Please update your .env file or edit the ./src/sms/batches/replace.ts file'); - } const requestData: ReplaceBatchMessageRequestData= { batch_id: batchIdInTheFuture, diff --git a/examples/simple-examples/src/sms/batches/send.ts b/examples/simple-examples/src/sms/batches/send.ts index 8485884a..9e161dc1 100644 --- a/examples/simple-examples/src/sms/batches/send.ts +++ b/examples/simple-examples/src/sms/batches/send.ts @@ -13,16 +13,7 @@ import { SendSMSRequestData, TextRequest } from '@sinch/sdk-core'; console.log('***********'); const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); - if (!recipientPhoneNumber) { - throw new Error('No recipient phone number has been provided. ' - + 'Please update your .env file or edit the ./src/sms/batches/send.ts file'); - } - const senderPhoneNumber = getPhoneNumberFromConfig(); - if (!senderPhoneNumber) { - throw new Error('No sender phone number has been provided. ' - + 'Please update your .env file or edit the ./src/sms/batches/send.ts file'); - } const oneDayLater = new Date(); oneDayLater.setDate(oneDayLater.getDate() +1); diff --git a/examples/simple-examples/src/sms/batches/update.ts b/examples/simple-examples/src/sms/batches/update.ts index 839d7949..02d85040 100644 --- a/examples/simple-examples/src/sms/batches/update.ts +++ b/examples/simple-examples/src/sms/batches/update.ts @@ -13,22 +13,8 @@ import { ApiUpdateTextMtMessage, UpdateBatchMessageRequestData } from '@sinch/sd console.log('**********************'); const batchId = getBatchIdFromConfig(); - if (!batchId) { - throw new Error('No batch id has been provided. ' - + 'Please update your .env file or edit the ./src/sms/batches/update.ts file'); - } - const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); - if (!recipientPhoneNumber) { - throw new Error('No recipient phone number has been provided. ' - + 'Please update your .env file or edit the ./src/sms/batches/update.ts file'); - } - const senderPhoneNumber = getPhoneNumberFromConfig(); - if (!senderPhoneNumber) { - throw new Error('No sender phone number has been provided. ' - + 'Please update your .env file or edit the ./src/sms/batches/update.ts file'); - } const requestData: UpdateBatchMessageRequestData= { batch_id: batchId, diff --git a/examples/simple-examples/src/sms/delivery-reports/getByBatchId.ts b/examples/simple-examples/src/sms/delivery-reports/getByBatchId.ts index 5fd01ebd..21a2eb38 100644 --- a/examples/simple-examples/src/sms/delivery-reports/getByBatchId.ts +++ b/examples/simple-examples/src/sms/delivery-reports/getByBatchId.ts @@ -7,10 +7,6 @@ import { GetDeliveryReportByBatchIdRequestData, MessageDeliveryStatus } from '@s console.log('******************************'); const batchId = getBatchIdFromConfig(); - if (!batchId) { - throw new Error('No batch id has been provided. ' - + 'Please update your .env file or edit the ./src/sms/delivery-reports/getByBatchId.ts file'); - } const requestData: GetDeliveryReportByBatchIdRequestData = { batch_id: batchId, diff --git a/examples/simple-examples/src/sms/delivery-reports/getByPhoneNumber.ts b/examples/simple-examples/src/sms/delivery-reports/getByPhoneNumber.ts index c9b61e72..bb092b47 100644 --- a/examples/simple-examples/src/sms/delivery-reports/getByPhoneNumber.ts +++ b/examples/simple-examples/src/sms/delivery-reports/getByPhoneNumber.ts @@ -13,16 +13,7 @@ import { GetDeliveryReportByPhoneNumberRequestData } from '@sinch/sdk-core'; console.log('**********************************'); const batchId = getBatchIdFromConfig(); - if (!batchId) { - throw new Error('No batch id has been provided. ' - + 'Please update your .env file or edit the ./src/sms/delivery-reports/getByPhoneNumber.ts file'); - } - const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); - if (!recipientPhoneNumber) { - throw new Error('No recipient phone number has been provided. ' - + 'Please update your .env file or edit the ./src/sms/delivery-reports/getByPhoneNumber.ts file'); - } const requestData: GetDeliveryReportByPhoneNumberRequestData = { batch_id: batchId, diff --git a/examples/simple-examples/src/sms/groups/delete/delete.ts b/examples/simple-examples/src/sms/groups/delete/delete.ts index 86830053..4ce6bf90 100644 --- a/examples/simple-examples/src/sms/groups/delete/delete.ts +++ b/examples/simple-examples/src/sms/groups/delete/delete.ts @@ -7,10 +7,6 @@ export const deleteGroup = async(sinchClient: SinchClient) => { console.log('***************'); const groupId = getGroupIdFromConfig(); - if (!groupId) { - throw new Error('No group id has been provided. ' - + 'Please update your .env file or edit the ./src/sms/groups/delete.ts file'); - } const requestData: DeleteGroupRequestData = { group_id: groupId, diff --git a/examples/simple-examples/src/sms/groups/get/get.ts b/examples/simple-examples/src/sms/groups/get/get.ts index d075456e..e3df132a 100644 --- a/examples/simple-examples/src/sms/groups/get/get.ts +++ b/examples/simple-examples/src/sms/groups/get/get.ts @@ -7,10 +7,6 @@ export const get = async(sinchClient: SinchClient) => { console.log('*****************'); const groupId = getGroupIdFromConfig(); - if (!groupId) { - throw new Error('No group id has been provided. ' - + 'Please update your .env file or edit the ./src/sms/groups/get.ts file'); - } const requestData: GetGroupRequestData = { group_id: groupId, diff --git a/examples/simple-examples/src/sms/groups/getPhoneNumbers/getPhoneNumbers.ts b/examples/simple-examples/src/sms/groups/getPhoneNumbers/getPhoneNumbers.ts index 5ca37819..69e6c4f1 100644 --- a/examples/simple-examples/src/sms/groups/getPhoneNumbers/getPhoneNumbers.ts +++ b/examples/simple-examples/src/sms/groups/getPhoneNumbers/getPhoneNumbers.ts @@ -7,10 +7,6 @@ export const getPhoneNumbers = async(sinchClient: SinchClient) => { console.log('**************'); const groupId = getGroupIdFromConfig(); - if (!groupId) { - throw new Error('No group id has been provided. ' - + 'Please update your .env file or edit the ./src/sms/groups/getPhoneNumbers.ts file'); - } const requestData: ListMembersRequestData = { group_id: groupId, diff --git a/examples/simple-examples/src/sms/groups/replace/replace.ts b/examples/simple-examples/src/sms/groups/replace/replace.ts index ea5a0b58..9bd16445 100644 --- a/examples/simple-examples/src/sms/groups/replace/replace.ts +++ b/examples/simple-examples/src/sms/groups/replace/replace.ts @@ -7,10 +7,6 @@ export const replace = async(sinchClient: SinchClient) => { console.log('****************'); const groupId = getGroupIdFromConfig(); - if (!groupId) { - throw new Error('No group id has been provided. ' - + 'Please update your .env file or edit the ./src/sms/groups/replace.ts file'); - } const requestData: ReplaceGroupRequestData = { group_id: groupId, diff --git a/examples/simple-examples/src/sms/groups/update/update.ts b/examples/simple-examples/src/sms/groups/update/update.ts index 3844251c..b5430d56 100644 --- a/examples/simple-examples/src/sms/groups/update/update.ts +++ b/examples/simple-examples/src/sms/groups/update/update.ts @@ -7,10 +7,6 @@ export const update = async(sinchClient: SinchClient) => { console.log('***************'); const groupId = getGroupIdFromConfig(); - if (!groupId) { - throw new Error('No group id has been provided. ' - + 'Please update your .env file or edit the ./src/sms/groups/update.ts file'); - } const requestData: UpdateGroupRequestData = { group_id: groupId, diff --git a/examples/simple-examples/src/sms/inbounds/get.ts b/examples/simple-examples/src/sms/inbounds/get.ts index 8a8316ee..347e8387 100644 --- a/examples/simple-examples/src/sms/inbounds/get.ts +++ b/examples/simple-examples/src/sms/inbounds/get.ts @@ -12,10 +12,6 @@ import { GetInboundMessageRequestData } from '@sinch/sdk-core'; console.log('**************************'); const inboundId = getInboundIdFromConfig(); - if (!inboundId) { - throw new Error('No inbound id has been provided. ' - + 'Please update your .env file or edit the ./src/sms/inbounds/get.ts file'); - } const requestData: GetInboundMessageRequestData = { inbound_id: inboundId, diff --git a/examples/simple-examples/src/sms/inbounds/list.ts b/examples/simple-examples/src/sms/inbounds/list.ts index 217ecfe0..abf78b2d 100644 --- a/examples/simple-examples/src/sms/inbounds/list.ts +++ b/examples/simple-examples/src/sms/inbounds/list.ts @@ -24,12 +24,7 @@ const populateInboundMessagesList = ( const oneWeekAgo = new Date(); oneWeekAgo.setDate(oneWeekAgo.getDate() - 7); oneWeekAgo.setHours(0, 0, 0, 0); - const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); - if (!recipientPhoneNumber) { - throw new Error('No recipient phone number has been provided. ' - + 'Please update your .env file or edit the ./src/sms/inbounds/list.ts file'); - } const requestData: ListInboundMessagesRequestData= { start_date: oneWeekAgo, diff --git a/examples/simple-examples/src/verification/verification-status/verification-by-id.ts b/examples/simple-examples/src/verification/verification-status/verification-by-id.ts index 2669dc51..741ac733 100644 --- a/examples/simple-examples/src/verification/verification-status/verification-by-id.ts +++ b/examples/simple-examples/src/verification/verification-status/verification-by-id.ts @@ -2,7 +2,7 @@ import { VerificationStatusByIdRequestData } from '@sinch/sdk-core'; import { getPrintFormat, getVerificationIdFromConfig, - initVerificationClient, + initApplicationClient, printFullResponse, } from '../../config'; @@ -12,16 +12,12 @@ import { console.log('**************************'); const verificationId = getVerificationIdFromConfig(); - if (!verificationId) { - throw new Error('No verification id has been provided. ' - + 'Please update your .env file or edit the ./src/verification/verification-status/verification-by-id.ts file'); - } const requestData: VerificationStatusByIdRequestData = { id: verificationId, }; - const sinchClient = initVerificationClient(); + const sinchClient = initApplicationClient(); let response; try { response = await sinchClient.verification.verificationStatus.getById(requestData); diff --git a/examples/simple-examples/src/verification/verification-status/verification-by-identity.ts b/examples/simple-examples/src/verification/verification-status/verification-by-identity.ts index 9715dfed..eecc064a 100644 --- a/examples/simple-examples/src/verification/verification-status/verification-by-identity.ts +++ b/examples/simple-examples/src/verification/verification-status/verification-by-identity.ts @@ -1,5 +1,5 @@ import { VerificationStatusByIdentityRequestData } from '@sinch/sdk-core'; -import { getPrintFormat, getVerificationIdentityFromConfig, initVerificationClient, printFullResponse } from '../../config'; +import { getPrintFormat, getVerificationIdentityFromConfig, initApplicationClient, printFullResponse } from '../../config'; (async () => { console.log('********************************'); @@ -7,18 +7,13 @@ import { getPrintFormat, getVerificationIdentityFromConfig, initVerificationClie console.log('********************************'); const verificationIdentity = getVerificationIdentityFromConfig(); - if (!verificationIdentity) { - throw new Error('No verification identity has been provided. ' - + 'Please update your .env file ' - + 'or edit the ./src/verification/verification-status/verification-by-identity.ts file'); - } const requestData: VerificationStatusByIdentityRequestData = { endpoint: verificationIdentity, method: 'sms', }; - const sinchClient = initVerificationClient(); + const sinchClient = initApplicationClient(); let response; try { response = await sinchClient.verification.verificationStatus.getByIdentity(requestData); diff --git a/examples/simple-examples/src/verification/verification-status/verification-by-reference.ts b/examples/simple-examples/src/verification/verification-status/verification-by-reference.ts index 2608c190..30b247b8 100644 --- a/examples/simple-examples/src/verification/verification-status/verification-by-reference.ts +++ b/examples/simple-examples/src/verification/verification-status/verification-by-reference.ts @@ -2,7 +2,7 @@ import { VerificationStatusByReferenceRequestData } from '@sinch/sdk-core'; import { getPrintFormat, getVerificationReferenceFromConfig, - initVerificationClient, + initApplicationClient, printFullResponse, } from '../../config'; @@ -12,17 +12,12 @@ import { console.log('*********************************'); const verificationReference = getVerificationReferenceFromConfig(); - if (!verificationReference) { - throw new Error('No verification reference has been provided. ' - + 'Please update your .env file ' - + 'or edit the ./src/verification/verification-status/verification-by-reference.ts file'); - } const requestData: VerificationStatusByReferenceRequestData = { reference: verificationReference, }; - const sinchClient = initVerificationClient(); + const sinchClient = initApplicationClient(); let response; try { response = await sinchClient.verification.verificationStatus.getByReference(requestData); diff --git a/examples/simple-examples/src/verification/verifications/callout/report-with-id_callout.ts b/examples/simple-examples/src/verification/verifications/callout/report-with-id_callout.ts index c7bb1be1..267bc6f0 100644 --- a/examples/simple-examples/src/verification/verifications/callout/report-with-id_callout.ts +++ b/examples/simple-examples/src/verification/verifications/callout/report-with-id_callout.ts @@ -11,16 +11,7 @@ import { reportWithId } from '../report-with-id'; console.log('************************************'); const verificationId = getVerificationIdFromConfig(); - if (!verificationId) { - throw new Error('No verification id has been provided. Please update your .env file ' - + 'or edit the ./src/verification/verifications/callout/report-with-id_callout.ts file'); - } - const verificationCode = getVerificationCodeFromConfig(); - if (!verificationCode) { - throw new Error('No verification code has been provided. Please update your .env file ' - + 'or edit the ./src/verification/verifications/callout/report-with-id_callout.ts file'); - } const requestData: ReportVerificationByIdRequestData = { id: verificationId, diff --git a/examples/simple-examples/src/verification/verifications/callout/report-with-identity_callout.ts b/examples/simple-examples/src/verification/verifications/callout/report-with-identity_callout.ts index fe39b702..cd4802e1 100644 --- a/examples/simple-examples/src/verification/verifications/callout/report-with-identity_callout.ts +++ b/examples/simple-examples/src/verification/verifications/callout/report-with-identity_callout.ts @@ -11,16 +11,7 @@ import { reportWithIdentity } from '../report-with-identity'; console.log('******************************************'); const verificationIdentity = getVerificationIdentityFromConfig(); - if (!verificationIdentity) { - throw new Error('No verification identity has been provided. Please update your .env file ' - + 'or edit the ./src/verification/verifications/callout/report-with-identity_callout.ts file'); - } - const verificationCode = getVerificationCodeFromConfig(); - if (!verificationCode) { - throw new Error('No verification code has been provided. Please update your .env file ' - + 'or edit the ./src/verification/verifications/callout/report-with-identity_callout.ts file'); - } const requestData: ReportVerificationByIdentityRequestData = { endpoint: verificationIdentity, diff --git a/examples/simple-examples/src/verification/verifications/callout/start-callout.ts b/examples/simple-examples/src/verification/verifications/callout/start-callout.ts index a27fb95a..979b0ae4 100644 --- a/examples/simple-examples/src/verification/verifications/callout/start-callout.ts +++ b/examples/simple-examples/src/verification/verifications/callout/start-callout.ts @@ -8,10 +8,6 @@ import { getVerificationIdentityFromConfig } from '../../../config'; console.log('*******************************'); const verificationIdentity = getVerificationIdentityFromConfig(); - if (!verificationIdentity) { - throw new Error('No verification identity has been provided. ' - + 'Please update your .env file or edit the ./src/verification/verifications/callout/start-callout.ts file'); - } const requestData: StartVerificationRequestData = { initiateVerificationRequestBody: { diff --git a/examples/simple-examples/src/verification/verifications/flashcall/report-with-id_flashcall.ts b/examples/simple-examples/src/verification/verifications/flashcall/report-with-id_flashcall.ts index 488518ed..04b6bd4f 100644 --- a/examples/simple-examples/src/verification/verifications/flashcall/report-with-id_flashcall.ts +++ b/examples/simple-examples/src/verification/verifications/flashcall/report-with-id_flashcall.ts @@ -11,16 +11,7 @@ import { reportWithId } from '../report-with-id'; console.log('***************************************'); const verificationId = getVerificationIdFromConfig(); - if (!verificationId) { - throw new Error('No verification id has been provided. Please update your .env file ' - + 'or edit the ./src/verification/verifications/flashcall/report-with-id_flashcall.ts file'); - } - const verificationCli = getVerificationCliFromConfig(); - if (!verificationCli) { - throw new Error('No verification CLI has been provided. Please update your .env file ' - + 'or edit the ./src/verification/verifications/flashcall/report-with-id_flashcall.ts file'); - } const requestData: ReportVerificationByIdRequestData = { id: verificationId, diff --git a/examples/simple-examples/src/verification/verifications/flashcall/report-with-identity_flashcall.ts b/examples/simple-examples/src/verification/verifications/flashcall/report-with-identity_flashcall.ts index 5c35a8ad..7a04e4be 100644 --- a/examples/simple-examples/src/verification/verifications/flashcall/report-with-identity_flashcall.ts +++ b/examples/simple-examples/src/verification/verifications/flashcall/report-with-identity_flashcall.ts @@ -11,16 +11,7 @@ import { reportWithIdentity } from '../report-with-identity'; console.log('*********************************************'); const verificationIdentity = getVerificationIdentityFromConfig(); - if (!verificationIdentity) { - throw new Error('No verification identity has been provided. Please update your .env file ' - + 'or edit the ./src/verification/verifications/flashcall/report-with-identity_flashcall.ts file'); - } - const verificationCli = getVerificationCliFromConfig(); - if (!verificationCli) { - throw new Error('No verification CLI has been provided. Please update your .env file ' - + 'or edit the ./src/verification/verifications/flashcall/report-with-identity_flashcall.ts file'); - } const requestData: ReportVerificationByIdentityRequestData = { endpoint: verificationIdentity, diff --git a/examples/simple-examples/src/verification/verifications/flashcall/start-flashcall.ts b/examples/simple-examples/src/verification/verifications/flashcall/start-flashcall.ts index 76465263..8cbe7a90 100644 --- a/examples/simple-examples/src/verification/verifications/flashcall/start-flashcall.ts +++ b/examples/simple-examples/src/verification/verifications/flashcall/start-flashcall.ts @@ -8,10 +8,6 @@ import { getVerificationIdentityFromConfig } from '../../../config'; console.log('*********************************'); const verificationIdentity = getVerificationIdentityFromConfig(); - if (!verificationIdentity) { - throw new Error('No verification identity has been provided. ' - + 'Please update your .env file or edit the ./src/verification/verifications/flashcall/start-flashcall.ts file'); - } const requestData: StartVerificationRequestData = { initiateVerificationRequestBody: { diff --git a/examples/simple-examples/src/verification/verifications/report-with-id.ts b/examples/simple-examples/src/verification/verifications/report-with-id.ts index 2be61f42..4de9106f 100644 --- a/examples/simple-examples/src/verification/verifications/report-with-id.ts +++ b/examples/simple-examples/src/verification/verifications/report-with-id.ts @@ -1,8 +1,8 @@ import { ReportVerificationByIdRequestData } from '@sinch/sdk-core'; -import { getPrintFormat, initVerificationClient, printFullResponse } from '../../config'; +import { getPrintFormat, initApplicationClient, printFullResponse } from '../../config'; export const reportWithId = async (requestData: ReportVerificationByIdRequestData) => { - const sinchClient = initVerificationClient(); + const sinchClient = initApplicationClient(); let response; try { response = await sinchClient.verification.verifications.reportById(requestData); diff --git a/examples/simple-examples/src/verification/verifications/report-with-identity.ts b/examples/simple-examples/src/verification/verifications/report-with-identity.ts index 59225067..9ed15f9a 100644 --- a/examples/simple-examples/src/verification/verifications/report-with-identity.ts +++ b/examples/simple-examples/src/verification/verifications/report-with-identity.ts @@ -1,8 +1,8 @@ import { ReportVerificationByIdentityRequestData } from '@sinch/sdk-core'; -import { getPrintFormat, initVerificationClient, printFullResponse } from '../../config'; +import { getPrintFormat, initApplicationClient, printFullResponse } from '../../config'; export const reportWithIdentity = async (requestData: ReportVerificationByIdentityRequestData) => { - const sinchClient = initVerificationClient(); + const sinchClient = initApplicationClient(); let response; try { response = await sinchClient.verification.verifications.reportByIdentity(requestData); diff --git a/examples/simple-examples/src/verification/verifications/seamless/start-seamless.ts b/examples/simple-examples/src/verification/verifications/seamless/start-seamless.ts index 9fc4dc66..504759e6 100644 --- a/examples/simple-examples/src/verification/verifications/seamless/start-seamless.ts +++ b/examples/simple-examples/src/verification/verifications/seamless/start-seamless.ts @@ -8,10 +8,6 @@ import { getVerificationIdentityFromConfig } from '../../../config'; console.log('********************************'); const verificationIdentity = getVerificationIdentityFromConfig(); - if (!verificationIdentity) { - throw new Error('No verification identity has been provided. ' - + 'Please update your .env file or edit the ./src/verification/verifications/seamless/start-seamless.ts file'); - } const requestData: StartVerificationRequestData = { initiateVerificationRequestBody: { diff --git a/examples/simple-examples/src/verification/verifications/sms/report-with-id_sms.ts b/examples/simple-examples/src/verification/verifications/sms/report-with-id_sms.ts index af422324..4236989e 100644 --- a/examples/simple-examples/src/verification/verifications/sms/report-with-id_sms.ts +++ b/examples/simple-examples/src/verification/verifications/sms/report-with-id_sms.ts @@ -11,16 +11,7 @@ import { reportWithId } from '../report-with-id'; console.log('*********************************'); const verificationId = getVerificationIdFromConfig(); - if (!verificationId) { - throw new Error('No verification id has been provided. Please update your .env file ' - + 'or edit the ./src/verification/verifications/sms/report-with-id_sms.ts file'); - } - const verificationCode = getVerificationCodeFromConfig(); - if (!verificationCode) { - throw new Error('No verification code has been provided. Please update your .env file ' - + 'or edit the ./src/verification/verifications/sms/report-with-id_sms.ts file'); - } const requestData: ReportVerificationByIdRequestData = { id: verificationId, diff --git a/examples/simple-examples/src/verification/verifications/sms/report-with-identity_sms.ts b/examples/simple-examples/src/verification/verifications/sms/report-with-identity_sms.ts index 72c86bce..1a02f468 100644 --- a/examples/simple-examples/src/verification/verifications/sms/report-with-identity_sms.ts +++ b/examples/simple-examples/src/verification/verifications/sms/report-with-identity_sms.ts @@ -11,16 +11,7 @@ import { reportWithIdentity } from '../report-with-identity'; console.log('***************************************'); const verificationIdentity = getVerificationIdentityFromConfig(); - if (!verificationIdentity) { - throw new Error('No verification identity has been provided. Please update your .env file ' - + 'or edit the ./src/verification/verifications/sms/report-with-identity_sms.ts file'); - } - const verificationCode = getVerificationCodeFromConfig(); - if (!verificationCode) { - throw new Error('No verification code has been provided. Please update your .env file ' - + 'or edit the ./src/verification/verifications/sms/report-with-identity_sms.ts file'); - } const requestData: ReportVerificationByIdentityRequestData = { endpoint: verificationIdentity, diff --git a/examples/simple-examples/src/verification/verifications/sms/start_sms.ts b/examples/simple-examples/src/verification/verifications/sms/start_sms.ts index 0a1e6c5c..0452a17d 100644 --- a/examples/simple-examples/src/verification/verifications/sms/start_sms.ts +++ b/examples/simple-examples/src/verification/verifications/sms/start_sms.ts @@ -8,10 +8,6 @@ import { getVerificationIdentityFromConfig } from '../../../config'; console.log('***************************'); const verificationIdentity = getVerificationIdentityFromConfig(); - if (!verificationIdentity) { - throw new Error('No verification identity has been provided. ' - + 'Please update your .env file or edit the ./src/verification/verifications/sms/start_sms.ts file'); - } const requestData: StartVerificationRequestData = { initiateVerificationRequestBody: { diff --git a/examples/simple-examples/src/verification/verifications/start.ts b/examples/simple-examples/src/verification/verifications/start.ts index fdedd375..59b4fe8f 100644 --- a/examples/simple-examples/src/verification/verifications/start.ts +++ b/examples/simple-examples/src/verification/verifications/start.ts @@ -1,8 +1,8 @@ import { StartVerificationRequestData } from '@sinch/sdk-core'; -import { getPrintFormat, initVerificationClient, printFullResponse } from '../../config'; +import { getPrintFormat, initApplicationClient, printFullResponse } from '../../config'; export const startVerification = async (requestData: StartVerificationRequestData) => { - const sinchClient = initVerificationClient(); + const sinchClient = initApplicationClient(); let response; try { response = await sinchClient.verification.verifications.start(requestData); diff --git a/examples/simple-examples/src/voice/applications/assignNumbers.ts b/examples/simple-examples/src/voice/applications/assignNumbers.ts new file mode 100644 index 00000000..c326af94 --- /dev/null +++ b/examples/simple-examples/src/voice/applications/assignNumbers.ts @@ -0,0 +1,29 @@ +import { getApplicationKeyFromConfig, getPhoneNumberFromConfig, initApplicationClient } from '../../config'; +import { AssignNumbersRequestData } from '@sinch/sdk-core'; + +(async () => { + console.log('*****************'); + console.log('* UpdateNumbers *'); + console.log('*****************'); + + const phoneNumber = getPhoneNumberFromConfig(); + const applicationKey = getApplicationKeyFromConfig(); + + const requestData: AssignNumbersRequestData = { + assignNumbersRequestBody: { + numbers: [phoneNumber], + applicationkey: applicationKey, + capability: 'voice', + }, + }; + + const sinchClient = initApplicationClient(); + try { + await sinchClient.voice.applications.assignNumbers(requestData); + } catch (error) { + console.log(`Impossible to assign the numbers '${requestData.assignNumbersRequestBody?.numbers}' to the application '${requestData.assignNumbersRequestBody?.applicationkey}'`); + throw error; + } + + console.log(`The numbers '${requestData.assignNumbersRequestBody?.numbers}' have been assigned to the application '${requestData.assignNumbersRequestBody?.applicationkey}' successfully`); +})(); diff --git a/examples/simple-examples/src/voice/applications/getCallbackURLs.ts b/examples/simple-examples/src/voice/applications/getCallbackURLs.ts new file mode 100644 index 00000000..f8fedeec --- /dev/null +++ b/examples/simple-examples/src/voice/applications/getCallbackURLs.ts @@ -0,0 +1,36 @@ +import { + getApplicationKeyFromConfig, + getPrintFormat, + initApplicationClient, + printFullResponse, +} from '../../config'; +import { GetCallbackURLsRequestData } from '@sinch/sdk-core'; + +(async () => { + console.log('*******************'); + console.log('* GetCallbackURLs *'); + console.log('*******************'); + + const applicationKey = getApplicationKeyFromConfig(); + + const requestData: GetCallbackURLsRequestData = { + applicationkey: applicationKey, + }; + + const sinchClient = initApplicationClient(); + let response; + try { + response = await sinchClient.voice.applications.getCallbackURLs(requestData); + } catch (error) { + console.log(`Impossible to retrieve the callback URLs for the application '${requestData.applicationkey}'`); + throw error; + } + + const printFormat = getPrintFormat(process.argv); + + if (printFormat === 'pretty') { + console.log(`The primary callback URL is [${response.url?.primary}]. ${response.url?.fallback ? 'The fallback URL is [' + response.url.fallback + ']' : 'There is no fallback URL'}`); + } else { + printFullResponse(response); + } +})(); diff --git a/examples/simple-examples/src/voice/applications/getNumbers.ts b/examples/simple-examples/src/voice/applications/getNumbers.ts new file mode 100644 index 00000000..1df4a0d2 --- /dev/null +++ b/examples/simple-examples/src/voice/applications/getNumbers.ts @@ -0,0 +1,27 @@ +import { getPrintFormat, initApplicationClient, printFullResponse } from '../../config'; +import { GetNumbersRequestData } from '@sinch/sdk-core'; + +(async () => { + console.log('**************'); + console.log('* GetNumbers *'); + console.log('**************'); + + const requestData: GetNumbersRequestData = {}; + + const sinchClient = initApplicationClient(); + let response; + try { + response = await sinchClient.voice.applications.getNumbers(requestData); + } catch (error) { + console.log(`Impossible to get information about your numbers`); + throw error; + } + + const printFormat = getPrintFormat(process.argv); + + if (printFormat === 'pretty') { + console.log(`You have ${response.numbers?.length} numbers: ${response.numbers?.map((number) => number.number).join(',')}`); + } else { + printFullResponse(response); + } +})(); diff --git a/examples/simple-examples/src/voice/applications/queryNumber.ts b/examples/simple-examples/src/voice/applications/queryNumber.ts new file mode 100644 index 00000000..afe78c55 --- /dev/null +++ b/examples/simple-examples/src/voice/applications/queryNumber.ts @@ -0,0 +1,31 @@ +import { getPhoneNumberFromConfig, getPrintFormat, initApplicationClient, printFullResponse } from '../../config'; +import { QueryNumberRequestData } from '@sinch/sdk-core'; + +(async () => { + console.log('***********************'); + console.log('* Calling_QueryNumber *'); + console.log('***********************'); + + const phoneNumber = getPhoneNumberFromConfig(); + + const requestData: QueryNumberRequestData = { + number: phoneNumber, + }; + + const sinchClient = initApplicationClient(); + let response; + try { + response = await sinchClient.voice.applications.queryNumber(requestData); + } catch (error) { + console.log(`Impossible to get information about the number ${requestData.number}`); + throw error; + } + + const printFormat = getPrintFormat(process.argv); + + if (printFormat === 'pretty') { + console.log(`The number '${response.number?.normalizedNumber}' is of type "${response.number?.numberType}"\nRate: ${response.number?.rate?.amount} ${response.number?.rate?.currencyId}`); + } else { + printFullResponse(response); + } +})(); diff --git a/examples/simple-examples/src/voice/applications/unassignNumber.ts b/examples/simple-examples/src/voice/applications/unassignNumber.ts new file mode 100644 index 00000000..a4a78399 --- /dev/null +++ b/examples/simple-examples/src/voice/applications/unassignNumber.ts @@ -0,0 +1,29 @@ +import { getApplicationKeyFromConfig, getPhoneNumberFromConfig, initApplicationClient } from '../../config'; +import { UnassignNumberRequestData } from '@sinch/sdk-core'; + +(async () => { + console.log('******************'); + console.log('* UnassignNumber *'); + console.log('******************'); + + const phoneNumber = getPhoneNumberFromConfig(); + const applicationKey = getApplicationKeyFromConfig(); + + const requestData: UnassignNumberRequestData = { + unassignNumbersRequestBody: { + number: phoneNumber, + applicationkey: applicationKey, + capability: 'voice', + }, + }; + + const sinchClient = initApplicationClient(); + try { + await sinchClient.voice.applications.unassignNumber(requestData); + } catch (error) { + console.log(`Impossible to unassign the number '${requestData.unassignNumbersRequestBody?.number}' from the application '${requestData.unassignNumbersRequestBody?.applicationkey}'`); + throw error; + } + + console.log(`The number '${requestData.unassignNumbersRequestBody?.number}' has been unassigned from the application '${requestData.unassignNumbersRequestBody?.applicationkey}'`); +})(); diff --git a/examples/simple-examples/src/voice/applications/updateCallbackURLs.ts b/examples/simple-examples/src/voice/applications/updateCallbackURLs.ts new file mode 100644 index 00000000..f1ff4b65 --- /dev/null +++ b/examples/simple-examples/src/voice/applications/updateCallbackURLs.ts @@ -0,0 +1,34 @@ +import { + getApplicationKeyFromConfig, + initApplicationClient, +} from '../../config'; +import { UpdateCallbackURLsRequestData } from '@sinch/sdk-core'; + +(async () => { + console.log('**********************'); + console.log('* UpdateCallbackURLs *'); + console.log('**********************'); + + const applicationKey = getApplicationKeyFromConfig(); + + const requestData: UpdateCallbackURLsRequestData = { + applicationkey: applicationKey, + updateCallbacksRequestBody: { + url: { + primary: 'https://new-primary-callback-url.com', + fallback: 'https://new-fallback-callback-url.com', + }, + }, + }; + + const sinchClient = initApplicationClient(); + try { + await sinchClient.voice.applications.updateCallbackURLs(requestData); + } catch (error) { + console.log(`Impossible to update the callback URLs for the application '${requestData.applicationkey}'`); + throw error; + } + + console.log(`The callback URLS of the application '${requestData.applicationkey}' have been updated successfully`); + +})(); diff --git a/examples/simple-examples/src/voice/callouts/conference.ts b/examples/simple-examples/src/voice/callouts/conference.ts new file mode 100644 index 00000000..829cce8b --- /dev/null +++ b/examples/simple-examples/src/voice/callouts/conference.ts @@ -0,0 +1,51 @@ +import { + getConferenceIdFromConfig, getPhoneNumberFromConfig, + getPrintFormat, + getRecipientPhoneNumberFromConfig, + initApplicationClient, + printFullResponse, +} from '../../config'; +import { ConferenceCalloutRequestData, VoiceRegion } from '@sinch/sdk-core'; + +(async () => { + console.log('*************************'); + console.log('* Callouts - Conference *'); + console.log('*************************'); + + const callingNumber = getPhoneNumberFromConfig(); + const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); + const conferenceId = getConferenceIdFromConfig(); + + const requestData: ConferenceCalloutRequestData = { + conferenceCalloutRequestBody: { + method: 'conferenceCallout', + conferenceCallout: { + conferenceId, + cli: callingNumber, + destination: { + type: 'number', + endpoint: recipientPhoneNumber, + }, + locale: 'en-US', + }, + }, + }; + + const sinchClient = initApplicationClient(); + sinchClient.voice.setRegion(VoiceRegion.EUROPE); + let response; + try { + response = await sinchClient.voice.callouts.conference(requestData); + } catch (error) { + console.log(`Impossible to make a Conference callout to '${requestData.conferenceCalloutRequestBody?.conferenceCallout.destination.endpoint}'`); + throw error; + } + + const printFormat = getPrintFormat(process.argv); + + if (printFormat === 'pretty') { + console.log(`The Conference callout was successful. Id = ${response.callId}`); + } else { + printFullResponse(response); + } +})(); diff --git a/examples/simple-examples/src/voice/callouts/custom.ts b/examples/simple-examples/src/voice/callouts/custom.ts new file mode 100644 index 00000000..1d4eacda --- /dev/null +++ b/examples/simple-examples/src/voice/callouts/custom.ts @@ -0,0 +1,48 @@ +import { + getPhoneNumberFromConfig, + getPrintFormat, + getRecipientPhoneNumberFromConfig, + initApplicationClient, + printFullResponse, +} from '../../config'; +import { CustomCalloutRequestData, VoiceRegion } from '@sinch/sdk-core'; + +(async () => { + console.log('*********************'); + console.log('* Callouts - Custom *'); + console.log('*********************'); + + const callingNumber = getPhoneNumberFromConfig(); + const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); + + const requestData: CustomCalloutRequestData = { + customCalloutRequestBody: { + method: 'customCallout', + customCallout: { + cli: callingNumber, + destination: { + type: 'number', + endpoint: recipientPhoneNumber, + }, + }, + }, + }; + + const sinchClient = initApplicationClient(); + sinchClient.voice.setRegion(VoiceRegion.EUROPE); + let response; + try { + response = await sinchClient.voice.callouts.custom(requestData); + } catch (error) { + console.log(`Impossible to make a Custom callout to '${requestData.customCalloutRequestBody?.customCallout.destination?.endpoint}'`); + throw error; + } + + const printFormat = getPrintFormat(process.argv); + + if (printFormat === 'pretty') { + console.log(`The Custom callout was successful. Id = ${response.callId}`); + } else { + printFullResponse(response); + } +})(); diff --git a/examples/simple-examples/src/voice/callouts/tts.ts b/examples/simple-examples/src/voice/callouts/tts.ts new file mode 100644 index 00000000..fb3adfb9 --- /dev/null +++ b/examples/simple-examples/src/voice/callouts/tts.ts @@ -0,0 +1,50 @@ +import { + getPhoneNumberFromConfig, + getPrintFormat, + getRecipientPhoneNumberFromConfig, + initApplicationClient, + printFullResponse, +} from '../../config'; +import { TtsCalloutRequestData, VoiceRegion } from '@sinch/sdk-core'; + +(async () => { + console.log('******************'); + console.log('* Callouts - TTS *'); + console.log('******************'); + + const callingNumber = getPhoneNumberFromConfig(); + const recipientPhoneNumber = getRecipientPhoneNumberFromConfig(); + + const requestData: TtsCalloutRequestData = { + ttsCalloutRequestBody: { + method: 'ttsCallout', + ttsCallout: { + cli: callingNumber, + destination: { + type: 'number', + endpoint: recipientPhoneNumber, + }, + locale: 'en-US', + text: 'Hello, this is a call from Sinch', + }, + }, + }; + + const sinchClient = initApplicationClient(); + sinchClient.voice.setRegion(VoiceRegion.EUROPE); + let response; + try { + response = await sinchClient.voice.callouts.tts(requestData); + } catch (error) { + console.log(`Impossible to make a TTS callout to '${requestData.ttsCalloutRequestBody?.ttsCallout.destination.endpoint}'`); + throw error; + } + + const printFormat = getPrintFormat(process.argv); + + if (printFormat === 'pretty') { + console.log(`The TTS callout was successful. Id = ${response.callId}`); + } else { + printFullResponse(response); + } +})(); diff --git a/examples/simple-examples/src/voice/calls/get.ts b/examples/simple-examples/src/voice/calls/get.ts new file mode 100644 index 00000000..74bde732 --- /dev/null +++ b/examples/simple-examples/src/voice/calls/get.ts @@ -0,0 +1,39 @@ +import { + getCallIdFromConfig, + getPrintFormat, + initApplicationClient, + printFullResponse, +} from '../../config'; +import { GetCallResultRequestData, VoiceRegion } from '@sinch/sdk-core'; + +(async () => { + console.log('******************'); + console.log('* GetCallResult *'); + console.log('******************'); + + const callId = getCallIdFromConfig(); + + const requestData: GetCallResultRequestData = { + callId, + }; + + const sinchClient = initApplicationClient(); + sinchClient.voice.setRegion(VoiceRegion.EUROPE); + let response; + try { + response = await sinchClient.voice.calls.get(requestData); + } catch (error) { + console.log(`Impossible get information about call Id ${requestData.callId}`); + throw error; + } + + const printFormat = getPrintFormat(process.argv); + + if (printFormat === 'pretty') { + // TODO: Add a post process on the response to fix the missing timezone in the timestamp + console.log(`The call '${response.callId}' was from '${response.from}' to '${response.to?.endpoint}' and lasted ${response.duration} seconds + Rate: ${response.userRate?.amount} ${response.userRate?.currencyId} - Debit: ${response.debit?.amount} ${response.debit?.currencyId}`); + } else { + printFullResponse(response); + } +})(); diff --git a/examples/simple-examples/src/voice/calls/manageWithCallLeg.ts b/examples/simple-examples/src/voice/calls/manageWithCallLeg.ts new file mode 100644 index 00000000..600c3d94 --- /dev/null +++ b/examples/simple-examples/src/voice/calls/manageWithCallLeg.ts @@ -0,0 +1,41 @@ +import { + getCallIdFromConfig, + initApplicationClient, +} from '../../config'; +import { ManageWithCallLegRequestData, VoiceRegion } from '@sinch/sdk-core'; + +(async () => { + console.log('*************************'); + console.log('* ManageCallWithCallLeg *'); + console.log('*************************'); + + const callId = getCallIdFromConfig(); + + const requestData: ManageWithCallLegRequestData = { + callId, + callLeg: 'callee', + svamlRequestBody: { + instructions: [ + { + name: 'say', + text: 'Hello, the call is over, hanging up now. Goodbye', + }, + ], + action: { + name: 'hangup', + }, + }, + }; + + const sinchClient = initApplicationClient(); + sinchClient.voice.setRegion(VoiceRegion.EUROPE); + try { + await sinchClient.voice.calls.manageWithCallLeg(requestData); + } catch (error) { + console.log(`Impossible manage with call leg the call Id ${requestData.callId}`); + throw error; + } + + console.log(`The call '${requestData.callId}' has been managed successfully with a call leg`); + +})(); diff --git a/examples/simple-examples/src/voice/calls/update.ts b/examples/simple-examples/src/voice/calls/update.ts new file mode 100644 index 00000000..178003f8 --- /dev/null +++ b/examples/simple-examples/src/voice/calls/update.ts @@ -0,0 +1,40 @@ +import { + getCallIdFromConfig, + initApplicationClient, +} from '../../config'; +import { UpdateCallRequestData, VoiceRegion } from '@sinch/sdk-core'; + +(async () => { + console.log('**************'); + console.log('* UpdateCall *'); + console.log('**************'); + + const callId = getCallIdFromConfig(); + + const requestData: UpdateCallRequestData = { + callId, + svamlRequestBody: { + instructions: [ + { + name: 'sendDtmf', + value: '1234#', + }, + ], + action: { + name: 'hangup', + }, + }, + }; + + const sinchClient = initApplicationClient(); + sinchClient.voice.setRegion(VoiceRegion.EUROPE); + try { + await sinchClient.voice.calls.update(requestData); + } catch (error) { + console.log(`Impossible update the call Id '${requestData.callId}'`); + throw error; + } + + console.log(`The call '${requestData.callId}' has been updated successfully`); + +})(); diff --git a/examples/simple-examples/src/voice/conferences/get.ts b/examples/simple-examples/src/voice/conferences/get.ts new file mode 100644 index 00000000..6d3cf59f --- /dev/null +++ b/examples/simple-examples/src/voice/conferences/get.ts @@ -0,0 +1,37 @@ +import { + getConferenceIdFromConfig, + getPrintFormat, + initApplicationClient, + printFullResponse, +} from '../../config'; +import { GetConferenceInfoRequestData, VoiceRegion } from '@sinch/sdk-core'; + +(async () => { + console.log('*********************'); + console.log('* GetConferenceInfo *'); + console.log('*********************'); + + const conferenceId = getConferenceIdFromConfig(); + + const requestData: GetConferenceInfoRequestData = { + conferenceId, + }; + + const sinchClient = initApplicationClient(); + sinchClient.voice.setRegion(VoiceRegion.EUROPE); + let response; + try { + response = await sinchClient.voice.conferences.get(requestData); + } catch (error) { + console.log(`Impossible get information about conference Id '${requestData.conferenceId}'`); + throw error; + } + + const printFormat = getPrintFormat(process.argv); + + if (printFormat === 'pretty') { + console.log(`The conference contains ${response.participants?.length} participants: ${response.participants?.map((participant) => participant.id).join(',')}`); + } else { + printFullResponse(response); + } +})(); diff --git a/examples/simple-examples/src/voice/conferences/kickAll.ts b/examples/simple-examples/src/voice/conferences/kickAll.ts new file mode 100644 index 00000000..0579da60 --- /dev/null +++ b/examples/simple-examples/src/voice/conferences/kickAll.ts @@ -0,0 +1,29 @@ +import { + getConferenceIdFromConfig, + initApplicationClient, +} from '../../config'; +import { KickAllRequestData, VoiceRegion } from '@sinch/sdk-core'; + +(async () => { + console.log('*********************'); + console.log('* KickConferenceAll *'); + console.log('*********************'); + + const conferenceId = getConferenceIdFromConfig(); + + const requestData: KickAllRequestData = { + conferenceId, + }; + + const sinchClient = initApplicationClient(); + sinchClient.voice.setRegion(VoiceRegion.EUROPE); + try { + await sinchClient.voice.conferences.kickAll(requestData); + } catch (error) { + console.log(`Impossible kick all participants from conference id '${requestData.conferenceId}'`); + throw error; + } + + console.log(`All the participants have been successfully kicked from the conference id '${requestData.conferenceId}'`); + +})(); diff --git a/examples/simple-examples/src/voice/conferences/kickParticipant.ts b/examples/simple-examples/src/voice/conferences/kickParticipant.ts new file mode 100644 index 00000000..106d0b37 --- /dev/null +++ b/examples/simple-examples/src/voice/conferences/kickParticipant.ts @@ -0,0 +1,32 @@ +import { + getCallIdFromConfig, + getConferenceIdFromConfig, + initApplicationClient, +} from '../../config'; +import { KickParticipantRequestData, VoiceRegion } from '@sinch/sdk-core'; + +(async () => { + console.log('*****************************'); + console.log('* KickConferenceParticipant *'); + console.log('*****************************'); + + const conferenceId = getConferenceIdFromConfig(); + const callId = getCallIdFromConfig(); + + const requestData: KickParticipantRequestData = { + conferenceId, + callId, + }; + + const sinchClient = initApplicationClient(); + sinchClient.voice.setRegion(VoiceRegion.EUROPE); + try { + await sinchClient.voice.conferences.kickParticipant(requestData); + } catch (error) { + console.log(`Impossible kick the participant '${requestData.callId}' from conference id '${requestData.conferenceId}'`); + throw error; + } + + console.log(`The participant '${requestData.callId}' has been successfully kicked from the conference id '${requestData.conferenceId}'`); + +})(); diff --git a/examples/simple-examples/src/voice/conferences/manageParticipant.ts b/examples/simple-examples/src/voice/conferences/manageParticipant.ts new file mode 100644 index 00000000..b3e6c187 --- /dev/null +++ b/examples/simple-examples/src/voice/conferences/manageParticipant.ts @@ -0,0 +1,36 @@ +import { + getCallIdFromConfig, + getConferenceIdFromConfig, + initApplicationClient, +} from '../../config'; +import { ManageParticipantRequestData, VoiceRegion } from '@sinch/sdk-core'; + +(async () => { + console.log('*******************************'); + console.log('* ManageConferenceParticipant *'); + console.log('*******************************'); + + const conferenceId = getConferenceIdFromConfig(); + const callId = getCallIdFromConfig(); + + const requestData: ManageParticipantRequestData = { + conferenceId, + callId, + manageParticipantRequestBody: { + command: 'mute', + moh: 'music1', + }, + }; + + const sinchClient = initApplicationClient(); + sinchClient.voice.setRegion(VoiceRegion.EUROPE); + try { + await sinchClient.voice.conferences.manageParticipant(requestData); + } catch (error) { + console.log(`Impossible manage the participant '${requestData.callId}' with conference id '${requestData.conferenceId}'`); + throw error; + } + + console.log(`The participant '${requestData.callId}' has been successfully managed with the conference id '${requestData.conferenceId}'`); + +})(); diff --git a/jest.config.ts b/jest.config.ts index abfc5a28..21e88f3e 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -24,6 +24,11 @@ const config: Config.InitialOptions = { testMatch: ['/packages/verification/tests/**/*.test.ts'], coveragePathIgnorePatterns: ['node_modules', 'tests'], }, + { + displayName: 'Voice', + testMatch: ['/packages/voice/tests/**/*.test.ts'], + coveragePathIgnorePatterns: ['node_modules', 'tests'], + }, ], moduleNameMapper: { '@sinch/(.+)': '/packages/$1/src', diff --git a/packages/sdk-client/src/client/api-client-pagination-helper.ts b/packages/sdk-client/src/client/api-client-pagination-helper.ts index 50a0cd11..c2d0b9e0 100644 --- a/packages/sdk-client/src/client/api-client-pagination-helper.ts +++ b/packages/sdk-client/src/client/api-client-pagination-helper.ts @@ -137,7 +137,7 @@ export const createNextPageMethod = ( page: nextPageValue, }; } else { - throw new Error(); + throw new Error(`Error: the pagination method (${context.pagination}) is not supported`); } const pageResultPromise = updateQueryParamsAndSendRequest(apiClient, newParams, requestOptions, context); diff --git a/packages/sdk-client/src/domain/domain-interface.ts b/packages/sdk-client/src/domain/domain-interface.ts index 81d2d4ee..98115734 100644 --- a/packages/sdk-client/src/domain/domain-interface.ts +++ b/packages/sdk-client/src/domain/domain-interface.ts @@ -30,6 +30,8 @@ export interface ApplicationCredentials { applicationKey: string; /** Your Application secret. You can find this on your [Dashboard](https://dashboard.sinch.com/verification/apps)*/ applicationSecret: string; + /** The region for the Voice API. Default is empty */ + voiceRegion?: VoiceRegion; } export const isUnifiedCredentials = (credentials: any): credentials is UnifiedCredentials => { @@ -66,3 +68,25 @@ export function getRegion(value: string | undefined): Region | undefined { console.error(`No region exist for the value '${value}'`); return undefined; } + +export enum VoiceRegion { + DEFAULT = '', + UNITED_STATES = '-use1', + EUROPE = '-euc1', + SOUTH_AMERICA = '-sae1', + SOUTHEAST_ASIA_1 = '-apse1', + SOUTHEAST_ASIA_2 = '-apse2' +} + +export const getVoiceRegion = (value: string | undefined): VoiceRegion | undefined => { + if (!value) { + return undefined; + } + for(const region of Object.values(VoiceRegion)) { + if (region === value.toLowerCase()) { + return region as VoiceRegion; + } + } + console.error(`No region exist for the value '${value}'`); + return undefined; +}; diff --git a/packages/sdk-core/package.json b/packages/sdk-core/package.json index 4d71edf7..05a6abe0 100644 --- a/packages/sdk-core/package.json +++ b/packages/sdk-core/package.json @@ -31,7 +31,8 @@ "dependencies": { "@sinch/numbers": "^0.0.0", "@sinch/sms": "^0.0.0", - "@sinch/verification": "^0.0.0" + "@sinch/verification": "^0.0.0", + "@sinch/voice": "^0.0.0" }, "devDependencies": {}, "publishConfig": { diff --git a/packages/sdk-core/src/index.ts b/packages/sdk-core/src/index.ts index 7a3f9336..616896ca 100644 --- a/packages/sdk-core/src/index.ts +++ b/packages/sdk-core/src/index.ts @@ -2,3 +2,4 @@ export * from './sinch-client'; export * from '@sinch/numbers'; export * from '@sinch/sms'; export * from '@sinch/verification'; +export * from '@sinch/voice'; diff --git a/packages/sdk-core/src/sinch-client.ts b/packages/sdk-core/src/sinch-client.ts index 75cdc783..4b0e97f1 100644 --- a/packages/sdk-core/src/sinch-client.ts +++ b/packages/sdk-core/src/sinch-client.ts @@ -2,6 +2,7 @@ import { Numbers } from '@sinch/numbers'; import { Sms } from '@sinch/sms'; import { Verification } from '@sinch/verification'; import { SinchClientParameters } from '@sinch/sdk-client'; +import { Voice } from '@sinch/voice'; /** Sinch Client to declare and initialize the supported APIs */ export class SinchClient { @@ -9,6 +10,7 @@ export class SinchClient { public readonly numbers: Numbers; public readonly sms: Sms; public readonly verification: Verification; + public readonly voice: Voice; /** * Initialize your API Client instance with the provided credentials. @@ -24,5 +26,8 @@ export class SinchClient { // Initialize the "Verification" API this.verification = new Verification(params); + + // Initialize the "Voice" API + this.voice = new Voice(params); } } diff --git a/packages/sms/src/rest/v1/batches/batches-api.ts b/packages/sms/src/rest/v1/batches/batches-api.ts index eb62c0bc..7ef20b28 100644 --- a/packages/sms/src/rest/v1/batches/batches-api.ts +++ b/packages/sms/src/rest/v1/batches/batches-api.ts @@ -126,7 +126,7 @@ export class BatchesApi extends SmsApi { const getParams = this.client.extractQueryParams(data, [] as never[]); const headers: { [key: string]: string | undefined } = { 'Content-Type': 'application/json', - 'Accept': '', + 'Accept': 'application/json', }; const body: RequestBody diff --git a/packages/sms/src/rest/v1/groups/groups-api.ts b/packages/sms/src/rest/v1/groups/groups-api.ts index 9d68681c..20286cb8 100644 --- a/packages/sms/src/rest/v1/groups/groups-api.ts +++ b/packages/sms/src/rest/v1/groups/groups-api.ts @@ -102,7 +102,7 @@ export class GroupsApi extends SmsApi { const getParams = this.client.extractQueryParams(data, [] as never[]); const headers: { [key: string]: string | undefined } = { 'Content-Type': 'application/json', - 'Accept': '', + 'Accept': 'application/json', }; const body: RequestBody = ''; diff --git a/packages/sms/src/rest/v1/sms-api.ts b/packages/sms/src/rest/v1/sms-api.ts index 6647acb3..8c38a857 100644 --- a/packages/sms/src/rest/v1/sms-api.ts +++ b/packages/sms/src/rest/v1/sms-api.ts @@ -24,13 +24,18 @@ export class SmsApi implements Api { * @param {string} basePath - The new base path to use for the APIs. */ public setBasePath(basePath: string) { - this.client = this.getSinchClient(); - this.client.apiClientOptions.basePath = basePath; + try { + this.client = this.getSinchClient(); + this.client.apiClientOptions.basePath = basePath; + } catch (error) { + console.error('Impossible to set a new base path, the Application credentials need to be provided first.'); + throw error; + } } /** * Updates the credentials used to authenticate API requests - * @param {UnifiedCredentials | ServicePlanIdCredentials} credentials + * @param {UnifiedCredentials | ServicePlanIdCredentials} credentials */ public setCredentials(credentials: UnifiedCredentials | ServicePlanIdCredentials) { const parametersBackup = { ...this.sinchClientParameters }; diff --git a/packages/voice/README.md b/packages/voice/README.md index 51ce2a2c..86cdf7b2 100644 --- a/packages/voice/README.md +++ b/packages/voice/README.md @@ -38,7 +38,7 @@ If you are using this SDK as part of the Sinch SDK (`@sinch/sdk-core`) you can a ```typescript import { - CalloutsRequestData, + TtsCalloutRequestData, GetCalloutResponseObj, SinchClient, SinchClientParameters, @@ -50,8 +50,8 @@ const credentials: SinchClientParameters = { }; const sinch = new SinchClient(credentials); -const requestData: CalloutsRequestData = { - calloutRequestBody: { +const requestData: TtsCalloutRequestData = { + ttsCalloutRequestBody: { method: 'ttsCallout', ttsCallout: { destination: { @@ -67,7 +67,7 @@ const requestData: CalloutsRequestData = { // Access the 'voice' domain registered on the Sinch Client const calloutResponse: GetCalloutResponseObj - = await sinch.voice.callouts.callouts(requestData); + = await sinch.voice.callouts.tts(requestData); ``` ### Standalone @@ -79,7 +79,7 @@ import { SinchClientParameters } from '@sinch/sdk-client'; import { - CalloutsRequestData, + TtsCalloutRequestData, GetCalloutResponseObj, Voice, } from '@sinch/voice'; @@ -92,8 +92,8 @@ const credentials: SinchClientParameters = { // Declare the 'verification' in a standalone way const voice = new Voice(credentials); -const requestData: CalloutsRequestData = { - calloutRequestBody: { +const requestData: TtsCalloutRequestData = { + ttsCalloutRequestBody: { method: 'ttsCallout', ttsCallout: { destination: { @@ -109,7 +109,7 @@ const requestData: CalloutsRequestData = { // Use the standalone declaration of the 'verification' domain const calloutResponse: GetCalloutResponseObj - = await voice.callouts.callouts(requestData); + = await voice.callouts.tts(requestData); ``` ## Promises @@ -120,16 +120,16 @@ All the methods that interact with the Sinch APIs use Promises. You can use `awa // Method 1: Wait for the Promise to complete let calloutResponse: GetCalloutResponseObj; try { - calloutResponse = await sinch.voice.callouts.callouts(requestData); + calloutResponse = await sinch.voice.callouts.tts(requestData); console.log(`callId = ${response.callId}`); } catch (error: any) { - console.error(`ERROR ${error.statusCode}: Impossible to make a call out to the number ${requestData.calloutRequestBody.ttsCallout.destination.endpoint}`); + console.error(`ERROR ${error.statusCode}: Impossible to make a TTS callout to the number ${requestData.ttsCalloutRequestBody.ttsCallout.destination.endpoint}`); } // Method 2: Resolve the promise -sinch.voice.callouts.callouts(requestData) +sinch.voice.callouts.tts(requestData) .then(response => console.log(`callId = ${response.callId}`)) - .catch(error => console.error(`ERROR ${error.statusCode}: Impossible to make a call out to the number ${requestData.calloutRequestBody.ttsCallout.destination.endpoint}`)); + .catch(error => console.error(`ERROR ${error.statusCode}: Impossible to make a TTS call out to the number ${requestData.ttsCalloutRequestBody.ttsCallout.destination.endpoint}`)); ``` ## Contact diff --git a/packages/voice/src/index.ts b/packages/voice/src/index.ts new file mode 100644 index 00000000..bd163908 --- /dev/null +++ b/packages/voice/src/index.ts @@ -0,0 +1,2 @@ +export * from './models'; +export * from './rest'; diff --git a/packages/voice/src/models/v1/update-numbers/update-numbers.ts b/packages/voice/src/models/v1/assign-numbers/assign-numbers.ts similarity index 91% rename from packages/voice/src/models/v1/update-numbers/update-numbers.ts rename to packages/voice/src/models/v1/assign-numbers/assign-numbers.ts index 226a6f47..d7868ba9 100644 --- a/packages/voice/src/models/v1/update-numbers/update-numbers.ts +++ b/packages/voice/src/models/v1/assign-numbers/assign-numbers.ts @@ -1,12 +1,12 @@ /** - * Model: UpdateNumbers + * Model: AssignNumbers * * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. * */ -export interface UpdateNumbers { +export interface AssignNumbers { /** The phone number or list of numbers in E.164 format. */ numbers?: string[]; diff --git a/packages/voice/src/models/v1/assign-numbers/index.ts b/packages/voice/src/models/v1/assign-numbers/index.ts new file mode 100644 index 00000000..e15158e7 --- /dev/null +++ b/packages/voice/src/models/v1/assign-numbers/index.ts @@ -0,0 +1 @@ +export type { AssignNumbers } from './assign-numbers'; diff --git a/packages/voice/src/models/v1/enums.ts b/packages/voice/src/models/v1/enums.ts index 07b2c921..f11009eb 100644 --- a/packages/voice/src/models/v1/enums.ts +++ b/packages/voice/src/models/v1/enums.ts @@ -24,7 +24,7 @@ export type { } from './unassign-numbers/unassign-numbers'; export type { CapabilityEnum as UpdateNumbersCapabilityEnum, -} from './update-numbers/update-numbers'; +} from './assign-numbers/assign-numbers'; export type { CommandEnum as ManageConferenceParticipantRequestCommandEnum, MohEnum as ManageConferenceParticipantRequestMohEnum, diff --git a/packages/voice/src/models/v1/get-call-response-obj/get-call-response-obj.ts b/packages/voice/src/models/v1/get-call-response-obj/get-call-response-obj.ts index 1eb1958e..10bcc8e3 100644 --- a/packages/voice/src/models/v1/get-call-response-obj/get-call-response-obj.ts +++ b/packages/voice/src/models/v1/get-call-response-obj/get-call-response-obj.ts @@ -11,7 +11,7 @@ export interface GetCallResponseObj { /** Contains the caller information. */ from?: string; /** Contains the callee information. */ - to?: string; + to?: GetCallResponseTo; /** Must be `pstn` for PSTN. */ domain?: DomainEnum; /** The unique identifier of the call. */ @@ -29,9 +29,29 @@ export interface GetCallResponseObj { /** An object that can be used to pass custom information related to the call. */ custom?: object; /** The rate per minute that was charged for the call. */ - userRate?: string; + userRate?: GetCallResponseUserRate; /** The total amount charged for the call. */ - debit?: string; + debit?: GetCallResponseDebit; +} + +export interface GetCallResponseTo { + /** The type of the destination. */ + type?: string; + /** The phone number, user name, or other identifier of the destination. */ + endpoint?: string; +} +export interface GetCallResponseUserRate { + /** The currency in which the call is charged. */ + currencyId?: string; + /** The rate per minute that was charged for the call. */ + amount?: number; +} + +export interface GetCallResponseDebit { + /** The currency ID of the rate, for example, `USD`. */ + currencyId?: string; + /** The total amount debited for the call. */ + amount?: number; } export type DomainEnum = 'pstn'; diff --git a/packages/voice/src/models/v1/get-call-response-obj/index.ts b/packages/voice/src/models/v1/get-call-response-obj/index.ts index b2baf4e9..daee4386 100644 --- a/packages/voice/src/models/v1/get-call-response-obj/index.ts +++ b/packages/voice/src/models/v1/get-call-response-obj/index.ts @@ -1 +1,6 @@ -export type { GetCallResponseObj } from './get-call-response-obj'; +export type { + GetCallResponseObj, + GetCallResponseTo, + GetCallResponseUserRate, + GetCallResponseDebit, +} from './get-call-response-obj'; diff --git a/packages/voice/src/models/v1/get-query-number/get-query-number.ts b/packages/voice/src/models/v1/get-query-number/get-query-number.ts index dd7f7619..5750d84d 100644 --- a/packages/voice/src/models/v1/get-query-number/get-query-number.ts +++ b/packages/voice/src/models/v1/get-query-number/get-query-number.ts @@ -12,7 +12,7 @@ export interface GetQueryNumber { /** The type of method. */ method?: string; /** @see GetQueryNumberNumberItem */ - numberItem?: GetQueryNumberNumberItem; + number?: GetQueryNumberNumberItem; } diff --git a/packages/voice/src/models/v1/index.ts b/packages/voice/src/models/v1/index.ts index f572f062..9bf3d80c 100644 --- a/packages/voice/src/models/v1/index.ts +++ b/packages/voice/src/models/v1/index.ts @@ -58,5 +58,5 @@ export * from './tts-callout-request'; export * from './unassign-numbers'; export * from './update-callbacks'; export * from './update-callbacks-url'; -export * from './update-numbers'; +export * from './assign-numbers'; export * from './enums'; diff --git a/packages/voice/src/models/v1/update-numbers/index.ts b/packages/voice/src/models/v1/update-numbers/index.ts deleted file mode 100644 index 4152bee7..00000000 --- a/packages/voice/src/models/v1/update-numbers/index.ts +++ /dev/null @@ -1 +0,0 @@ -export type { UpdateNumbers } from './update-numbers'; diff --git a/packages/voice/src/rest/index.ts b/packages/voice/src/rest/index.ts new file mode 100644 index 00000000..5b98253d --- /dev/null +++ b/packages/voice/src/rest/index.ts @@ -0,0 +1 @@ +export * from './v1'; diff --git a/packages/voice/src/rest/v1/applications/applications-api.jest.fixture.ts b/packages/voice/src/rest/v1/applications/applications-api.jest.fixture.ts new file mode 100644 index 00000000..f9d12598 --- /dev/null +++ b/packages/voice/src/rest/v1/applications/applications-api.jest.fixture.ts @@ -0,0 +1,31 @@ +import { GetCallbacks, GetNumbersResponseObj, GetQueryNumber } from '../../../models'; +import { ApplicationsApi, QueryNumberRequestData, GetCallbackURLsRequestData, GetNumbersRequestData, UnassignNumberRequestData, UpdateCallbackURLsRequestData, AssignNumbersRequestData } from './applications-api'; + +export class ApplicationsApiFixture implements Partial> { + + /** + * Fixture associated to function queryNumber + */ + public queryNumber: jest.Mock, [QueryNumberRequestData]> = jest.fn(); + /** + * Fixture associated to function getCallbackURLs + */ + public getCallbackURLs: jest.Mock, [GetCallbackURLsRequestData]> = jest.fn(); + /** + * Fixture associated to function getNumbers + */ + public getNumbers: jest.Mock, [GetNumbersRequestData]> = jest.fn(); + /** + * Fixture associated to function unassignNumber + */ + public unassignNumber: jest.Mock, [UnassignNumberRequestData]> = jest.fn(); + /** + * Fixture associated to function updateCallbackURLs + */ + public updateCallbackURLs: jest.Mock, [UpdateCallbackURLsRequestData]> = jest.fn(); + /** + * Fixture associated to function assignNumbers + */ + public assignNumbers: jest.Mock, [AssignNumbersRequestData]> = jest.fn(); +} + diff --git a/packages/voice/src/rest/v1/applications/applications-api.ts b/packages/voice/src/rest/v1/applications/applications-api.ts new file mode 100644 index 00000000..d957727e --- /dev/null +++ b/packages/voice/src/rest/v1/applications/applications-api.ts @@ -0,0 +1,228 @@ +import { + GetCallbacks, + GetNumbersResponseObj, + GetQueryNumber, + UnassignNumbers, + UpdateCallbacks, + AssignNumbers, +} from '../../../models'; +import { + RequestBody, + SinchClientParameters, +} from '@sinch/sdk-client'; +import { VoiceApi } from '../voice-api'; + +export interface QueryNumberRequestData { + /** The phone number you want to query. */ + 'number': string; +} +export interface GetCallbackURLsRequestData { + /** The unique identifying key of the application. */ + 'applicationkey': string; +} +export interface GetNumbersRequestData { +} +export interface UnassignNumberRequestData { + /** */ + 'unassignNumbersRequestBody'?: UnassignNumbers; +} +export interface UpdateCallbackURLsRequestData { + /** The unique identifying key of the application. */ + 'applicationkey': string; + /** */ + 'updateCallbacksRequestBody'?: UpdateCallbacks; +} +export interface AssignNumbersRequestData { + /** */ + 'assignNumbersRequestBody'?: AssignNumbers; +} + +export class ApplicationsApi extends VoiceApi { + + /** + * Initialize your interface + * + * @param {SinchClientParameters} sinchClientParameters - The parameters used to initialize the API Client. + */ + constructor(sinchClientParameters: SinchClientParameters) { + super(sinchClientParameters, 'ApplicationsApi'); + } + + /** + * Query number + * Returns information about the requested number. + * @param { QueryNumberRequestData } data - The data to provide to the API call. + */ + public async queryNumber(data: QueryNumberRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody = ''; + const path = `/v1/calling/query/number/${data['number']}`; + const basePathUrl = this.client.apiClientOptions.basePath + path; + + const requestOptions + = await this.client.prepareOptions(basePathUrl, 'GET', getParams, headers, body || undefined, path); + const url = this.client.prepareUrl(requestOptions.basePath, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'QueryNumber', + }); + } + + /** + * Get Callback URLs + * Returns any callback URLs configured for the specified application. + * @param { GetCallbackURLsRequestData } data - The data to provide to the API call. + */ + public async getCallbackURLs(data: GetCallbackURLsRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody = ''; + const path = `/v1/configuration/callbacks/applications/${data['applicationkey']}`; + const basePathUrl = this.client.apiClientOptions.basePath + path; + + const requestOptions + = await this.client.prepareOptions(basePathUrl, 'GET', getParams, headers, body || undefined, path); + const url = this.client.prepareUrl(requestOptions.basePath, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'GetCallbackURLs', + }); + } + + /** + * Get Numbers + * Get information about your numbers. It returns a list of numbers that you own, as well as their capability (voice or SMS). For the ones that are assigned to an app, it returns the application key of the app. + * @param { GetNumbersRequestData } data - The data to provide to the API call. + */ + public async getNumbers(data: GetNumbersRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody = ''; + const path = `/v1/configuration/numbers`; + const basePathUrl = this.client.apiClientOptions.basePath + path; + + const requestOptions + = await this.client.prepareOptions(basePathUrl, 'GET', getParams, headers, body || undefined, path); + const url = this.client.prepareUrl(requestOptions.basePath, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'GetNumbers', + }); + } + + /** + * Un-assign number + * Un-assign a number from an application. + * @param { UnassignNumberRequestData } data - The data to provide to the API call. + */ + public async unassignNumber(data: UnassignNumberRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody = data['unassignNumbersRequestBody'] + ? JSON.stringify(data['unassignNumbersRequestBody']) : '{}'; + const path = `/v1/configuration/numbers`; + const basePathUrl = this.client.apiClientOptions.basePath + path; + + const requestOptions + = await this.client.prepareOptions(basePathUrl, 'DELETE', getParams, headers, body || undefined, path); + const url = this.client.prepareUrl(requestOptions.basePath, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'UnassignNumber', + }); + } + + /** + * Update Callbacks + * Update the configured callback URLs for the specified application. + * @param { UpdateCallbackURLsRequestData } data - The data to provide to the API call. + */ + public async updateCallbackURLs(data: UpdateCallbackURLsRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody = data['updateCallbacksRequestBody'] + ? JSON.stringify(data['updateCallbacksRequestBody']) : '{}'; + const path = `/v1/configuration/callbacks/applications/${data['applicationkey']}`; + const basePathUrl = this.client.apiClientOptions.basePath + path; + + const requestOptions + = await this.client.prepareOptions(basePathUrl, 'POST', getParams, headers, body || undefined, path); + const url = this.client.prepareUrl(requestOptions.basePath, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'UpdateCallbackURLs', + }); + } + + /** + * Update Numbers + * Assign a number or a list of numbers to an application. + * @param { AssignNumbersRequestData } data - The data to provide to the API call. + */ + public async assignNumbers(data: AssignNumbersRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody = data['assignNumbersRequestBody'] + ? JSON.stringify(data['assignNumbersRequestBody']) : '{}'; + const path = `/v1/configuration/numbers`; + const basePathUrl = this.client.apiClientOptions.basePath + path; + + const requestOptions + = await this.client.prepareOptions(basePathUrl, 'POST', getParams, headers, body || undefined, path); + const url = this.client.prepareUrl(requestOptions.basePath, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'UpdateNumbers', + }); + } + +} diff --git a/packages/voice/src/rest/v1/applications/index.ts b/packages/voice/src/rest/v1/applications/index.ts new file mode 100644 index 00000000..c47b53ea --- /dev/null +++ b/packages/voice/src/rest/v1/applications/index.ts @@ -0,0 +1,2 @@ +export * from './applications-api'; +export * from './applications-api.jest.fixture'; diff --git a/packages/voice/src/rest/v1/callouts/callouts-api.jest.fixture.ts b/packages/voice/src/rest/v1/callouts/callouts-api.jest.fixture.ts new file mode 100644 index 00000000..bd3b8460 --- /dev/null +++ b/packages/voice/src/rest/v1/callouts/callouts-api.jest.fixture.ts @@ -0,0 +1,26 @@ +import { GetCalloutResponseObj } from '../../../models'; +import { + CalloutsApi, + ConferenceCalloutRequestData, + CustomCalloutRequestData, + TtsCalloutRequestData, +} from './callouts-api'; + +export class CalloutsApiFixture implements Partial> { + + /** + * Fixture associated to function tts + */ + public tts: jest.Mock, [TtsCalloutRequestData]> = jest.fn(); + + /** + * Fixture associated to function tts + */ + public conference: jest.Mock, [ConferenceCalloutRequestData]> = jest.fn(); + + /** + * Fixture associated to function tts + */ + public custom: jest.Mock, [CustomCalloutRequestData]> = jest.fn(); +} + diff --git a/packages/voice/src/rest/v1/callouts/callouts-api.ts b/packages/voice/src/rest/v1/callouts/callouts-api.ts new file mode 100644 index 00000000..fe782d34 --- /dev/null +++ b/packages/voice/src/rest/v1/callouts/callouts-api.ts @@ -0,0 +1,137 @@ +import { + ConferenceCalloutRequest, + CustomCalloutRequest, + GetCalloutResponseObj, + TtsCalloutRequest, +} from '../../../models'; +import { + RequestBody, + SinchClientParameters, +} from '@sinch/sdk-client'; +import { VoiceApi } from '../voice-api'; + +export interface TtsCalloutRequestData { + 'ttsCalloutRequestBody': { + /** Type of callout. */ + method: 'ttsCallout', + /** @see TtsCalloutRequest */ + ttsCallout: TtsCalloutRequest + } +} + +export interface ConferenceCalloutRequestData { + 'conferenceCalloutRequestBody': { + /** Type of callout. */ + method: 'conferenceCallout', + /** @see ConferenceCalloutRequest */ + conferenceCallout: ConferenceCalloutRequest + } +} + +export interface CustomCalloutRequestData { + 'customCalloutRequestBody': { + /** Type of callout. */ + method: 'customCallout', + /** @see CustomCalloutRequest */ + customCallout: CustomCalloutRequest + } +} + +export class CalloutsApi extends VoiceApi { + + /** + * Initialize your interface + * + * @param {SinchClientParameters} sinchClientParameters - The parameters used to initialize the API Client. + */ + constructor(sinchClientParameters: SinchClientParameters) { + super(sinchClientParameters, 'CalloutsApi'); + } + + /** + * TTS Callout Request + * Makes a text-to-speech callout to a phone number. + * @param { TtsCalloutRequestData } data - The data to provide to the API call. + */ + public async tts(data: TtsCalloutRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody = data['ttsCalloutRequestBody'] ? JSON.stringify(data['ttsCalloutRequestBody']) : '{}'; + const path = `/calling/v1/callouts`; + const basePathUrl = this.client.apiClientOptions.basePath + path; + + const requestOptions = await this.client.prepareOptions(basePathUrl, 'POST', getParams, headers, body, path); + const url = this.client.prepareUrl(requestOptions.basePath, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'Callouts', + }); + } + + /** + * Conference Callout Request + * Makes a conference callout to a phone number. + * @param { ConferenceCalloutRequestData } data - The data to provide to the API call. + */ + public async conference(data: ConferenceCalloutRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody + = data['conferenceCalloutRequestBody'] ? JSON.stringify(data['conferenceCalloutRequestBody']) : '{}'; + const path = `/calling/v1/callouts`; + const basePathUrl = this.client.apiClientOptions.basePath + path; + + const requestOptions = await this.client.prepareOptions(basePathUrl, 'POST', getParams, headers, body, path); + const url = this.client.prepareUrl(requestOptions.basePath, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'Callouts', + }); + } + + /** + * Custom Callout Request + * Makes a conference callout to a phone number. + * @param { CustomCalloutRequestData } data - The data to provide to the API call. + */ + public async custom(data: CustomCalloutRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody + = data['customCalloutRequestBody'] ? JSON.stringify(data['customCalloutRequestBody']) : '{}'; + const path = `/calling/v1/callouts`; + const basePathUrl = this.client.apiClientOptions.basePath + path; + + const requestOptions = await this.client.prepareOptions(basePathUrl, 'POST', getParams, headers, body, path); + const url = this.client.prepareUrl(requestOptions.basePath, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'Callouts', + }); + } + +} diff --git a/packages/voice/src/rest/v1/callouts/index.ts b/packages/voice/src/rest/v1/callouts/index.ts new file mode 100644 index 00000000..2bc7623a --- /dev/null +++ b/packages/voice/src/rest/v1/callouts/index.ts @@ -0,0 +1,2 @@ +export * from './callouts-api'; +export * from './callouts-api.jest.fixture'; diff --git a/packages/voice/src/rest/v1/calls/calls-api.jest.fixture.ts b/packages/voice/src/rest/v1/calls/calls-api.jest.fixture.ts new file mode 100644 index 00000000..7cbae8c0 --- /dev/null +++ b/packages/voice/src/rest/v1/calls/calls-api.jest.fixture.ts @@ -0,0 +1,19 @@ +import { GetCallResponseObj } from '../../../models'; +import { CallsApi, GetCallResultRequestData, ManageWithCallLegRequestData, UpdateCallRequestData } from './calls-api'; + +export class CallsApiFixture implements Partial> { + + /** + * Fixture associated to function getCallResult + */ + public get: jest.Mock, [GetCallResultRequestData]> = jest.fn(); + /** + * Fixture associated to function manageCallWithCallLeg + */ + public manageWithCallLeg: jest.Mock, [ManageWithCallLegRequestData]> = jest.fn(); + /** + * Fixture associated to function updateCall + */ + public update: jest.Mock, [UpdateCallRequestData]> = jest.fn(); +} + diff --git a/packages/voice/src/rest/v1/calls/calls-api.ts b/packages/voice/src/rest/v1/calls/calls-api.ts new file mode 100644 index 00000000..4404f20a --- /dev/null +++ b/packages/voice/src/rest/v1/calls/calls-api.ts @@ -0,0 +1,127 @@ +import { + GetCallResponseObj, + SVAMLRequestBody, +} from '../../../models'; +import { + RequestBody, + SinchClientParameters, +} from '@sinch/sdk-client'; +import { VoiceApi } from '../voice-api'; + +export type CallLegEnum = 'caller' | 'callee' | 'both'; +export interface GetCallResultRequestData { + /** The unique identifier of the call. This value is generated by the system. */ + 'callId': string; +} +export interface ManageWithCallLegRequestData { + /** The unique identifier of the call. This value is generated by the system. */ + 'callId': string; + /** Specifies which part of the call will be managed. This option is used only by the `PlayFiles` and `Say` instructions to indicate which channel the sound will be played on. Valid options are `caller`, `callee` or `both`. If not specified, the default value is `caller`.
The `callLeg` identifier is ignored for calls that are part of a conference and calls initiated using the Callout API. */ + 'callLeg': CallLegEnum; + /** */ + 'svamlRequestBody'?: SVAMLRequestBody; +} +export interface UpdateCallRequestData { + /** The unique identifier of the call. This value is generated by the system. */ + 'callId': string; + /** */ + 'svamlRequestBody'?: SVAMLRequestBody; +} + +export class CallsApi extends VoiceApi { + + /** + * Initialize your interface + * + * @param {SinchClientParameters} sinchClientParameters - The parameters used to initialize the API Client. + */ + constructor(sinchClientParameters: SinchClientParameters) { + super(sinchClientParameters, 'CallsApi'); + } + + /** + * Get information about a call + * You can retrieve information about an ongoing or completed call using a call ID. You can find the call ID of an ongoing call by viewing the response object from a callout request. You can find the call ID of a completed call by looking at your call logs in your Sinch [Dashboard](https://dashboard.sinch.com/voice/logs). Note: You can only use this method for calls that terminate to PSTN or SIP networks from an In-app call. + * @param { GetCallResultRequestData } data - The data to provide to the API call. + */ + public async get(data: GetCallResultRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody = ''; + const path = `/calling/v1/calls/id/${data['callId']}`; + const basePathUrl = this.client.apiClientOptions.basePath + path; + + const requestOptions + = await this.client.prepareOptions(basePathUrl, 'GET', getParams, headers, body || undefined, path); + const url = this.client.prepareUrl(requestOptions.basePath, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'GetCallResult', + }); + } + + /** + * Manage Call with `callLeg` + * This method is used to manage ongoing, connected calls. This method is only used when using the `PlayFiles` and `Say` instructions in the request body. This method uses SVAML in the request body to perform various tasks related to the call. For more information about SVAML, see the [Callback API](/docs/voice/api-reference/svaml/) documentation. Note: You can only use this method for calls that originate from or terminate to PSTN or SIP networks. + * @param { ManageWithCallLegRequestData } data - The data to provide to the API call. + */ + public async manageWithCallLeg(data: ManageWithCallLegRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody = data['svamlRequestBody'] ? JSON.stringify(data['svamlRequestBody']) : '{}'; + const path = `/calling/v1/calls/id/${data['callId']}/leg/${data['callLeg']}`; + const basePathUrl = this.client.apiClientOptions.basePath + path; + + const requestOptions = await this.client.prepareOptions(basePathUrl, 'PATCH', getParams, headers, body, path); + const url = this.client.prepareUrl(requestOptions.basePath, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'ManageCallWithCallLeg', + }); + } + + /** + * Update a call in progress + * This method is used to manage ongoing, connected calls. This method uses SVAML in the request body to perform various tasks related to the call. For more information about SVAML, see the [Callback API](/docs/voice/api-reference/svaml/) documentation. This method can only be used for calls that originate from or terminate to PSTN or SIP networks. + * @param { UpdateCallRequestData } data - The data to provide to the API call. + */ + public async update(data: UpdateCallRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody = data['svamlRequestBody'] ? JSON.stringify(data['svamlRequestBody']) : '{}'; + const path = `/calling/v1/calls/id/${data['callId']}`; + const basePathUrl = this.client.apiClientOptions.basePath + path; + + const requestOptions = await this.client.prepareOptions(basePathUrl, 'PATCH', getParams, headers, body, path); + const url = this.client.prepareUrl(requestOptions.basePath, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'UpdateCall', + }); + } + +} diff --git a/packages/voice/src/rest/v1/calls/index.ts b/packages/voice/src/rest/v1/calls/index.ts new file mode 100644 index 00000000..6810f62e --- /dev/null +++ b/packages/voice/src/rest/v1/calls/index.ts @@ -0,0 +1,2 @@ +export * from './calls-api'; +export * from './calls-api.jest.fixture'; diff --git a/packages/voice/src/rest/v1/conferences/conferences-api.jest.fixture.ts b/packages/voice/src/rest/v1/conferences/conferences-api.jest.fixture.ts new file mode 100644 index 00000000..b248edf3 --- /dev/null +++ b/packages/voice/src/rest/v1/conferences/conferences-api.jest.fixture.ts @@ -0,0 +1,30 @@ +import { + GetConferenceInfoResponse, +} from '../../../models'; +import { + ConferencesApi, + GetConferenceInfoRequestData, + KickAllRequestData, + KickParticipantRequestData, + ManageParticipantRequestData, +} from './conferences-api'; + +export class ConferencesApiFixture implements Partial> { + + /** + * Fixture associated to function get + */ + public get: jest.Mock, [GetConferenceInfoRequestData]> = jest.fn(); + /** + * Fixture associated to function kickAll + */ + public kickAll: jest.Mock, [KickAllRequestData]> = jest.fn(); + /** + * Fixture associated to function kickParticipant + */ + public kickParticipant: jest.Mock, [KickParticipantRequestData]> = jest.fn(); + /** + * Fixture associated to function manageParticipant + */ + public manageParticipant: jest.Mock, [ManageParticipantRequestData]> = jest.fn(); +} diff --git a/packages/voice/src/rest/v1/conferences/conferences-api.ts b/packages/voice/src/rest/v1/conferences/conferences-api.ts new file mode 100644 index 00000000..c4a21a73 --- /dev/null +++ b/packages/voice/src/rest/v1/conferences/conferences-api.ts @@ -0,0 +1,159 @@ +import { + GetConferenceInfoResponse, + ManageConferenceParticipantRequest, +} from '../../../models/'; +import { + RequestBody, + SinchClientParameters, +} from '@sinch/sdk-client'; +import { VoiceApi } from '../voice-api'; + +export interface GetConferenceInfoRequestData { + /** The unique identifier of the conference. The user sets this value. */ + 'conferenceId': string; +} +export interface KickAllRequestData { + /** The unique identifier of the conference. The user sets this value. */ + 'conferenceId': string; +} +export interface KickParticipantRequestData { + /** The unique identifier of the call. This value is generated by the system. */ + 'callId': string; + /** The unique identifier of the conference. The user sets this value. */ + 'conferenceId': string; +} +export interface ManageParticipantRequestData { + /** The unique identifier of the call. This value is generated by the system. */ + 'callId': string; + /** The unique identifier of the conference. The user sets this value. */ + 'conferenceId': string; + /** */ + 'manageParticipantRequestBody'?: ManageConferenceParticipantRequest; +} + +export class ConferencesApi extends VoiceApi { + + /** + * Initialize your interface + * + * @param {SinchClientParameters} sinchClientParameters - The parameters used to initialize the API Client. + */ + constructor(sinchClientParameters: SinchClientParameters) { + super(sinchClientParameters, 'ConferencesApi'); + } + + /** + * Get Conference Info + * Returns information about a conference that matches the provided conference ID. + * @param { GetConferenceInfoRequestData } data - The data to provide to the API call. + */ + public async get(data: GetConferenceInfoRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody = ''; + const path = `/calling/v1/conferences/id/${data['conferenceId']}`; + const basePathUrl = this.client.apiClientOptions.basePath + path; + + const requestOptions + = await this.client.prepareOptions(basePathUrl, 'GET', getParams, headers, body || undefined, path); + const url = this.client.prepareUrl(requestOptions.basePath, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'GetConferenceInfo', + }); + } + + /** + * Kick Conference All + * Removes all participants from a conference. + * @param { KickAllRequestData } data - The data to provide to the API call. + */ + public async kickAll(data: KickAllRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody = ''; + const path = `/calling/v1/conferences/id/${data['conferenceId']}`; + const basePathUrl = this.client.apiClientOptions.basePath + path; + + const requestOptions = await this.client.prepareOptions(basePathUrl, 'DELETE', getParams, headers, body, path); + const url = this.client.prepareUrl(requestOptions.basePath, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'KickConferenceAll', + }); + } + + /** + * Kick Conference Participant + * Remove a specified conference participant from a specified conference. + * @param { KickParticipantRequestData } data - The data to provide to the API call. + */ + public async kickParticipant(data: KickParticipantRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody = ''; + const path = `/calling/v1/conferences/id/${data['conferenceId']}/${data['callId']}`; + const basePathUrl = this.client.apiClientOptions.basePath + path; + + const requestOptions = await this.client.prepareOptions(basePathUrl, 'DELETE', getParams, headers, body, path); + const url = this.client.prepareUrl(requestOptions.basePath, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'KickConferenceParticipant', + }); + } + + /** + * Manage Conference Participant + * Manages conference participant in a specified conference: * mute / unmute * put on hold / resume. + * @param { ManageParticipantRequestData } data - The data to provide to the API call. + */ + public async manageParticipant(data: ManageParticipantRequestData): Promise { + this.client = this.getSinchClient(); + const getParams = this.client.extractQueryParams(data, [] as never[]); + const headers: { [key: string]: string | undefined } = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }; + + const body: RequestBody = data['manageParticipantRequestBody'] + ? JSON.stringify(data['manageParticipantRequestBody']) : '{}'; + const path = `/calling/v1/conferences/id/${data['conferenceId']}/${data['callId']}`; + const basePathUrl = this.client.apiClientOptions.basePath + path; + + const requestOptions = await this.client.prepareOptions(basePathUrl, 'PATCH', getParams, headers, body, path); + const url = this.client.prepareUrl(requestOptions.basePath, requestOptions.queryParams); + + return this.client.processCall({ + url, + requestOptions, + apiName: this.apiName, + operationId: 'ManageConferenceParticipant', + }); + } + +} diff --git a/packages/voice/src/rest/v1/conferences/index.ts b/packages/voice/src/rest/v1/conferences/index.ts new file mode 100644 index 00000000..9b6c88d2 --- /dev/null +++ b/packages/voice/src/rest/v1/conferences/index.ts @@ -0,0 +1,2 @@ +export * from './conferences-api'; +export * from './conferences-api.jest.fixture'; diff --git a/packages/voice/src/rest/v1/enums.ts b/packages/voice/src/rest/v1/enums.ts new file mode 100644 index 00000000..66b8d858 --- /dev/null +++ b/packages/voice/src/rest/v1/enums.ts @@ -0,0 +1 @@ +export type { CallLegEnum } from './calls'; diff --git a/packages/voice/src/rest/v1/fixtures.jest.ts b/packages/voice/src/rest/v1/fixtures.jest.ts new file mode 100644 index 00000000..62d5acd6 --- /dev/null +++ b/packages/voice/src/rest/v1/fixtures.jest.ts @@ -0,0 +1,4 @@ +export { ApplicationsApiFixture } from './applications/applications-api.jest.fixture'; +export { CalloutsApiFixture } from './callouts/callouts-api.jest.fixture'; +export { CallsApiFixture } from './calls/calls-api.jest.fixture'; +export { ConferencesApiFixture } from './conferences/conferences-api.jest.fixture'; diff --git a/packages/voice/src/rest/v1/index.ts b/packages/voice/src/rest/v1/index.ts new file mode 100644 index 00000000..fb756338 --- /dev/null +++ b/packages/voice/src/rest/v1/index.ts @@ -0,0 +1,6 @@ +export * from './applications'; +export * from './callouts'; +export * from './calls'; +export * from './conferences'; +export * from './enums'; +export * from './voice'; diff --git a/packages/voice/src/rest/v1/voice-api.ts b/packages/voice/src/rest/v1/voice-api.ts new file mode 100644 index 00000000..842ecc8e --- /dev/null +++ b/packages/voice/src/rest/v1/voice-api.ts @@ -0,0 +1,104 @@ +import { + Api, + ApiClient, + ApiFetchClient, ApplicationCredentials, + SigningRequest, + SinchClientParameters, + VoiceRegion, + XTimestampRequest, +} from '@sinch/sdk-client'; + +export class VoiceApi implements Api { + public readonly apiName: string; + public client?: ApiClient; + private sinchClientParameters: SinchClientParameters; + + constructor(sinchClientParameters: SinchClientParameters, apiName: string) { + this.sinchClientParameters = sinchClientParameters; + this.apiName = apiName; + } + + /** + * Update the default basePath for the API + * @param {string} basePath - The new base path to use for the APIs. + */ + public setBasePath(basePath: string) { + try { + this.client = this.getSinchClient(); + this.client.apiClientOptions.basePath = basePath; + } catch (error) { + console.error('Impossible to set a new base path, the Application credentials need to be provided first.'); + throw error; + } + } + + /** + * Update the region in the basePath + * @param {VoiceRegion} region - The new region to send the requests to + */ + public setRegion(region: VoiceRegion) { + this.sinchClientParameters.voiceRegion = region; + if (this.client) { + this.client.apiClientOptions.basePath = this.buildBasePath(region); + } + } + + /** + * Updates the application credentials used to authenticate API requests + * @param {ApplicationCredentials} credentials + */ + public setApplication(credentials: ApplicationCredentials) { + const parametersBackup = { ...this.sinchClientParameters }; + this.sinchClientParameters = { + ...parametersBackup, + ...credentials, + }; + this.resetApiClient(); + try { + this.getSinchClient(); + } catch (error) { + console.error('Impossible to assign the new application to the Voice API'); + this.sinchClientParameters = parametersBackup; + throw error; + } + } + + private resetApiClient() { + this.client = undefined; + } + + /** + * Checks the configuration parameters are ok and initialize the API client. Once initialized, the same instance will + * be returned for the subsequent API calls (singleton pattern) + * @return {ApiClient} the API Client or throws an error in case the configuration parameters are not ok + * @private + */ + public getSinchClient(): ApiClient { + if (!this.client) { + if (!this.sinchClientParameters.applicationKey || !this.sinchClientParameters.applicationSecret) { + throw new Error('Invalid configuration for the Verification API: ' + + '"applicationKey" and "applicationSecret" values must be provided'); + } + const apiClientOptions = { + requestPlugins: [ + new XTimestampRequest(), + new SigningRequest(this.sinchClientParameters.applicationKey, this.sinchClientParameters.applicationSecret), + ], + }; + this.client = new ApiFetchClient(apiClientOptions); + const region: VoiceRegion = this.sinchClientParameters.voiceRegion || VoiceRegion.DEFAULT; + this.client.apiClientOptions.basePath = this.buildBasePath(region); + } + return this.client; + } + + private buildBasePath(region: VoiceRegion) { + switch (this.apiName) { + case 'ApplicationsApi': + return `https://callingapi.sinch.com`; + default: + return `https://calling${region}.api.sinch.com`; + } + } + +} diff --git a/packages/voice/src/rest/v1/voice.ts b/packages/voice/src/rest/v1/voice.ts new file mode 100644 index 00000000..681a4233 --- /dev/null +++ b/packages/voice/src/rest/v1/voice.ts @@ -0,0 +1,41 @@ +/** + * Domain: calling + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ +import { SinchClientParameters, VoiceRegion } from '@sinch/sdk-client'; +import { ApplicationsApi } from './applications'; +import { ConferencesApi } from './conferences'; +import { CallsApi } from './calls'; +import { CalloutsApi } from './callouts'; + +export class Voice { + public readonly applications: ApplicationsApi; + public readonly conferences: ConferencesApi; + public readonly calls: CallsApi; + public readonly callouts: CalloutsApi; + + constructor(params: SinchClientParameters) { + this.applications = new ApplicationsApi(params); + this.conferences = new ConferencesApi(params); + this.calls = new CallsApi(params); + this.callouts = new CalloutsApi(params); + } + + /** + * Update the default basePath for each API + * + * @param {string} basePath - The new base path to use for all the APIs. + */ + public setBasePath(basePath: string) { + this.applications.setBasePath(basePath); + this.conferences.setBasePath(basePath); + this.calls.setBasePath(basePath); + this.callouts.setBasePath(basePath); + } + + public setRegion(region: VoiceRegion) { + this.applications.setRegion(region); + } +} diff --git a/packages/voice/tests/rest/v1/applications/applications-api.test.ts b/packages/voice/tests/rest/v1/applications/applications-api.test.ts new file mode 100644 index 00000000..71d12d30 --- /dev/null +++ b/packages/voice/tests/rest/v1/applications/applications-api.test.ts @@ -0,0 +1,179 @@ +import { ApiClientOptions, SigningRequest } from '@sinch/sdk-client'; +import { + ApplicationsApi, + ApplicationsApiFixture, AssignNumbersRequestData, + GetCallbacks, + GetCallbackURLsRequestData, + GetNumbersRequestData, + GetNumbersResponseObj, + GetQueryNumber, + QueryNumberRequestData, + UnassignNumberRequestData, + UpdateCallbackURLsRequestData, +} from '../../../../src'; + +describe('ApplicationsApi', () => { + let applicationsApi: ApplicationsApi; + let fixture: ApplicationsApiFixture; + let apiClientOptions: ApiClientOptions; + + beforeEach(() => { + fixture = new ApplicationsApiFixture(); + apiClientOptions = { + requestPlugins: [new SigningRequest('keyId', 'keySecret')], + }; + applicationsApi = new ApplicationsApi(apiClientOptions); + }); + + describe ('queryNumber', () => { + it('should make a GET request to get information about the requested number', async () => { + // Given + const requestData: QueryNumberRequestData = { + number: '+14151112223333', + }; + const expectedResponse: GetQueryNumber = { + method: 'numberItem', + number: { + countryId: 'US', + numberType: 'Mobile', + normalizedNumber: '+14151112223333', + restricted: false, + rate: { + currencyId: 'USD', + amount: 0.368, + }, + }, + }; + + // When + fixture.queryNumber.mockResolvedValue(expectedResponse); + applicationsApi.queryNumber = fixture.queryNumber; + const response = await applicationsApi.queryNumber(requestData); + + // Then + expect(response).toEqual(expectedResponse); + expect(fixture.queryNumber).toHaveBeenCalledWith(requestData); + }); + }); + + describe ('getCallbackURLs', () => { + it('should make a GET request to return any callback URLs configured for the specified application', async () => { + // Given + const requestData: GetCallbackURLsRequestData = { + applicationkey: 'APPLICATION_KEY', + }; + const expectedResponse: GetCallbacks = { + url:{ + primary: 'primaryCallBackUrl', + fallback: 'fallbackCallbackUrl', + }, + }; + + // When + fixture.getCallbackURLs.mockResolvedValue(expectedResponse); + applicationsApi.getCallbackURLs = fixture.getCallbackURLs; + const response = await applicationsApi.getCallbackURLs(requestData); + + // Then + expect(response).toEqual(expectedResponse); + expect(fixture.getCallbackURLs).toHaveBeenCalledWith(requestData); + }); + }); + + describe ('getNumbers', () => { + it('should make a GET request to get information about your numbers', async () => { + // Given + const requestData: GetNumbersRequestData = {}; + const expectedResponse: GetNumbersResponseObj = { + numbers: [ + { + number: '33444555666', + applicationkey: 'APPLICATION_KEY', + capability: 'voice', + }, + ], + }; + + // When + fixture.getNumbers.mockResolvedValue(expectedResponse); + applicationsApi.getNumbers = fixture.getNumbers; + const response = await applicationsApi.getNumbers(requestData); + + // Then + expect(response).toEqual(expectedResponse); + expect(fixture.getNumbers).toHaveBeenCalledWith(requestData); + }); + }); + + describe ('unassignNumber', () => { + it('should make a DELETE request to un-assign a number from an application', async () => { + // Given + const requestData: UnassignNumberRequestData = { + unassignNumbersRequestBody: { + number: '+33444555666', + applicationkey: 'APPLICATION_KEY', + capability: 'voice', + }, + }; + + // When + fixture.unassignNumber.mockResolvedValue(); + applicationsApi.unassignNumber = fixture.unassignNumber; + const response = await applicationsApi.unassignNumber(requestData); + + // Then + expect(response).toBeUndefined(); + expect(fixture.unassignNumber).toHaveBeenCalledWith(requestData); + }); + }); + + describe ('updateCallbackURLs', () => { + it('should make a POST request to update the configured callback URL', async () => { + // Given + const requestData: UpdateCallbackURLsRequestData = { + applicationkey: 'APPLICATION_KEY', + updateCallbacksRequestBody: { + url: { + primary: 'primaryCallBackUrl', + fallback: 'fallbackCallbackUrl', + }, + }, + }; + + + // When + fixture.updateCallbackURLs.mockResolvedValue(); + applicationsApi.updateCallbackURLs = fixture.updateCallbackURLs; + const response = await applicationsApi.updateCallbackURLs(requestData); + + // Then + expect(response).toBeUndefined(); + expect(fixture.updateCallbackURLs).toHaveBeenCalledWith(requestData); + }); + }); + + describe ('updateNumbers', () => { + it('should make a POST request to assign some numbers to an application', async () => { + // Given + const requestData: AssignNumbersRequestData = { + assignNumbersRequestBody: { + numbers: [ + '+33444555666', + '+33777888999', + ], + applicationkey: 'APPLICATION_KEY', + capability: 'voice', + }, + }; + + // When + fixture.assignNumbers.mockResolvedValue(); + applicationsApi.assignNumbers = fixture.assignNumbers; + const response = await applicationsApi.assignNumbers(requestData); + + // Then + expect(response).toBeUndefined(); + expect(fixture.assignNumbers).toHaveBeenCalledWith(requestData); + }); + }); +}); diff --git a/packages/voice/tests/rest/v1/callouts/callouts-api.test.ts b/packages/voice/tests/rest/v1/callouts/callouts-api.test.ts new file mode 100644 index 00000000..fd185681 --- /dev/null +++ b/packages/voice/tests/rest/v1/callouts/callouts-api.test.ts @@ -0,0 +1,115 @@ +import { ApiClientOptions, SigningRequest } from '@sinch/sdk-client'; +import { + CalloutsApi, + CalloutsApiFixture, ConferenceCalloutRequestData, CustomCalloutRequestData, + GetCalloutResponseObj, + TtsCalloutRequestData, +} from '../../../../src'; + +describe('CalloutsApi', () => { + let calloutsApi: CalloutsApi; + let fixture: CalloutsApiFixture; + let apiClientOptions: ApiClientOptions; + + beforeEach(() => { + fixture = new CalloutsApiFixture(); + apiClientOptions = { + requestPlugins: [new SigningRequest('keyId', 'keySecret')], + }; + calloutsApi = new CalloutsApi(apiClientOptions); + }); + + describe ('TTS callouts', () => { + it('should make a POST request to make a TTS callout to a phone number', async () => { + // Given + const requestData: TtsCalloutRequestData = { + ttsCalloutRequestBody: { + method: 'ttsCallout', + ttsCallout: { + cli: '+14045001000', + destination: { + type: 'number', + endpoint: '+14045005000', + }, + domain: 'pstn', + text: 'text to speech', + }, + }, + }; + const expectedResponse: GetCalloutResponseObj = { + callId: 'callId', + }; + + // When + fixture.tts.mockResolvedValue(expectedResponse); + calloutsApi.tts = fixture.tts; + const response = await calloutsApi.tts(requestData); + + // Then + expect(response).toEqual(expectedResponse); + expect(fixture.tts).toHaveBeenCalledWith(requestData); + }); + }); + + describe ('Conference callouts', () => { + it('should make a POST request to make a conference callout to a phone number', async () => { + // Given + const requestData: ConferenceCalloutRequestData = { + conferenceCalloutRequestBody: { + method: 'conferenceCallout', + conferenceCallout: { + cli: '+14045001000', + conferenceId: 'conferenceId', + destination: { + type: 'number', + endpoint: '+14045005000', + }, + domain: 'pstn', + }, + }, + }; + const expectedResponse: GetCalloutResponseObj = { + callId: 'callId', + }; + + // When + fixture.conference.mockResolvedValue(expectedResponse); + calloutsApi.conference = fixture.conference; + const response = await calloutsApi.conference(requestData); + + // Then + expect(response).toEqual(expectedResponse); + expect(fixture.conference).toHaveBeenCalledWith(requestData); + }); + }); + + describe ('Custom callouts', () => { + it('should make a POST request to make a Custom callout to a phone number', async () => { + // Given + const requestData: CustomCalloutRequestData = { + customCalloutRequestBody: { + method: 'customCallout', + customCallout: { + cli: '+14045001000', + destination: { + type: 'number', + endpoint: '+14045005000', + }, + }, + }, + }; + const expectedResponse: GetCalloutResponseObj = { + callId: 'callId', + }; + + // When + fixture.custom.mockResolvedValue(expectedResponse); + calloutsApi.custom = fixture.custom; + const response = await calloutsApi.custom(requestData); + + // Then + expect(response).toEqual(expectedResponse); + expect(fixture.custom).toHaveBeenCalledWith(requestData); + }); + }); +}); diff --git a/packages/voice/tests/rest/v1/calls/calls-api.test.ts b/packages/voice/tests/rest/v1/calls/calls-api.test.ts new file mode 100644 index 00000000..10ea4871 --- /dev/null +++ b/packages/voice/tests/rest/v1/calls/calls-api.test.ts @@ -0,0 +1,131 @@ +import { ApiClientOptions, SigningRequest } from '@sinch/sdk-client'; +import { + CallsApi, + CallsApiFixture, + GetCallResponseObj, + GetCallResultRequestData, + ManageWithCallLegRequestData, + SvamlAction, + SvamlActionHangup, + SvamlInstruction, + SvamlInstructionSay, + SvamlInstructionSendDtmf, + UpdateCallRequestData, +} from '../../../../src'; + +describe('CallsApi', () => { + let callsApi: CallsApi; + let fixture: CallsApiFixture; + let apiClientOptions: ApiClientOptions; + + beforeEach(() => { + fixture = new CallsApiFixture(); + apiClientOptions = { + requestPlugins: [new SigningRequest('keyId', 'keySecret')], + }; + callsApi = new CallsApi(apiClientOptions); + }); + + describe ('getCallResult', () => { + it('should make a GET request to retrieve information about a call', async () => { + // Given + const requestData: GetCallResultRequestData = { + callId: 'callId', + }; + const expectedResponse: GetCallResponseObj = { + callId: 'callId', + to: { + type: 'Number', + endpoint: '33777888999', + }, + domain: 'pstn', + duration: 30, + status: 'FINAL', + result: 'ANSWERED', + reason: 'CALLERHANGUP', + timestamp: new Date(), + userRate: { + currencyId: 'EUR', + amount: 0.1758, + }, + debit: { + currencyId: 'EUR', + amount: 0.1758, + }, + }; + + // When + fixture.get.mockResolvedValue(expectedResponse); + callsApi.get = fixture.get; + const response = await callsApi.get(requestData); + + // Then + expect(response).toEqual(expectedResponse); + expect(fixture.get).toHaveBeenCalledWith(requestData); + }); + }); + + describe ('manageCallWithCallLeg', () => { + it('should make a PATCH request to manage calls', async () => { + // Given + const instruction: SvamlInstruction = { + name: 'say', + text: 'Hello, the call is over, hanging up now. Goodbye', + locale: 'en-US', + } as SvamlInstructionSay; + const action: SvamlAction = { + name: 'hangup', + } as SvamlActionHangup; + const requestData: ManageWithCallLegRequestData = { + callId: 'callId', + callLeg: 'caller', + svamlRequestBody: { + instructions: [ + instruction, + ], + action, + }, + }; + + // When + fixture.manageWithCallLeg.mockResolvedValue(); + callsApi.manageWithCallLeg = fixture.manageWithCallLeg; + const response = await callsApi.manageWithCallLeg(requestData); + + // Then + expect(response).toBeUndefined(); + expect(fixture.manageWithCallLeg).toHaveBeenCalledWith(requestData); + }); + }); + + describe ('updateCall', () => { + it('should make a PATCH request to manage a call in progress', async () => { + // Given + const instruction: SvamlInstruction = { + name: 'sendDtmf', + value: '1234#', + } as SvamlInstructionSendDtmf; + const action: SvamlAction = { + name: 'hangup', + } as SvamlActionHangup; + const requestData: UpdateCallRequestData = { + callId: 'callId', + svamlRequestBody: { + instructions: [ + instruction, + ], + action, + }, + }; + + // When + fixture.update.mockResolvedValue(); + callsApi.update = fixture.update; + const response = await callsApi.update(requestData); + + // Then + expect(response).toBeUndefined(); + expect(fixture.update).toHaveBeenCalledWith(requestData); + }); + }); +}); diff --git a/packages/voice/tests/rest/v1/conferences/conferences-api.test.ts b/packages/voice/tests/rest/v1/conferences/conferences-api.test.ts new file mode 100644 index 00000000..628f37f7 --- /dev/null +++ b/packages/voice/tests/rest/v1/conferences/conferences-api.test.ts @@ -0,0 +1,121 @@ +import { ApiClientOptions, SigningRequest } from '@sinch/sdk-client'; +import { + ConferencesApi, + ConferencesApiFixture, + GetConferenceInfoResponse, + GetConferenceInfoRequestData, + KickAllRequestData, + KickParticipantRequestData, + ManageParticipantRequestData, +} from '../../../../src'; + + +describe('ConferencesApi', () => { + let conferencesApi: ConferencesApi; + let fixture: ConferencesApiFixture; + let apiClientOptions: ApiClientOptions; + + beforeEach(() => { + fixture = new ConferencesApiFixture(); + apiClientOptions = { + requestPlugins: [new SigningRequest('keyId', 'keySecret')], + }; + conferencesApi = new ConferencesApi(apiClientOptions); + }); + + describe ('getConferenceInfo', () => { + it('should make a GET request to ...', async () => { + // Given + const requestData: GetConferenceInfoRequestData = { + conferenceId: 'conferenceId', + }; + const expectedResponse: GetConferenceInfoResponse = { + participants: [ + { + cli: '+46708168731', + id: 'myConfId', + duration: 14, + muted: false, + onhold: false, + }, + { + cli: 'myUserName', + id: 'myConfId2', + duration: 12, + muted: false, + onhold: false, + }, + ], + }; + + // When + fixture.get.mockResolvedValue(expectedResponse); + conferencesApi.get = fixture.get; + const response = await conferencesApi.get(requestData); + + // Then + expect(response).toEqual(expectedResponse); + expect(fixture.get).toHaveBeenCalledWith(requestData); + }); + }); + + describe ('kickConferenceAll', () => { + it('should make a DELETE request to remove all participants from a conference', async () => { + // Given + const requestData: KickAllRequestData = { + conferenceId: 'conferenceId', + }; + + // When + fixture.kickAll.mockResolvedValue(); + conferencesApi.kickAll = fixture.kickAll; + const response = await conferencesApi.kickAll(requestData); + + // Then + expect(response).toBeUndefined(); + expect(fixture.kickAll).toHaveBeenCalledWith(requestData); + }); + }); + + describe ('kickConferenceParticipant', () => { + it('should make a DELETE request to remove the specified participant from a conference', async () => { + // Given + const requestData: KickParticipantRequestData = { + conferenceId: 'conferenceId', + callId: 'callId', + }; + + // When + fixture.kickParticipant.mockResolvedValue(); + conferencesApi.kickParticipant = fixture.kickParticipant; + const response = await conferencesApi.kickParticipant(requestData); + + // Then + expect(response).toBeUndefined(); + expect(fixture.kickParticipant).toHaveBeenCalledWith(requestData); + }); + }); + + describe ('manageConferenceParticipant', () => { + it('should make a PATCH request to manage a conference participant', async () => { + // Given + const requestData: ManageParticipantRequestData = { + callId: 'callId', + conferenceId: 'conferenceId', + manageParticipantRequestBody: { + command: 'mute', + moh: 'ring', + }, + }; + + // When + fixture.kickParticipant.mockResolvedValue(); + conferencesApi.kickParticipant = fixture.kickParticipant; + const response = await conferencesApi.kickParticipant(requestData); + + // Then + expect(response).toBeUndefined(); + expect(fixture.kickParticipant).toHaveBeenCalledWith(requestData); + }); + }); +});