Skip to content

Commit 686478d

Browse files
committed
VAPI-3162
1 parent cb915a0 commit 686478d

3 files changed

Lines changed: 87 additions & 0 deletions

File tree

custom_templates/gem.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ require 'bandwidth-sdk/models/bxml/verbs/phone_number'
5353
require 'bandwidth-sdk/models/bxml/verbs/play_audio'
5454
require 'bandwidth-sdk/models/bxml/verbs/record'
5555
require 'bandwidth-sdk/models/bxml/verbs/redirect'
56+
require 'bandwidth-sdk/models/bxml/verbs/refer'
5657
require 'bandwidth-sdk/models/bxml/verbs/resume_recording'
5758
require 'bandwidth-sdk/models/bxml/verbs/ring'
5859
require 'bandwidth-sdk/models/bxml/verbs/send_dtmf'
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module Bandwidth
2+
module Bxml
3+
class Refer < Bandwidth::Bxml::NestableVerb
4+
# Initializer
5+
# @param sip_uri [SipUri] or [Array<SipUri>] XML element children. Defaults to an empty array. Valid nested verb is: SipUri.
6+
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
7+
def initialize(sip_uri = [], attributes = {})
8+
super('Refer', nil, sip_uri, attributes)
9+
10+
@attribute_map = {
11+
refer_complete_url: 'referCompleteUrl', # Optional [String]: URL to send the Refer Complete event to and request new BXML. May be a relative URL.
12+
refer_complete_method: 'referCompleteMethod', # Optional [String]: The HTTP method to use for the request to referCompleteUrl. GET or POST. Default value is POST.
13+
tag: 'tag', # Optional [String]: A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or cleared. May be cleared by setting tag="" Max length 256 characters.
14+
}
15+
end
16+
17+
# Add SipUri to the nested verbs array
18+
# @param sip_uri [SipUri] or [Array<SipUri>] Verb or verbs to add to the array.
19+
def add_sip_uri(sip_uri)
20+
@nested_verbs.push(*sip_uri)
21+
end
22+
end
23+
end
24+
end
25+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Unit tests for Bandwidth::Bxml::Refer
2+
describe 'Bandwidth::Bxml::Refer' do
3+
let(:initial_attributes) {
4+
{
5+
refer_complete_url: 'https://example.com/handleRefer',
6+
refer_complete_method: 'POST',
7+
tag: 'initial_tag'
8+
}
9+
}
10+
11+
let(:new_attributes) {
12+
{
13+
refer_complete_url: 'https://new.com/handleRefer',
14+
refer_complete_method: 'GET',
15+
tag: 'new_tag'
16+
}
17+
}
18+
19+
let(:sip_uri) { Bandwidth::Bxml::SipUri.new('sip:alice@atlanta.example.com') }
20+
21+
let(:instance) { Bandwidth::Bxml::Refer.new([], initial_attributes) }
22+
let(:instance_nested) { Bandwidth::Bxml::Refer.new(sip_uri, initial_attributes) }
23+
24+
describe 'test an instance of Refer' do
25+
it 'validates instance of Refer' do
26+
expect(instance).to be_instance_of(Bandwidth::Bxml::Refer)
27+
expect(instance).to be_a(Bandwidth::Bxml::Verb)
28+
end
29+
30+
it 'tests the to_bxml method of the Refer instance' do
31+
expected = "\n<Refer referCompleteUrl=\"https://example.com/handleRefer\" referCompleteMethod=\"POST\" tag=\"initial_tag\"/>\n"
32+
expect(instance.to_bxml).to eq(expected)
33+
end
34+
35+
it 'tests the set_attributes method of the Refer instance' do
36+
instance.set_attributes(new_attributes)
37+
expected = "\n<Refer referCompleteUrl=\"https://new.com/handleRefer\" referCompleteMethod=\"GET\" tag=\"new_tag\"/>\n"
38+
expect(instance.to_bxml).to eq(expected)
39+
end
40+
end
41+
42+
describe 'test an instance of Refer with nested SipUri' do
43+
it 'validates instance of Refer' do
44+
expect(instance_nested).to be_instance_of(Bandwidth::Bxml::Refer)
45+
expect(instance_nested).to be_a(Bandwidth::Bxml::Verb)
46+
end
47+
48+
it 'tests the to_bxml method of the nested Refer instance' do
49+
expected = "\n<Refer referCompleteUrl=\"https://example.com/handleRefer\" referCompleteMethod=\"POST\" tag=\"initial_tag\">\n <SipUri>sip:alice@atlanta.example.com</SipUri>\n</Refer>\n"
50+
expect(instance_nested.to_bxml).to eq(expected)
51+
end
52+
53+
it 'tests the add_sip_uri method of the nested Refer instance' do
54+
sip_uri_2 = Bandwidth::Bxml::SipUri.new('sip:bob@biloxi.example.com')
55+
instance_nested.add_sip_uri(sip_uri_2)
56+
expected = "\n<Refer referCompleteUrl=\"https://example.com/handleRefer\" referCompleteMethod=\"POST\" tag=\"initial_tag\">\n <SipUri>sip:alice@atlanta.example.com</SipUri>\n <SipUri>sip:bob@biloxi.example.com</SipUri>\n</Refer>\n"
57+
expect(instance_nested.to_bxml).to eq(expected)
58+
end
59+
end
60+
end
61+

0 commit comments

Comments
 (0)