Skip to content

Commit 4cf4a79

Browse files
atelegustampercaseyckoegel
authored
VAPI-3162-REFER (#211)
* VAPI-3162-REFER * VAPI-3162-REFER * VAPI-3162-REFER * VAPI-3162-REFER * VAPI-3162-REFER * VAPI-3162-REFER * VAPI-3162-REFER * VAPI-3162-REFER * VAPI-3162-REFER * VAPI-3162-REFER * VAPI-3162-REFER * Remove ReferCompleteCallback model, keep only Bxml::Refer verb The referComplete callback model will land later via a separate api-specs-driven PR once VAPI-3440 merges. This also removes the top-level Bandwidth::Refer model (and its ReferCompleteMethodEnum/ ReferCallStatusEnum helpers), which duplicated Bxml::Refer at the openapi-generator layer and had no equivalent for any other BXML verb (e.g. Transfer has no top-level Bandwidth::Transfer model). Adds a spec for Bxml::Refer covering construction with a bare SipUri and correct BXML rendering. * Remove orphaned SipUri REST model and stale generator manifest entries Bandwidth::SipUri (JSON model layer) and its bandwidth.yml schema were left over from the deleted top-level Refer/ReferCompleteCallback models and had no remaining consumer. .openapi-generator/FILES still listed refer.rb, refer_call_status_enum.rb, refer_complete_callback.rb, refer_complete_method_enum.rb, and their specs after those files were already deleted. * Address review feedback: sip_uri defaults, set_sip_uri setter, annotations Default sip_uri to an empty array and drop the array-wrapping in super() (parent already casts), add YARD annotations for each attribute matching Transfer's style, add a set_sip_uri setter, and restructure the spec to use instance/instance_nested like Gather's spec. Also fixed a trailing newline drift in .openapi-generator/FILES. --------- Co-authored-by: stampercasey <cstamper@bandwidth.com> Co-authored-by: Cameron Koegel <53310569+ckoegel@users.noreply.github.com>
1 parent 78b0f76 commit 4cf4a79

4 files changed

Lines changed: 82 additions & 1 deletion

File tree

‎lib/bandwidth-sdk.rb‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@
238238
require 'bandwidth-sdk/models/bxml/verbs/play_audio'
239239
require 'bandwidth-sdk/models/bxml/verbs/record'
240240
require 'bandwidth-sdk/models/bxml/verbs/redirect'
241+
require 'bandwidth-sdk/models/bxml/verbs/refer'
241242
require 'bandwidth-sdk/models/bxml/verbs/resume_recording'
242243
require 'bandwidth-sdk/models/bxml/verbs/ring'
243244
require 'bandwidth-sdk/models/bxml/verbs/send_dtmf'
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module Bandwidth
2+
module Bxml
3+
class Refer < Bandwidth::Bxml::NestableVerb
4+
# Initializer
5+
# @param sip_uri [SipUri] The SIP URI to REFER the call to. Uses the same SipUri verb shared with Transfer. Defaults to an empty array.
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 for failure recovery. May be a relative URL. Defaults to None.
12+
refer_complete_method: 'referCompleteMethod', # Optional [String]: The HTTP method to use for the request to referCompleteUrl. GET or POST. Default value is POST. Defaults to None.
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. Defaults to None.
14+
}
15+
end
16+
17+
# Set the SIP URI destination for this Refer verb
18+
# @param sip_uri [SipUri] The SIP URI to refer the call to.
19+
def set_sip_uri(sip_uri)
20+
@nested_verbs = [sip_uri]
21+
end
22+
end
23+
end
24+
end

‎lib/bandwidth-sdk/models/bxml/verbs/sip_uri.rb‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
module Bandwidth
22
module Bxml
33
class SipUri < Bandwidth::Bxml::Verb
4+
# Shared nested verb used by both Transfer and Refer to specify a SIP URI destination.
5+
#
46
# Initializer
5-
# @param uri [String] A SIP URI to transfer the call to (e.g. sip:user@server.com)
7+
# @param uri [String] A SIP URI to transfer or refer the call to (e.g. sip:user@server.com)
68
# @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
79
def initialize(uri, attributes = {})
810
super('SipUri', uri, attributes)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Unit tests for Bandwidth::Bxml::Refer
2+
describe 'Bandwidth::Bxml::Refer' do
3+
let(:initial_attributes) {
4+
{
5+
refer_complete_url: 'https://initial.com',
6+
refer_complete_method: 'POST',
7+
tag: 'initial_tag'
8+
}
9+
}
10+
11+
let(:new_attributes) {
12+
{
13+
refer_complete_url: 'https://new.com',
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 set_attributes method of the Refer instance' do
31+
instance.set_attributes(new_attributes)
32+
expected = "\n<Refer referCompleteUrl=\"https://new.com\" referCompleteMethod=\"GET\" tag=\"new_tag\"/>\n"
33+
expect(instance.to_bxml).to eq(expected)
34+
end
35+
36+
it 'tests the set_sip_uri method of the Refer instance' do
37+
instance.set_sip_uri(sip_uri)
38+
expected = "\n<Refer referCompleteUrl=\"https://initial.com\" referCompleteMethod=\"POST\" tag=\"initial_tag\">\n <SipUri>sip:alice@atlanta.example.com</SipUri>\n</Refer>\n"
39+
expect(instance.to_bxml).to eq(expected)
40+
end
41+
end
42+
43+
describe 'test an instance of Refer with a nested SipUri' do
44+
it 'validates instance of Refer' do
45+
expect(instance_nested).to be_instance_of(Bandwidth::Bxml::Refer)
46+
expect(instance_nested).to be_a(Bandwidth::Bxml::Verb)
47+
end
48+
49+
it 'tests the to_bxml method of the nested Refer instance' do
50+
expected = "\n<Refer referCompleteUrl=\"https://initial.com\" referCompleteMethod=\"POST\" tag=\"initial_tag\">\n <SipUri>sip:alice@atlanta.example.com</SipUri>\n</Refer>\n"
51+
expect(instance_nested.to_bxml).to eq(expected)
52+
end
53+
end
54+
end

0 commit comments

Comments
 (0)