Skip to content

Commit

Permalink
SWI-4587 add transferCallerDisplayName to Transfer Verb (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoegel authored Feb 16, 2024
1 parent 2bab25b commit a333baa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/bandwidth-sdk/models/bxml/verbs/transfer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ def initialize(transfer_to = [], attributes = {})

@attribute_map = {
transfer_caller_id: 'transferCallerId', # Optional [String]: The caller ID to use when the call is transferred, if different. Must be in E.164 format (e.g. +15555555555) or be one of the following strings Restricted, Anonymous, Private, or Unavailable. Leave as default to pass along the number of the remote party. Defaults to None.
call_timeout: 'callTimeout', # Optional [Number]:The timeout (in seconds) for the callee to answer the call after it starts ringing. If the call does not start ringing within 30s, the call will be cancelled regardless of this value. Range: decimal values between 1 - 300. Default value is 30 seconds. Defaults to None.
transfer_caller_display_name: 'transferCallerDisplayName', # Optional [String]: The caller display name to use when the call is transferred. May not exceed 256 characters nor contain control characters such as new lines. Defaults to None.
call_timeout: 'callTimeout', # Optional [Number]: The timeout (in seconds) for the callee to answer the call after it starts ringing. If the call does not start ringing within 30s, the call will be cancelled regardless of this value. Range: decimal values between 1 - 300. Default value is 30 seconds. Defaults to None.
transfer_complete_url: 'transferCompleteUrl', # Optional [String]: URL to send the Transfer Complete event to and request new BXML. Optional but recommended. See below for further details. May be a relative URL. Defaults to None.
transfer_complete_method: 'transferCompleteMethod', # Optional [String]: The HTTP method to use for the request to transferCompleteUrl. GET or POST. Default value is POST. Defaults to None.
transfer_complete_fallback_url: 'transferCompleteFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the Transfer Complete callback delivery in case transferCompleteUrl fails to respond. Defaults to None.
Expand Down
12 changes: 7 additions & 5 deletions spec/models/bxml/verbs/transfer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
let(:initial_attributes) {
{
transfer_caller_id: '+19195551234',
transfer_caller_display_name: 'initial_caller',
call_timeout: 5,
transfer_complete_url: 'https://initial.com',
transfer_complete_method: 'POST',
Expand All @@ -21,6 +22,7 @@
let(:new_attributes) {
{
transfer_caller_id: '+19195554321',
transfer_caller_display_name: 'new_caller',
call_timeout: 10,
transfer_complete_url: 'https://new.com',
transfer_complete_method: 'POST',
Expand Down Expand Up @@ -49,13 +51,13 @@
end

it 'tests the to_bxml method of the Transfer instance' do
expected = "\n<Transfer transferCallerId=\"+19195551234\" callTimeout=\"5\" transferCompleteUrl=\"https://initial.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://initial.com\" transferCompleteFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" diversionTreatment=\"propagate\" diversionReason=\"user-busy\"/>\n"
expected = "\n<Transfer transferCallerId=\"+19195551234\" transferCallerDisplayName=\"initial_caller\" callTimeout=\"5\" transferCompleteUrl=\"https://initial.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://initial.com\" transferCompleteFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" diversionTreatment=\"propagate\" diversionReason=\"user-busy\"/>\n"
expect(instance.to_bxml).to eq(expected)
end

it 'tests the set_attributes method of the Transfer instance' do
instance.set_attributes(new_attributes)
expected = "\n<Transfer transferCallerId=\"+19195554321\" callTimeout=\"10\" transferCompleteUrl=\"https://new.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://new.com\" transferCompleteFallbackMethod=\"POST\" username=\"new_username\" password=\"new_password\" fallbackUsername=\"new_fallback_username\" fallbackPassword=\"new_fallback_password\" tag=\"new_tag\" diversionTreatment=\"stack\" diversionReason=\"no-answer\"/>\n"
expected = "\n<Transfer transferCallerId=\"+19195554321\" transferCallerDisplayName=\"new_caller\" callTimeout=\"10\" transferCompleteUrl=\"https://new.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://new.com\" transferCompleteFallbackMethod=\"POST\" username=\"new_username\" password=\"new_password\" fallbackUsername=\"new_fallback_username\" fallbackPassword=\"new_fallback_password\" tag=\"new_tag\" diversionTreatment=\"stack\" diversionReason=\"no-answer\"/>\n"
expect(instance.to_bxml).to eq(expected)
end
end
Expand All @@ -67,16 +69,16 @@
end

it 'tests the to_bxml method of the nested Transfer instance' do
expected = "\n<Transfer transferCallerId=\"+19195551234\" callTimeout=\"5\" transferCompleteUrl=\"https://initial.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://initial.com\" transferCompleteFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" diversionTreatment=\"propagate\" diversionReason=\"user-busy\">\n <PhoneNumber>+19195551234</PhoneNumber>\n</Transfer>\n"
expected = "\n<Transfer transferCallerId=\"+19195551234\" transferCallerDisplayName=\"initial_caller\" callTimeout=\"5\" transferCompleteUrl=\"https://initial.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://initial.com\" transferCompleteFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" diversionTreatment=\"propagate\" diversionReason=\"user-busy\">\n <PhoneNumber>+19195551234</PhoneNumber>\n</Transfer>\n"
expect(instance_nested.to_bxml).to eq(expected)
end

it 'tests the add_verb method of the nested Transfer instance' do
expected_single = "\n<Transfer transferCallerId=\"+19195551234\" callTimeout=\"5\" transferCompleteUrl=\"https://initial.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://initial.com\" transferCompleteFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" diversionTreatment=\"propagate\" diversionReason=\"user-busy\">\n <PhoneNumber>+19195551234</PhoneNumber>\n <SipUri>sip:[email protected]</SipUri>\n</Transfer>\n"
expected_single = "\n<Transfer transferCallerId=\"+19195551234\" transferCallerDisplayName=\"initial_caller\" callTimeout=\"5\" transferCompleteUrl=\"https://initial.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://initial.com\" transferCompleteFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" diversionTreatment=\"propagate\" diversionReason=\"user-busy\">\n <PhoneNumber>+19195551234</PhoneNumber>\n <SipUri>sip:[email protected]</SipUri>\n</Transfer>\n"
instance_nested.add_transfer_recipients(sip_uri)
expect(instance_nested.to_bxml).to eq(expected_single)

expected_multiple = "\n<Transfer transferCallerId=\"+19195551234\" callTimeout=\"5\" transferCompleteUrl=\"https://initial.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://initial.com\" transferCompleteFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" diversionTreatment=\"propagate\" diversionReason=\"user-busy\">\n <PhoneNumber>+19195551234</PhoneNumber>\n <SipUri>sip:[email protected]</SipUri>\n <SipUri>sip:[email protected]</SipUri>\n <PhoneNumber>+19195551234</PhoneNumber>\n</Transfer>\n"
expected_multiple = "\n<Transfer transferCallerId=\"+19195551234\" transferCallerDisplayName=\"initial_caller\" callTimeout=\"5\" transferCompleteUrl=\"https://initial.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://initial.com\" transferCompleteFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" diversionTreatment=\"propagate\" diversionReason=\"user-busy\">\n <PhoneNumber>+19195551234</PhoneNumber>\n <SipUri>sip:[email protected]</SipUri>\n <SipUri>sip:[email protected]</SipUri>\n <PhoneNumber>+19195551234</PhoneNumber>\n</Transfer>\n"
instance_nested.add_transfer_recipients([sip_uri, phone_number])
expect(instance_nested.to_bxml).to eq(expected_multiple)
end
Expand Down

0 comments on commit a333baa

Please sign in to comment.