From 686478d48910d4858fbfd6d086c694e1700bbd0c Mon Sep 17 00:00:00 2001 From: nitinkumar Date: Thu, 28 May 2026 16:42:27 +0530 Subject: [PATCH 1/2] VAPI-3162 --- custom_templates/gem.mustache | 1 + lib/bandwidth-sdk/models/bxml/verbs/refer.rb | 25 ++++++++ spec/unit/models/bxml/verbs/refer_spec.rb | 61 ++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 lib/bandwidth-sdk/models/bxml/verbs/refer.rb create mode 100644 spec/unit/models/bxml/verbs/refer_spec.rb diff --git a/custom_templates/gem.mustache b/custom_templates/gem.mustache index cd6eeb59..f9c90d1c 100644 --- a/custom_templates/gem.mustache +++ b/custom_templates/gem.mustache @@ -53,6 +53,7 @@ require 'bandwidth-sdk/models/bxml/verbs/phone_number' 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' diff --git a/lib/bandwidth-sdk/models/bxml/verbs/refer.rb b/lib/bandwidth-sdk/models/bxml/verbs/refer.rb new file mode 100644 index 00000000..45974243 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/refer.rb @@ -0,0 +1,25 @@ +module Bandwidth + module Bxml + class Refer < Bandwidth::Bxml::NestableVerb + # Initializer + # @param sip_uri [SipUri] or [Array] XML element children. Defaults to an empty array. Valid nested verb is: SipUri. + # @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', # Optional [String]: URL to send the Refer Complete event to and request new BXML. May be a relative URL. + refer_complete_method: 'referCompleteMethod', # Optional [String]: The HTTP method to use for the request to referCompleteUrl. GET or POST. Default value is POST. + 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. + } + end + + # Add SipUri to the nested verbs array + # @param sip_uri [SipUri] or [Array] Verb or verbs to add to the array. + def add_sip_uri(sip_uri) + @nested_verbs.push(*sip_uri) + end + end + end +end + diff --git a/spec/unit/models/bxml/verbs/refer_spec.rb b/spec/unit/models/bxml/verbs/refer_spec.rb new file mode 100644 index 00000000..123c197c --- /dev/null +++ b/spec/unit/models/bxml/verbs/refer_spec.rb @@ -0,0 +1,61 @@ +# Unit tests for Bandwidth::Bxml::Refer +describe 'Bandwidth::Bxml::Refer' do + let(:initial_attributes) { + { + refer_complete_url: 'https://example.com/handleRefer', + refer_complete_method: 'POST', + tag: 'initial_tag' + } + } + + let(:new_attributes) { + { + refer_complete_url: 'https://new.com/handleRefer', + 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([], initial_attributes) } + let(:instance_nested) { 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\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\n" + expect(instance.to_bxml).to eq(expected) + end + end + + describe 'test an instance of Refer with nested SipUri' do + it 'validates instance of Refer' do + expect(instance_nested).to be_instance_of(Bandwidth::Bxml::Refer) + expect(instance_nested).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the nested Refer instance' do + expected = "\n\n sip:alice@atlanta.example.com\n\n" + expect(instance_nested.to_bxml).to eq(expected) + end + + it 'tests the add_sip_uri method of the nested Refer instance' do + sip_uri_2 = Bandwidth::Bxml::SipUri.new('sip:bob@biloxi.example.com') + instance_nested.add_sip_uri(sip_uri_2) + expected = "\n\n sip:alice@atlanta.example.com\n sip:bob@biloxi.example.com\n\n" + expect(instance_nested.to_bxml).to eq(expected) + end + end +end + From b2b55d1889a6715280cda2ab58ccb8434b7684b2 Mon Sep 17 00:00:00 2001 From: nitinkumar Date: Fri, 29 May 2026 17:55:07 +0530 Subject: [PATCH 2/2] VAPI-3162 build fix --- lib/bandwidth-sdk.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/bandwidth-sdk.rb b/lib/bandwidth-sdk.rb index a15c309c..293421af 100644 --- a/lib/bandwidth-sdk.rb +++ b/lib/bandwidth-sdk.rb @@ -235,6 +235,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'