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: 2 additions & 0 deletions lib/bandwidth-sdk/models/bxml/verbs/transfer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def initialize(transfer_to = [], attributes = {})
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.
diversion_treatment: 'diversionTreatment', # Optional [String]: Can be any of the following: - none: No diversion headers are sent on the outbound leg of the transferred call. - propagate: Copy the Diversion header from the inbound leg to the outbound leg. Ignored if there is no Diversion header present on the inbound leg. - stack: After propagating any Diversion header from the inbound leg to the outbound leg, stack on top another Diversion header based on the Request-URI of the inbound call. If diversionTreatment is not specified, no diversion header will be included for the transfer even if one came with the inbound call. Defaults to None.
diversion_reason: 'diversionReason', # Optional [String]: Can be any of the following values: unknown, user-busy, no-answer, unavailable, unconditional, time-of-day, do-not-disturb, deflection, follow-me, out-of-service, away. This parameter is considered only when diversionTreatment is set to stack. Defaults to None.
attestation_level: 'attestationLevel', # Optional [String]: The STIR/SHAKEN attestation level to sign the transferred call with. Can be A, B, or C. Only applies to accounts using the Hosted Signing Service. Cannot be combined with identity. Defaults to None.
identity: 'identity', # Optional [String]: A SIP Identity header value (PASSporT) signed by you, sent unmodified on the transferred call. Max length 2000 characters. Cannot be combined with attestationLevel. Defaults to None.
}
end

Expand Down
18 changes: 11 additions & 7 deletions spec/unit/models/bxml/verbs/transfer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
fallback_password: 'initial_fallback_password',
tag: 'initial_tag',
diversion_treatment: 'propagate',
diversion_reason: 'user-busy'
diversion_reason: 'user-busy',
attestation_level: 'A',
identity: 'initial_identity'
}
}

Expand All @@ -36,7 +38,9 @@
fallback_password: 'new_fallback_password',
tag: 'new_tag',
diversion_treatment: 'stack',
diversion_reason: 'no-answer'
diversion_reason: 'no-answer',
attestation_level: 'B',
identity: 'new_identity'
}
}

Expand All @@ -53,13 +57,13 @@
end

it 'tests the to_bxml method of the Transfer instance' do
expected = "\n<Transfer transferCallerId=\"+19195551234\" privacy=\"true\" 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"
expected = "\n<Transfer transferCallerId=\"+19195551234\" privacy=\"true\" 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\" attestationLevel=\"A\" identity=\"initial_identity\"/>\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\" privacy=\"false\" 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"
expected = "\n<Transfer transferCallerId=\"+19195554321\" privacy=\"false\" 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\" attestationLevel=\"B\" identity=\"new_identity\"/>\n"
expect(instance.to_bxml).to eq(expected)
end
end
Expand All @@ -71,16 +75,16 @@
end

it 'tests the to_bxml method of the nested Transfer instance' do
expected = "\n<Transfer transferCallerId=\"+19195551234\" privacy=\"true\" 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"
expected = "\n<Transfer transferCallerId=\"+19195551234\" privacy=\"true\" 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\" attestationLevel=\"A\" identity=\"initial_identity\">\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\" privacy=\"true\" 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:1-999-123-4567@voip-provider.example.net</SipUri>\n</Transfer>\n"
expected_single = "\n<Transfer transferCallerId=\"+19195551234\" privacy=\"true\" 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\" attestationLevel=\"A\" identity=\"initial_identity\">\n <PhoneNumber>+19195551234</PhoneNumber>\n <SipUri>sip:1-999-123-4567@voip-provider.example.net</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\" privacy=\"true\" 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:1-999-123-4567@voip-provider.example.net</SipUri>\n <SipUri>sip:1-999-123-4567@voip-provider.example.net</SipUri>\n <PhoneNumber>+19195551234</PhoneNumber>\n</Transfer>\n"
expected_multiple = "\n<Transfer transferCallerId=\"+19195551234\" privacy=\"true\" 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\" attestationLevel=\"A\" identity=\"initial_identity\">\n <PhoneNumber>+19195551234</PhoneNumber>\n <SipUri>sip:1-999-123-4567@voip-provider.example.net</SipUri>\n <SipUri>sip:1-999-123-4567@voip-provider.example.net</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