diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 3573294..e5a9441 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -182,6 +182,8 @@ docs/RecordingTranscriptions.md docs/RecordingsApi.md docs/RedirectCallback.md docs/RedirectMethodEnum.md +docs/ReferCallStatus.md +docs/ReferCompleteCallback.md docs/SipConnectionMetadata.md docs/SipCredentials.md docs/SmsMessageContent.md @@ -387,6 +389,8 @@ models/recording-transcription-metadata.ts models/recording-transcriptions.ts models/redirect-callback.ts models/redirect-method-enum.ts +models/refer-call-status.ts +models/refer-complete-callback.ts models/sip-connection-metadata.ts models/sip-credentials.ts models/sms-message-content.ts diff --git a/README.md b/README.md index 9f024b8..d3b6f40 100644 --- a/README.md +++ b/README.md @@ -322,6 +322,8 @@ Class | Method | HTTP request | Description - [RecordingTranscriptions](docs/RecordingTranscriptions.md) - [RedirectCallback](docs/RedirectCallback.md) - [RedirectMethodEnum](docs/RedirectMethodEnum.md) + - [ReferCallStatus](docs/ReferCallStatus.md) + - [ReferCompleteCallback](docs/ReferCompleteCallback.md) - [SipConnectionMetadata](docs/SipConnectionMetadata.md) - [SipCredentials](docs/SipCredentials.md) - [SmsMessageContent](docs/SmsMessageContent.md) diff --git a/bandwidth.yml b/bandwidth.yml index fd39c5c..c928265 100644 --- a/bandwidth.yml +++ b/bandwidth.yml @@ -5303,6 +5303,66 @@ components: $ref: '#/components/schemas/errorMessage' errorId: $ref: '#/components/schemas/errorId' + referCompleteCallback: + type: object + description: >- + The Refer Complete event is fired when the verb finishes + executing. This is sent to the referCompleteUrl specified on the + verb, and the BXML returned in it is executed on the call. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + accountId: + $ref: '#/components/schemas/accountId' + applicationId: + $ref: '#/components/schemas/applicationId1' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + direction: + $ref: '#/components/schemas/callDirectionEnum' + callId: + $ref: '#/components/schemas/callId' + callUrl: + $ref: '#/components/schemas/callUrl' + startTime: + $ref: '#/components/schemas/startTime' + answerTime: + $ref: '#/components/schemas/answerTime' + tag: + $ref: '#/components/schemas/tag1' + referCallStatus: + $ref: '#/components/schemas/referCallStatus' + referSipResponseCode: + $ref: '#/components/schemas/referSipResponseCode' + notifySipResponseCode: + $ref: '#/components/schemas/notifySipResponseCode' + referCallStatus: + type: string + description: >- + The outcome of the REFER attempt. Possible values are success or + failure. + enum: + - success + - failure + example: success + referSipResponseCode: + type: integer + nullable: true + description: >- + The SIP response code received for the REFER request (e.g. 202, 405, + 603). Absent when not applicable. + example: 202 + notifySipResponseCode: + type: integer + nullable: true + description: >- + The SIP response code received in the NOTIFY message (e.g. 200, 404, + 486). Absent on REFER rejection or NOTIFY timeout. + example: 200 eventType: type: string description: >- @@ -5311,8 +5371,8 @@ components: conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, - recordingAvailable, redirect, transcriptionAvailable, transferAnswer, - transferComplete, transferDisconnect. + recordingAvailable, redirect, referComplete, transcriptionAvailable, + transferAnswer, transferComplete, transferDisconnect. example: bridgeComplete eventTime: type: string diff --git a/docs/ReferCallStatus.md b/docs/ReferCallStatus.md new file mode 100644 index 0000000..8bb584f --- /dev/null +++ b/docs/ReferCallStatus.md @@ -0,0 +1,11 @@ +# ReferCallStatus + +The outcome of the REFER attempt. Possible values are success or failure. + +## Enum + +* `Success` (value: `'success'`) + +* `Failure` (value: `'failure'`) + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/ReferCompleteCallback.md b/docs/ReferCompleteCallback.md new file mode 100644 index 0000000..dff137b --- /dev/null +++ b/docs/ReferCompleteCallback.md @@ -0,0 +1,49 @@ +# ReferCompleteCallback + +The Refer Complete event is fired when the verb finishes executing. This is sent to the referCompleteUrl specified on the verb, and the BXML returned in it is executed on the call. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**eventType** | **string** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, referComplete, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] [default to undefined] +**eventTime** | **string** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] [default to undefined] +**accountId** | **string** | The user account associated with the call. | [optional] [default to undefined] +**applicationId** | **string** | The id of the application associated with the call. | [optional] [default to undefined] +**from** | **string** | The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555). | [optional] [default to undefined] +**to** | **string** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] [default to undefined] +**direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] [default to undefined] +**callId** | **string** | The call id associated with the event. | [optional] [default to undefined] +**callUrl** | **string** | The URL of the call associated with the event. | [optional] [default to undefined] +**startTime** | **string** | Time the call was started, in ISO 8601 format. | [optional] [default to undefined] +**answerTime** | **string** | Time the call was answered, in ISO 8601 format. | [optional] [default to undefined] +**tag** | **string** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] [default to undefined] +**referCallStatus** | [**ReferCallStatus**](ReferCallStatus.md) | | [optional] [default to undefined] +**referSipResponseCode** | **number** | The SIP response code received for the REFER request (e.g. 202, 405, 603). Absent when not applicable. | [optional] [default to undefined] +**notifySipResponseCode** | **number** | The SIP response code received in the NOTIFY message (e.g. 200, 404, 486). Absent on REFER rejection or NOTIFY timeout. | [optional] [default to undefined] + +## Example + +```typescript +import { ReferCompleteCallback } from 'bandwidth-sdk'; + +const instance: ReferCompleteCallback = { + eventType, + eventTime, + accountId, + applicationId, + from, + to, + direction, + callId, + callUrl, + startTime, + answerTime, + tag, + referCallStatus, + referSipResponseCode, + notifySipResponseCode, +}; +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/models/bxml/verbs/Refer.ts b/models/bxml/verbs/Refer.ts new file mode 100644 index 0000000..97d8340 --- /dev/null +++ b/models/bxml/verbs/Refer.ts @@ -0,0 +1,38 @@ +import { NestableVerb } from '../NestableVerb'; +import { ReferSipUri } from './ReferSipUri'; + +export interface ReferAttributes { + referCompleteUrl?: string; + referCompleteMethod?: string; + tag?: string; +} + +/** + * @export + * @class Refer + * @extends {NestableVerb} + * Represents a Refer BXML verb. + * NOTE: On success the call is terminated — the remote SIP endpoint redirects away from Bandwidth. + * Recovery BXML in referCompleteUrl only makes sense for failure handling. + */ +export class Refer extends NestableVerb { + attributes: ReferAttributes; + + /** + * Creates an instance of Refer + * @param {ReferSipUri} sipUri The SipUri child element (required — spec mandates exactly one) + * @param {ReferAttributes} attributes The attributes to add to the element + */ + constructor(sipUri: ReferSipUri, attributes?: ReferAttributes) { + super('Refer', undefined, attributes, [sipUri]); + } + + /** + * Set the SipUri for this Refer verb + * @param {ReferSipUri} sipUri The SipUri to refer to + */ + setSipUri(sipUri: ReferSipUri): void { + // Replaces the single required SipUri child — allows exactly one. + this.nestedVerbs = [sipUri]; + } +} diff --git a/models/bxml/verbs/ReferSipUri.ts b/models/bxml/verbs/ReferSipUri.ts new file mode 100644 index 0000000..1f26b83 --- /dev/null +++ b/models/bxml/verbs/ReferSipUri.ts @@ -0,0 +1,22 @@ +import { Verb } from '../Verb'; + +/** + * @export + * @class ReferSipUri + * @extends {Verb} + * Represents a SipUri child element scoped to the Refer verb. + * Unlike the Transfer-scoped SipUri, this accepts only a URI — no + * transferAnswerUrl, uui, username/password, or other Transfer attributes. + */ +export class ReferSipUri extends Verb { + uri: string; + + /** + * Creates an instance of ReferSipUri + * @param {string} uri The SIP URI to refer to (must start with sip:) + */ + constructor(uri: string) { + super('SipUri', uri); + } +} + diff --git a/models/bxml/verbs/index.ts b/models/bxml/verbs/index.ts index 4dd67a4..0740998 100644 --- a/models/bxml/verbs/index.ts +++ b/models/bxml/verbs/index.ts @@ -12,6 +12,8 @@ export * from './PhoneNumber'; export * from './PlayAudio'; export * from './Record'; export * from './Redirect'; +export * from './Refer'; +export * from './ReferSipUri'; export * from './ResumeRecording'; export * from './Ring'; export * from './SendDtmf'; diff --git a/models/index.ts b/models/index.ts index 2c25029..b86dae0 100644 --- a/models/index.ts +++ b/models/index.ts @@ -155,6 +155,8 @@ export * from './recording-transcription-metadata'; export * from './recording-transcriptions'; export * from './redirect-callback'; export * from './redirect-method-enum'; +export * from './refer-call-status'; +export * from './refer-complete-callback'; export * from './sip-connection-metadata'; export * from './sip-credentials'; export * from './sms-message-content'; diff --git a/models/refer-call-status.ts b/models/refer-call-status.ts new file mode 100644 index 0000000..81c8292 --- /dev/null +++ b/models/refer-call-status.ts @@ -0,0 +1,29 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Bandwidth + * Bandwidth\'s Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +/** + * The outcome of the REFER attempt. Possible values are success or failure. + */ + +export const ReferCallStatus = { + Success: 'success', + Failure: 'failure' +} as const; + +export type ReferCallStatus = typeof ReferCallStatus[keyof typeof ReferCallStatus]; + + + diff --git a/models/refer-complete-callback.ts b/models/refer-complete-callback.ts new file mode 100644 index 0000000..a073737 --- /dev/null +++ b/models/refer-complete-callback.ts @@ -0,0 +1,84 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Bandwidth + * Bandwidth\'s Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +// May contain unused imports in some cases +// @ts-ignore +import type { CallDirectionEnum } from './call-direction-enum'; +// May contain unused imports in some cases +// @ts-ignore +import type { ReferCallStatus } from './refer-call-status'; + +/** + * The Refer Complete event is fired when the verb finishes executing. This is sent to the referCompleteUrl specified on the verb, and the BXML returned in it is executed on the call. + */ +export interface ReferCompleteCallback { + /** + * The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, referComplete, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + */ + 'eventType'?: string; + /** + * The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + */ + 'eventTime'?: string; + /** + * The user account associated with the call. + */ + 'accountId'?: string; + /** + * The id of the application associated with the call. + */ + 'applicationId'?: string; + /** + * The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555). + */ + 'from'?: string; + /** + * The phone number that received the call, in E.164 format (e.g. +15555555555). + */ + 'to'?: string; + 'direction'?: CallDirectionEnum; + /** + * The call id associated with the event. + */ + 'callId'?: string; + /** + * The URL of the call associated with the event. + */ + 'callUrl'?: string; + /** + * Time the call was started, in ISO 8601 format. + */ + 'startTime'?: string; + /** + * Time the call was answered, in ISO 8601 format. + */ + 'answerTime'?: string | null; + /** + * (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + */ + 'tag'?: string | null; + 'referCallStatus'?: ReferCallStatus; + /** + * The SIP response code received for the REFER request (e.g. 202, 405, 603). Absent when not applicable. + */ + 'referSipResponseCode'?: number | null; + /** + * The SIP response code received in the NOTIFY message (e.g. 200, 404, 486). Absent on REFER rejection or NOTIFY timeout. + */ + 'notifySipResponseCode'?: number | null; +} + + + diff --git a/tests/unit/models/bxml/verbs/Refer.test.ts b/tests/unit/models/bxml/verbs/Refer.test.ts new file mode 100644 index 0000000..f763f4b --- /dev/null +++ b/tests/unit/models/bxml/verbs/Refer.test.ts @@ -0,0 +1,42 @@ +import { Refer, ReferAttributes } from '../../../../../models/bxml/verbs/Refer'; +import { ReferSipUri } from '../../../../../models/bxml/verbs/ReferSipUri'; + +describe('Refer', () => { + test('should generate Refer XML with SipUri and all attributes', () => { + const attributes: ReferAttributes = { + referCompleteUrl: 'https://example.com/handleRefer', + referCompleteMethod: 'POST', + tag: 'my-tag', + }; + const sipUri = new ReferSipUri('sip:alice@atlanta.example.com'); + const refer = new Refer(sipUri, attributes); + + const xml = refer.toBxml(); + expect(xml).toContain('sip:alice@atlanta.example.com'); + expect(xml).toContain(''); + }); + + test('should generate Refer XML with no attributes', () => { + const sipUri = new ReferSipUri('sip:bob@biloxi.example.com'); + const refer = new Refer(sipUri); + + const xml = refer.toBxml(); + expect(xml).toContain(''); + expect(xml).toContain('sip:bob@biloxi.example.com'); + }); + + test('setSipUri should replace the nested SipUri', () => { + const sipUri1 = new ReferSipUri('sip:alice@atlanta.example.com'); + const sipUri2 = new ReferSipUri('sip:bob@biloxi.example.com'); + const refer = new Refer(sipUri1); + + refer.setSipUri(sipUri2); + const xml = refer.toBxml(); + expect(xml).not.toContain('alice'); + expect(xml).toContain('sip:bob@biloxi.example.com'); + }); +});