Skip to content
Open
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
2 changes: 1 addition & 1 deletion .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -432,4 +432,4 @@ lib/bandwidth-sdk/models/webhook_subscription_error.rb
lib/bandwidth-sdk/models/webhook_subscription_request_schema.rb
lib/bandwidth-sdk/models/webhook_subscription_type_enum.rb
lib/bandwidth-sdk/models/webhook_subscriptions_list_body.rb
lib/bandwidth-sdk/version.rb
lib/bandwidth-sdk/version.rb
1 change: 1 addition & 0 deletions lib/bandwidth-sdk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
require 'bandwidth-sdk/models/bxml/verbs/play_audio'
require 'bandwidth-sdk/models/bxml/verbs/record'
require 'bandwidth-sdk/models/bxml/verbs/redirect'
require 'bandwidth-sdk/models/bxml/verbs/refer'
require 'bandwidth-sdk/models/bxml/verbs/resume_recording'
require 'bandwidth-sdk/models/bxml/verbs/ring'
require 'bandwidth-sdk/models/bxml/verbs/send_dtmf'
Expand Down
17 changes: 17 additions & 0 deletions lib/bandwidth-sdk/models/bxml/verbs/refer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module Bandwidth
module Bxml
class Refer < Bandwidth::Bxml::NestableVerb
# Initializer
# @param sip_uri [SipUri] The SIP URI to REFER the call to. Uses the same SipUri verb shared with Transfer.
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
def initialize(sip_uri, attributes = {})
super('Refer', nil, [sip_uri], attributes)
@attribute_map = {
refer_complete_url: 'referCompleteUrl',
refer_complete_method: 'referCompleteMethod',
tag: 'tag'
}
end
end
end
end
4 changes: 3 additions & 1 deletion lib/bandwidth-sdk/models/bxml/verbs/sip_uri.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module Bandwidth
module Bxml
class SipUri < Bandwidth::Bxml::Verb
# Shared nested verb used by both Transfer and Refer to specify a SIP URI destination.
#
# Initializer
# @param uri [String] A SIP URI to transfer the call to (e.g. sip:user@server.com)
# @param uri [String] A SIP URI to transfer or refer the call to (e.g. sip:user@server.com)
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
def initialize(uri, attributes = {})
super('SipUri', uri, attributes)
Expand Down
49 changes: 49 additions & 0 deletions spec/unit/models/bxml/verbs/refer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Unit tests for Bandwidth::Bxml::Refer
describe 'Bandwidth::Bxml::Refer' do
let(:initial_attributes) {
{
refer_complete_url: 'https://initial.com',
refer_complete_method: 'POST',
tag: 'initial_tag'
}
}

let(:new_attributes) {
{
refer_complete_url: 'https://new.com',
refer_complete_method: 'GET',
tag: 'new_tag'
}
}

let(:sip_uri) { Bandwidth::Bxml::SipUri.new('sip:alice@atlanta.example.com') }

let(:instance) { Bandwidth::Bxml::Refer.new(sip_uri, initial_attributes) }

describe 'test an instance of Refer' do
it 'validates instance of Refer' do
expect(instance).to be_instance_of(Bandwidth::Bxml::Refer)
expect(instance).to be_a(Bandwidth::Bxml::Verb)
end

it 'tests the to_bxml method of the Refer instance' do
expected = "\n<Refer referCompleteUrl=\"https://initial.com\" referCompleteMethod=\"POST\" tag=\"initial_tag\">\n <SipUri>sip:alice@atlanta.example.com</SipUri>\n</Refer>\n"
expect(instance.to_bxml).to eq(expected)
end

it 'tests the set_attributes method of the Refer instance' do
instance.set_attributes(new_attributes)
expected = "\n<Refer referCompleteUrl=\"https://new.com\" referCompleteMethod=\"GET\" tag=\"new_tag\">\n <SipUri>sip:alice@atlanta.example.com</SipUri>\n</Refer>\n"
expect(instance.to_bxml).to eq(expected)
end
end

describe 'test an instance of Refer with a bare SipUri' do
let(:bare_instance) { Bandwidth::Bxml::Refer.new(sip_uri) }

it 'renders correctly with no additional attributes' do
expected = "\n<Refer>\n <SipUri>sip:alice@atlanta.example.com</SipUri>\n</Refer>\n"
expect(bare_instance.to_bxml).to eq(expected)
end
end
end