Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEVEXP-269 (Part 1/2): Refactor Voice models #24

Merged
merged 5 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { GetNumbersRequestData } from '@sinch/sdk-core';
const sinchClient = initApplicationClient();
let response;
try {
response = await sinchClient.voice.applications.getNumbers(requestData);
response = await sinchClient.voice.applications.listNumbers(requestData);
} catch (error) {
console.log(`Impossible to get information about your numbers`);
throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { ManageWithCallLegRequestData, VoiceRegion } from '@sinch/sdk-core';
const requestData: ManageWithCallLegRequestData = {
callId,
callLeg: 'callee',
svamlRequestBody: {
manageWithCallLegRequestBody: {
instructions: [
{
name: 'say',
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-examples/src/voice/calls/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { UpdateCallRequestData, VoiceRegion } from '@sinch/sdk-core';

const requestData: UpdateCallRequestData = {
callId,
svamlRequestBody: {
updateCallRequestBody: {
instructions: [
{
name: 'sendDtmf',
Expand Down
22 changes: 0 additions & 22 deletions packages/voice/src/models/v1/ace-request-amd/ace-request-amd.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/voice/src/models/v1/ace-request-amd/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/voice/src/models/v1/ace-request/index.ts

This file was deleted.

26 changes: 0 additions & 26 deletions packages/voice/src/models/v1/ace-response/ace-response.ts

This file was deleted.

13 changes: 1 addition & 12 deletions packages/voice/src/models/v1/assign-numbers/assign-numbers.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
/**
* Model: AssignNumbers
*
* THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT.
*
*/


export interface AssignNumbers {

/** 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;
capability?: 'voice' | 'sms';
}

export type CapabilityEnum = 'voice' | 'sms';

10 changes: 0 additions & 10 deletions packages/voice/src/models/v1/call-header/call-header.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/**
* 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.
*/
Expand All @@ -16,5 +8,3 @@ export interface CallHeader {
/** The call header value of the key value pair. */
value?: string;
}


31 changes: 31 additions & 0 deletions packages/voice/src/models/v1/call-object/call-object.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ReasonEnum, ResultEnum } from '../enums';
import { VoicePrice } from '../voice-price';
import { Participant } from '../participant';

export interface CallObject {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me some time to identify what mean "CallObject" and it usage.
Finally have to ensure I was right by looking at the OAS file details to identify it is the getCallResponseObj schema.
So finally, may be it could mean the name should convey more information for auto-documentation purpose and readability for maintainers

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming is a complicated task :)
The main object here is a 'Call' which is also the name of the service 'Calls' and also the verb 'call'. This is why I've added the suffix 'Object' to be clear about which kind of call it was and to avoid a naming conflict.
Then, the operationId is Calling_GetCallResult but here "Result" doesn't mean "Response" but rather "Status" which confused me too. The response object defined in the specification is getCallResponseObj which is "the object that represents the response of a getCall (status) query". So I thought to name it "CallResponse" but then it would be confusing with the actions of the "Call" service.
Long story short: what do you think about CallInformation?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes; and it is not so far from documentation related to operation: Get information about a call

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. In the end it's GetCallInformation as it is the result of a GET call, such as "get callbacks" for instance


/** Contains the caller information. */
from?: Participant;
/** Contains the callee information. */
to?: Participant;
/** Must be `pstn` for PSTN. */
domain?: 'pstn';
/** 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?: 'ONGOING' | 'FINAL';
/** 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?: string;
/** The rate per minute that was charged for the call. */
userRate?: VoicePrice;
/** The total amount charged for the call. */
debit?: VoicePrice;
}
1 change: 1 addition & 0 deletions packages/voice/src/models/v1/call-object/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type { CallObject } from './call-object';
28 changes: 0 additions & 28 deletions packages/voice/src/models/v1/callout-request/callout-request.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/voice/src/models/v1/callout-request/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* The returned call ID.
*/
export interface CalloutResponse {

/** The returned call identifier. */
callId?: string;
}


1 change: 1 addition & 0 deletions packages/voice/src/models/v1/callout-response/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type { CalloutResponse } from './callout-response';

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
/**
* Model: ConferenceCalloutRequest
*
* THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT.
*
*/

import { ConferenceCalloutRequestConferenceDtmfOptions } from '../conference-callout-request-conference-dtmf-options';
import { Destination } from '../destination';
import { ConferenceDtmfOptions } from '../conference-dtmf-options';

/**
* The conference callout calls a phone number or a user. When the call is answered, it's connected to a conference room.
Expand All @@ -19,8 +12,8 @@ export interface ConferenceCalloutRequest {
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;
/** 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). */
conferenceDtmfOptions?: ConferenceDtmfOptions;
/** 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;
Expand All @@ -41,5 +34,3 @@ export interface ConferenceCalloutRequest {
/** can be either “pstn” for PSTN endpoint or “mxp” for data (app or web) clients. */
domain?: string;
}


Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
/**
* 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 {
export interface ConferenceDtmfOptions {

/** Determines what DTMF mode the participant will use in the call. */
mode?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type { ConferenceDtmfOptions } from './conference-dtmf-options';
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
/**
* Model: CustomCalloutRequest
*
* THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT.
*
*/

import { Destination } from '../destination';

/**
Expand All @@ -29,5 +22,3 @@ export interface CustomCalloutRequest {
/** <b>Note:</b> 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;
}


13 changes: 1 addition & 12 deletions packages/voice/src/models/v1/destination/destination.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
/**
* 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;
type: 'number' | 'username';
/** 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';

This file was deleted.

1 change: 0 additions & 1 deletion packages/voice/src/models/v1/dice-request-debit/index.ts

This file was deleted.

This file was deleted.

This file was deleted.

30 changes: 0 additions & 30 deletions packages/voice/src/models/v1/enums.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,3 @@
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,
} 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 './assign-numbers/assign-numbers';
export type {
CommandEnum as ManageConferenceParticipantRequestCommandEnum,
MohEnum as ManageConferenceParticipantRequestMohEnum,
} from './manage-conference-participant-request/manage-conference-participant-request';

export type ResultEnum = 'N/A' | 'ANSWERED' | 'BUSY' | 'NOANSWER' | 'FAILED';

export type ReasonEnum = 'N/A'
Expand Down
Loading
Loading