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

SWI-4587 Add transferCallerDisplayName to Transfer Verb #87

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions src/bxml/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Verb } from './Verb'
export interface TransferOptions {
transferCallerId?: string

transferCallerDisplayName?: string

callTimeout?: number

tag?: string
Expand Down Expand Up @@ -36,6 +38,8 @@ export interface TransferOptions {
export class Transfer implements TransferOptions, Verb {
transferCallerId?: string

transferCallerDisplayName?: string

callTimeout?: number

tag?: string
Expand Down Expand Up @@ -77,6 +81,7 @@ export class Transfer implements TransferOptions, Verb {
this.username = options.username
this.tag = options.tag
this.transferCallerId = options.transferCallerId
this.transferCallerDisplayName = options.transferCallerDisplayName
this.transferCompleteFallbackMethod = options.transferCompleteFallbackMethod
this.transferCompleteFallbackUrl = options.transferCompleteFallbackUrl
this.transferCompleteMethod = options.transferCompleteMethod
Expand All @@ -90,6 +95,10 @@ export class Transfer implements TransferOptions, Verb {
attributes['transferCallerId'] = this.transferCallerId
}

if (this.transferCallerDisplayName !== undefined) {
attributes['transferCallerDisplayName'] = this.transferCallerDisplayName
}

if (this.callTimeout !== undefined) {
attributes['callTimeout'] = `${this.callTimeout}`
}
Expand Down
3 changes: 2 additions & 1 deletion tests/bxml.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ describe("Transfer", () => {

var transfer = new Transfer({
transferCallerId: "+18888888888",
transferCallerDisplayName: "test",
callTimeout: 3,
tag: "tagTransfer",
transferCompleteUrl: "https://testtransfer.com",
Expand All @@ -399,7 +400,7 @@ describe("Transfer", () => {

var response = new Response(transfer);

var expectedString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response><Transfer transferCallerId=\"+18888888888\" callTimeout=\"3\" tag=\"tagTransfer\" transferCompleteUrl=\"https://testtransfer.com\" transferCompleteMethod=\"GET\" username=\"usertransfer\" password=\"passtransfer\" diversionTreatment=\"none\" diversionReason=\"away\" transferCompleteFallbackUrl=\"https://test.com\" transferCompleteFallbackMethod=\"POST\" fallbackUsername=\"fusern\" fallbackPassword=\"fpassw\"><PhoneNumber transferAnswerUrl=\"https://test.com\" transferAnswerMethod=\"GET\" username=\"user\" password=\"pass\" tag=\"tag\" transferAnswerFallbackUrl=\"https://test2.com\" transferAnswerFallbackMethod=\"GET\" fallbackUsername=\"fuser\" fallbackPassword=\"fpass\">+17777777777</PhoneNumber><SipUri uui=\"uui\" transferAnswerUrl=\"https://test3.com\" transferAnswerMethod=\"POST\" transferAnswerFallbackUrl=\"https://test4.com\" transferAnswerFallbackMethod=\"POST\" username=\"user2\" password=\"pass2\" fallbackUsername=\"fuser2\" fallbackPassword=\"fpass4\" tag=\"tag2\">sip-uri</SipUri></Transfer></Response>";
var expectedString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response><Transfer transferCallerId=\"+18888888888\" transferCallerDisplayName=\"test\" callTimeout=\"3\" tag=\"tagTransfer\" transferCompleteUrl=\"https://testtransfer.com\" transferCompleteMethod=\"GET\" username=\"usertransfer\" password=\"passtransfer\" diversionTreatment=\"none\" diversionReason=\"away\" transferCompleteFallbackUrl=\"https://test.com\" transferCompleteFallbackMethod=\"POST\" fallbackUsername=\"fusern\" fallbackPassword=\"fpassw\"><PhoneNumber transferAnswerUrl=\"https://test.com\" transferAnswerMethod=\"GET\" username=\"user\" password=\"pass\" tag=\"tag\" transferAnswerFallbackUrl=\"https://test2.com\" transferAnswerFallbackMethod=\"GET\" fallbackUsername=\"fuser\" fallbackPassword=\"fpass\">+17777777777</PhoneNumber><SipUri uui=\"uui\" transferAnswerUrl=\"https://test3.com\" transferAnswerMethod=\"POST\" transferAnswerFallbackUrl=\"https://test4.com\" transferAnswerFallbackMethod=\"POST\" username=\"user2\" password=\"pass2\" fallbackUsername=\"fuser2\" fallbackPassword=\"fpass4\" tag=\"tag2\">sip-uri</SipUri></Transfer></Response>";
expect(response.toBxml()).toEqual(expectedString);
});
});
Expand Down
Loading