-
Notifications
You must be signed in to change notification settings - Fork 0
VAPI-3165 Add Refer BXML verb support #118
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
Open
s-aher
wants to merge
7
commits into
main
Choose a base branch
from
VAPI-3165
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c72c181
VAPI-3165 Add Refer BXML verb implementation and tests
s-aher 2b31ce6
Merge branch 'main' of github.com:Bandwidth/node-sdk into VAPI-3165
s-aher 95909f7
VAPI-3165 Update bandwidth.yaml and models for sip refer
s-aher e139ddd
Merge branch 'main' into VAPI-3165
s-aher d3414d9
Merge remote-tracking branch 'origin/VAPI-3165' into VAPI-3165
s-aher 785428c
VAPI-3165 fixed review comments
s-aher 29d1572
Merge branch 'main' into VAPI-3165
s-aher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { NestableVerb } from '../NestableVerb'; | ||
| import { SipUri } from './SipUri'; | ||
|
|
||
| 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 {ReferAttributes} attributes The attributes to add to the element | ||
| * @param {SipUri} sipUri The SipUri child element (required for a valid Refer) | ||
| */ | ||
| constructor(attributes?: ReferAttributes, sipUri?: SipUri) { | ||
|
s-aher marked this conversation as resolved.
Outdated
|
||
| super('Refer', undefined, attributes, sipUri ? [sipUri] : undefined); | ||
| } | ||
|
|
||
| /** | ||
| * Set the SipUri for this Refer verb | ||
| * @param {SipUri} sipUri The SipUri to refer to | ||
| */ | ||
| setSipUri(sipUri: SipUri): void { | ||
| this.nestedVerbs = [sipUri]; | ||
|
s-aher marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { Refer, ReferAttributes } from '../../../../../models/bxml/verbs/Refer'; | ||
| import { SipUri } from '../../../../../models/bxml/verbs/SipUri'; | ||
|
|
||
| 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 SipUri('sip:alice@atlanta.example.com'); | ||
| const refer = new Refer(attributes, sipUri); | ||
|
|
||
| const xml = refer.toBxml(); | ||
| expect(xml).toContain('<Refer'); | ||
| expect(xml).toContain('referCompleteUrl="https://example.com/handleRefer"'); | ||
| expect(xml).toContain('referCompleteMethod="POST"'); | ||
| expect(xml).toContain('tag="my-tag"'); | ||
| expect(xml).toContain('<SipUri>sip:alice@atlanta.example.com</SipUri>'); | ||
| expect(xml).toContain('</Refer>'); | ||
| }); | ||
|
|
||
| test('should generate Refer XML with no attributes', () => { | ||
| const sipUri = new SipUri('sip:bob@biloxi.example.com'); | ||
| const refer = new Refer(undefined, sipUri); | ||
|
|
||
| const xml = refer.toBxml(); | ||
| expect(xml).toContain('<Refer>'); | ||
| expect(xml).toContain('<SipUri>sip:bob@biloxi.example.com</SipUri>'); | ||
| }); | ||
|
|
||
| test('setSipUri should replace the nested SipUri', () => { | ||
| const sipUri1 = new SipUri('sip:alice@atlanta.example.com'); | ||
| const sipUri2 = new SipUri('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'); | ||
| }); | ||
| }); | ||
|
|
||
|
s-aher marked this conversation as resolved.
Outdated
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.