bandwidth-sdk 2.1.1 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +85 -70
- data/lib/bandwidth.rb +31 -2
- data/lib/bandwidth/api_helper.rb +14 -9
- data/lib/bandwidth/client.rb +22 -2
- data/lib/bandwidth/configuration.rb +67 -12
- data/lib/bandwidth/http/api_response.rb +2 -0
- data/lib/bandwidth/http/auth/two_factor_auth_basic_auth.rb +22 -0
- data/lib/bandwidth/http/auth/web_rtc_basic_auth.rb +22 -0
- data/lib/bandwidth/http/faraday_client.rb +5 -2
- data/lib/bandwidth/messaging_lib/messaging.rb +5 -3
- data/lib/bandwidth/messaging_lib/messaging/client.rb +13 -2
- data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +191 -113
- data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/messaging_lib/messaging/exceptions/{generic_client_exception.rb → messaging_exception.rb} +2 -14
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +23 -13
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +125 -0
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +60 -0
- data/lib/bandwidth/messaging_lib/messaging/models/media.rb +4 -4
- data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +21 -8
- data/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +62 -0
- data/lib/bandwidth/messaging_lib/messaging/models/priority_enum.rb +19 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +22 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +51 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb +49 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/mfa_controller.rb +209 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/error_with_request_exception.rb +34 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/forbidden_request_exception.rb +29 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/unauthorized_request_exception.rb +29 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb +88 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_messaging_response.rb +35 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_code_response.rb +35 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb +75 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_voice_response.rb +35 -0
- data/lib/bandwidth/utilities/file_wrapper.rb +17 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/bridge.rb +28 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/conference.rb +32 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/gather.rb +13 -1
- data/lib/bandwidth/voice_lib/bxml/verbs/phone_number.rb +7 -1
- data/lib/bandwidth/voice_lib/bxml/verbs/record.rb +9 -1
- data/lib/bandwidth/voice_lib/bxml/verbs/redirect.rb +5 -1
- data/lib/bandwidth/voice_lib/bxml/verbs/ring.rb +15 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb +4 -1
- data/lib/bandwidth/voice_lib/bxml/verbs/sip_uri.rb +25 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/start_gather.rb +20 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/start_recording.rb +4 -1
- data/lib/bandwidth/voice_lib/bxml/verbs/stop_gather.rb +14 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/tag.rb +13 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/transfer.rb +14 -3
- data/lib/bandwidth/voice_lib/voice.rb +19 -4
- data/lib/bandwidth/voice_lib/voice/client.rb +13 -2
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +1219 -133
- data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/voice_lib/voice/exceptions/{error_response_exception.rb → api_error_response_exception.rb} +3 -3
- data/lib/bandwidth/voice_lib/voice/models/answer_fallback_method_enum.rb +17 -0
- data/lib/bandwidth/voice_lib/voice/models/api_call_response.rb +56 -2
- data/lib/bandwidth/voice_lib/voice/models/api_call_state_response.rb +164 -0
- data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +135 -12
- data/lib/bandwidth/voice_lib/voice/models/api_modify_call_request.rb +37 -1
- data/lib/bandwidth/voice_lib/voice/models/api_modify_conference_request.rb +107 -0
- data/lib/bandwidth/voice_lib/voice/models/api_transcribe_recording_request.rb +80 -0
- data/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb +35 -0
- data/lib/bandwidth/voice_lib/voice/models/conference_detail.rb +108 -0
- data/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb +35 -0
- data/lib/bandwidth/voice_lib/voice/models/conference_member_detail.rb +80 -0
- data/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata_response.rb +126 -0
- data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +47 -0
- data/lib/bandwidth/voice_lib/voice/models/modify_call_recording_state.rb +1 -1
- data/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +66 -28
- data/lib/bandwidth/voice_lib/voice/models/redirect_fallback_method_enum.rb +17 -0
- data/lib/bandwidth/voice_lib/voice/models/state1_enum.rb +4 -7
- data/lib/bandwidth/voice_lib/voice/models/state2_enum.rb +20 -0
- data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +7 -4
- data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +29 -0
- data/lib/bandwidth/voice_lib/voice/models/status3_enum.rb +32 -0
- data/lib/bandwidth/voice_lib/voice/models/status_enum.rb +17 -0
- data/lib/bandwidth/{messaging_lib/messaging/models/field_error.rb → voice_lib/voice/models/transcript.rb} +15 -15
- data/lib/bandwidth/voice_lib/voice/models/transcription.rb +62 -0
- data/lib/bandwidth/voice_lib/voice/models/transcription_response.rb +42 -0
- data/lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb +13 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc.rb +22 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +51 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +692 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +49 -0
- data/lib/bandwidth/{messaging_lib/messaging/exceptions/path_client_exception.rb → web_rtc_lib/web_rtc/exceptions/error_exception.rb} +4 -19
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +47 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/device_api_version_enum.rb +17 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +92 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +35 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/publish_permission_enum.rb +17 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +44 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +54 -0
- data/test/integration/test_integration.rb +570 -0
- metadata +132 -19
- data/lib/bandwidth/voice_lib/voice/models/api_get_account_recordings_metadata_request.rb +0 -65
- data/lib/bandwidth/voice_lib/voice/models/transcription_status_enum.rb +0 -20
- data/lib/bandwidth/voice_lib/voice/models/type_enum.rb +0 -32
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# bandwidth
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module Bandwidth
|
|
7
|
+
# BaseController.
|
|
8
|
+
class BaseController
|
|
9
|
+
attr_accessor :config, :http_call_back
|
|
10
|
+
|
|
11
|
+
def initialize(config, http_call_back: nil)
|
|
12
|
+
@config = config
|
|
13
|
+
@http_call_back = http_call_back
|
|
14
|
+
|
|
15
|
+
@global_headers = {
|
|
16
|
+
'user-agent' => 'ruby-sdk'
|
|
17
|
+
}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def validate_parameters(args)
|
|
21
|
+
args.each do |_name, value|
|
|
22
|
+
if value.nil?
|
|
23
|
+
raise ArgumentError, "Required parameter #{_name} cannot be nil."
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def execute_request(request, binary: false)
|
|
29
|
+
@http_call_back.on_before_request(request) if @http_call_back
|
|
30
|
+
|
|
31
|
+
APIHelper.clean_hash(request.headers)
|
|
32
|
+
request.headers.merge!(@global_headers)
|
|
33
|
+
|
|
34
|
+
response = if binary
|
|
35
|
+
config.http_client.execute_as_binary(request)
|
|
36
|
+
else
|
|
37
|
+
config.http_client.execute_as_string(request)
|
|
38
|
+
end
|
|
39
|
+
@http_call_back.on_after_response(response) if @http_call_back
|
|
40
|
+
|
|
41
|
+
response
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def validate_response(response)
|
|
45
|
+
raise APIException.new 'HTTP Response Not OK', response unless
|
|
46
|
+
response.status_code.between?(200, 208) # [200,208] = HTTP OK
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -4,28 +4,16 @@
|
|
|
4
4
|
# ( https://apimatic.io ).
|
|
5
5
|
|
|
6
6
|
module Bandwidth
|
|
7
|
-
#
|
|
8
|
-
class
|
|
9
|
-
# TODO: Write general description for this method
|
|
10
|
-
# @return [String]
|
|
11
|
-
attr_accessor :timestamp
|
|
12
|
-
|
|
7
|
+
# Error class.
|
|
8
|
+
class ErrorException < APIException
|
|
13
9
|
# TODO: Write general description for this method
|
|
14
10
|
# @return [Integer]
|
|
15
|
-
attr_accessor :
|
|
16
|
-
|
|
17
|
-
# TODO: Write general description for this method
|
|
18
|
-
# @return [String]
|
|
19
|
-
attr_accessor :error
|
|
11
|
+
attr_accessor :code
|
|
20
12
|
|
|
21
13
|
# TODO: Write general description for this method
|
|
22
14
|
# @return [String]
|
|
23
15
|
attr_accessor :message
|
|
24
16
|
|
|
25
|
-
# TODO: Write general description for this method
|
|
26
|
-
# @return [String]
|
|
27
|
-
attr_accessor :path
|
|
28
|
-
|
|
29
17
|
# The constructor.
|
|
30
18
|
# @param [String] The reason for raising an exception.
|
|
31
19
|
# @param [HttpResponse] The HttpReponse of the API call.
|
|
@@ -39,11 +27,8 @@ module Bandwidth
|
|
|
39
27
|
# @param [Hash] The deserialized response sent by the server in the
|
|
40
28
|
# response body.
|
|
41
29
|
def unbox(hash)
|
|
42
|
-
@
|
|
43
|
-
@status = hash['status']
|
|
44
|
-
@error = hash['error']
|
|
30
|
+
@code = hash['code']
|
|
45
31
|
@message = hash['message']
|
|
46
|
-
@path = hash['path']
|
|
47
32
|
end
|
|
48
33
|
end
|
|
49
34
|
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# bandwidth
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module Bandwidth
|
|
7
|
+
# AccountsParticipantsResponse Model.
|
|
8
|
+
class AccountsParticipantsResponse < BaseModel
|
|
9
|
+
# A participant object
|
|
10
|
+
# @return [Participant]
|
|
11
|
+
attr_accessor :participant
|
|
12
|
+
|
|
13
|
+
# Auth token for the returned participant
|
|
14
|
+
# This should be passed to the participant so that they can connect to the
|
|
15
|
+
# platform
|
|
16
|
+
# @return [String]
|
|
17
|
+
attr_accessor :token
|
|
18
|
+
|
|
19
|
+
# A mapping from model property names to API property names.
|
|
20
|
+
def self.names
|
|
21
|
+
@_hash = {} if @_hash.nil?
|
|
22
|
+
@_hash['participant'] = 'participant'
|
|
23
|
+
@_hash['token'] = 'token'
|
|
24
|
+
@_hash
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def initialize(participant = nil,
|
|
28
|
+
token = nil)
|
|
29
|
+
@participant = participant
|
|
30
|
+
@token = token
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Creates an instance of the object from a hash.
|
|
34
|
+
def self.from_hash(hash)
|
|
35
|
+
return nil unless hash
|
|
36
|
+
|
|
37
|
+
# Extract variables from the hash.
|
|
38
|
+
participant = Participant.from_hash(hash['participant']) if
|
|
39
|
+
hash['participant']
|
|
40
|
+
token = hash['token']
|
|
41
|
+
|
|
42
|
+
# Create object from extracted values.
|
|
43
|
+
AccountsParticipantsResponse.new(participant,
|
|
44
|
+
token)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# bandwidth
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module Bandwidth
|
|
7
|
+
# Optional field to define the device api version of this participant
|
|
8
|
+
class DeviceApiVersionEnum
|
|
9
|
+
DEVICE_API_VERSION_ENUM = [
|
|
10
|
+
# TODO: Write general description for V3
|
|
11
|
+
V3 = 'v3'.freeze,
|
|
12
|
+
|
|
13
|
+
# TODO: Write general description for V2
|
|
14
|
+
V2 = 'v2'.freeze
|
|
15
|
+
].freeze
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# bandwidth
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module Bandwidth
|
|
7
|
+
# A participant object
|
|
8
|
+
class Participant < BaseModel
|
|
9
|
+
# Unique id of the participant
|
|
10
|
+
# @return [String]
|
|
11
|
+
attr_accessor :id
|
|
12
|
+
|
|
13
|
+
# Full callback url to use for notifications about this participant
|
|
14
|
+
# @return [String]
|
|
15
|
+
attr_accessor :callback_url
|
|
16
|
+
|
|
17
|
+
# Defines if this participant can publish audio or video
|
|
18
|
+
# @return [List of PublishPermissionEnum]
|
|
19
|
+
attr_accessor :publish_permissions
|
|
20
|
+
|
|
21
|
+
# List of session ids this participant is associated with
|
|
22
|
+
# Capped to one
|
|
23
|
+
# @return [List of String]
|
|
24
|
+
attr_accessor :sessions
|
|
25
|
+
|
|
26
|
+
# List of session ids this participant is associated with
|
|
27
|
+
# Capped to one
|
|
28
|
+
# @return [Subscriptions]
|
|
29
|
+
attr_accessor :subscriptions
|
|
30
|
+
|
|
31
|
+
# User defined tag to associate with the participant
|
|
32
|
+
# @return [String]
|
|
33
|
+
attr_accessor :tag
|
|
34
|
+
|
|
35
|
+
# Optional field to define the device api version of this participant
|
|
36
|
+
# @return [DeviceApiVersionEnum]
|
|
37
|
+
attr_accessor :device_api_version
|
|
38
|
+
|
|
39
|
+
# A mapping from model property names to API property names.
|
|
40
|
+
def self.names
|
|
41
|
+
@_hash = {} if @_hash.nil?
|
|
42
|
+
@_hash['id'] = 'id'
|
|
43
|
+
@_hash['callback_url'] = 'callbackUrl'
|
|
44
|
+
@_hash['publish_permissions'] = 'publishPermissions'
|
|
45
|
+
@_hash['sessions'] = 'sessions'
|
|
46
|
+
@_hash['subscriptions'] = 'subscriptions'
|
|
47
|
+
@_hash['tag'] = 'tag'
|
|
48
|
+
@_hash['device_api_version'] = 'deviceApiVersion'
|
|
49
|
+
@_hash
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def initialize(id = nil,
|
|
53
|
+
callback_url = nil,
|
|
54
|
+
publish_permissions = nil,
|
|
55
|
+
sessions = nil,
|
|
56
|
+
subscriptions = nil,
|
|
57
|
+
tag = nil,
|
|
58
|
+
device_api_version = DeviceApiVersionEnum::V2)
|
|
59
|
+
@id = id
|
|
60
|
+
@callback_url = callback_url
|
|
61
|
+
@publish_permissions = publish_permissions
|
|
62
|
+
@sessions = sessions
|
|
63
|
+
@subscriptions = subscriptions
|
|
64
|
+
@tag = tag
|
|
65
|
+
@device_api_version = device_api_version
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Creates an instance of the object from a hash.
|
|
69
|
+
def self.from_hash(hash)
|
|
70
|
+
return nil unless hash
|
|
71
|
+
|
|
72
|
+
# Extract variables from the hash.
|
|
73
|
+
id = hash['id']
|
|
74
|
+
callback_url = hash['callbackUrl']
|
|
75
|
+
publish_permissions = hash['publishPermissions']
|
|
76
|
+
sessions = hash['sessions']
|
|
77
|
+
subscriptions = Subscriptions.from_hash(hash['subscriptions']) if
|
|
78
|
+
hash['subscriptions']
|
|
79
|
+
tag = hash['tag']
|
|
80
|
+
device_api_version = hash['deviceApiVersion'] ||= DeviceApiVersionEnum::V2
|
|
81
|
+
|
|
82
|
+
# Create object from extracted values.
|
|
83
|
+
Participant.new(id,
|
|
84
|
+
callback_url,
|
|
85
|
+
publish_permissions,
|
|
86
|
+
sessions,
|
|
87
|
+
subscriptions,
|
|
88
|
+
tag,
|
|
89
|
+
device_api_version)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# bandwidth
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module Bandwidth
|
|
7
|
+
# ParticipantSubscription Model.
|
|
8
|
+
class ParticipantSubscription < BaseModel
|
|
9
|
+
# Participant the subscriber should be subscribed to
|
|
10
|
+
# @return [String]
|
|
11
|
+
attr_accessor :participant_id
|
|
12
|
+
|
|
13
|
+
# A mapping from model property names to API property names.
|
|
14
|
+
def self.names
|
|
15
|
+
@_hash = {} if @_hash.nil?
|
|
16
|
+
@_hash['participant_id'] = 'participantId'
|
|
17
|
+
@_hash
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def initialize(participant_id = nil)
|
|
21
|
+
@participant_id = participant_id
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Creates an instance of the object from a hash.
|
|
25
|
+
def self.from_hash(hash)
|
|
26
|
+
return nil unless hash
|
|
27
|
+
|
|
28
|
+
# Extract variables from the hash.
|
|
29
|
+
participant_id = hash['participantId']
|
|
30
|
+
|
|
31
|
+
# Create object from extracted values.
|
|
32
|
+
ParticipantSubscription.new(participant_id)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# bandwidth
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module Bandwidth
|
|
7
|
+
# PublishPermission.
|
|
8
|
+
class PublishPermissionEnum
|
|
9
|
+
PUBLISH_PERMISSION_ENUM = [
|
|
10
|
+
# TODO: Write general description for AUDIO
|
|
11
|
+
AUDIO = 'AUDIO'.freeze,
|
|
12
|
+
|
|
13
|
+
# TODO: Write general description for VIDEO
|
|
14
|
+
VIDEO = 'VIDEO'.freeze
|
|
15
|
+
].freeze
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# bandwidth
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module Bandwidth
|
|
7
|
+
# A session object
|
|
8
|
+
class Session < BaseModel
|
|
9
|
+
# Unique id of the session
|
|
10
|
+
# @return [String]
|
|
11
|
+
attr_accessor :id
|
|
12
|
+
|
|
13
|
+
# User defined tag to associate with the session
|
|
14
|
+
# @return [String]
|
|
15
|
+
attr_accessor :tag
|
|
16
|
+
|
|
17
|
+
# A mapping from model property names to API property names.
|
|
18
|
+
def self.names
|
|
19
|
+
@_hash = {} if @_hash.nil?
|
|
20
|
+
@_hash['id'] = 'id'
|
|
21
|
+
@_hash['tag'] = 'tag'
|
|
22
|
+
@_hash
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def initialize(id = nil,
|
|
26
|
+
tag = nil)
|
|
27
|
+
@id = id
|
|
28
|
+
@tag = tag
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Creates an instance of the object from a hash.
|
|
32
|
+
def self.from_hash(hash)
|
|
33
|
+
return nil unless hash
|
|
34
|
+
|
|
35
|
+
# Extract variables from the hash.
|
|
36
|
+
id = hash['id']
|
|
37
|
+
tag = hash['tag']
|
|
38
|
+
|
|
39
|
+
# Create object from extracted values.
|
|
40
|
+
Session.new(id,
|
|
41
|
+
tag)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# bandwidth
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module Bandwidth
|
|
7
|
+
# Subscriptions Model.
|
|
8
|
+
class Subscriptions < BaseModel
|
|
9
|
+
# Session the subscriptions are associated with
|
|
10
|
+
# If this is the only field, the subscriber will be subscribed to all
|
|
11
|
+
# participants in the session (including any participants that are later
|
|
12
|
+
# added to the session)
|
|
13
|
+
# @return [String]
|
|
14
|
+
attr_accessor :session_id
|
|
15
|
+
|
|
16
|
+
# Subset of participants to subscribe to in the session. Optional.
|
|
17
|
+
# @return [List of ParticipantSubscription]
|
|
18
|
+
attr_accessor :participants
|
|
19
|
+
|
|
20
|
+
# A mapping from model property names to API property names.
|
|
21
|
+
def self.names
|
|
22
|
+
@_hash = {} if @_hash.nil?
|
|
23
|
+
@_hash['session_id'] = 'sessionId'
|
|
24
|
+
@_hash['participants'] = 'participants'
|
|
25
|
+
@_hash
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def initialize(session_id = nil,
|
|
29
|
+
participants = nil)
|
|
30
|
+
@session_id = session_id
|
|
31
|
+
@participants = participants
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Creates an instance of the object from a hash.
|
|
35
|
+
def self.from_hash(hash)
|
|
36
|
+
return nil unless hash
|
|
37
|
+
|
|
38
|
+
# Extract variables from the hash.
|
|
39
|
+
session_id = hash['sessionId']
|
|
40
|
+
# Parameter is an array, so we need to iterate through it
|
|
41
|
+
participants = nil
|
|
42
|
+
unless hash['participants'].nil?
|
|
43
|
+
participants = []
|
|
44
|
+
hash['participants'].each do |structure|
|
|
45
|
+
participants << (ParticipantSubscription.from_hash(structure) if structure)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Create object from extracted values.
|
|
50
|
+
Subscriptions.new(session_id,
|
|
51
|
+
participants)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
# test_integration.rb
|
|
2
|
+
#
|
|
3
|
+
# A simple integration test against Bandwidth's APIs
|
|
4
|
+
|
|
5
|
+
require 'test/unit'
|
|
6
|
+
require_relative '../../lib/bandwidth.rb'
|
|
7
|
+
|
|
8
|
+
include Bandwidth
|
|
9
|
+
include Bandwidth::Voice
|
|
10
|
+
include Bandwidth::Messaging
|
|
11
|
+
include Bandwidth::TwoFactorAuth
|
|
12
|
+
|
|
13
|
+
begin
|
|
14
|
+
USERNAME = ENV.fetch("USERNAME")
|
|
15
|
+
PASSWORD = ENV.fetch("PASSWORD")
|
|
16
|
+
ACCOUNT_ID = ENV.fetch("ACCOUNT_ID")
|
|
17
|
+
VOICE_APPLICATION_ID = ENV.fetch("VOICE_APPLICATION_ID")
|
|
18
|
+
MESSAGING_APPLICATION_ID = ENV.fetch("MESSAGING_APPLICATION_ID")
|
|
19
|
+
CALLBACK_URL = ENV.fetch("CALLBACK_URL")
|
|
20
|
+
PHONE_NUMBER_OUTBOUND = ENV.fetch("PHONE_NUMBER_OUTBOUND")
|
|
21
|
+
PHONE_NUMBER_INBOUND = ENV.fetch("PHONE_NUMBER_INBOUND")
|
|
22
|
+
MFA_MESSAGING_APPLICATION_ID = ENV.fetch("MFA_MESSAGING_APPLICATION_ID")
|
|
23
|
+
MFA_VOICE_APPLICATION_ID = ENV.fetch("MFA_VOICE_APPLICATION_ID")
|
|
24
|
+
PHONE_NUMBER_MFA = ENV.fetch("PHONE_NUMBER_MFA")
|
|
25
|
+
rescue
|
|
26
|
+
puts "Environmental variables not found"
|
|
27
|
+
exit(-1)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class IntegrationTest < Test::Unit::TestCase
|
|
31
|
+
def setup
|
|
32
|
+
@bandwidth_client = Bandwidth::Client.new(
|
|
33
|
+
voice_basic_auth_user_name: USERNAME,
|
|
34
|
+
voice_basic_auth_password: PASSWORD,
|
|
35
|
+
messaging_basic_auth_user_name: USERNAME,
|
|
36
|
+
messaging_basic_auth_password: PASSWORD,
|
|
37
|
+
two_factor_auth_basic_auth_user_name: USERNAME,
|
|
38
|
+
two_factor_auth_basic_auth_password: PASSWORD
|
|
39
|
+
)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_create_message
|
|
43
|
+
body = MessageRequest.new
|
|
44
|
+
body.application_id = MESSAGING_APPLICATION_ID
|
|
45
|
+
body.to = [PHONE_NUMBER_INBOUND]
|
|
46
|
+
body.from = PHONE_NUMBER_OUTBOUND
|
|
47
|
+
body.text = "Ruby Integration"
|
|
48
|
+
response = @bandwidth_client.messaging_client.client.create_message(ACCOUNT_ID, body)
|
|
49
|
+
assert(response.data.id.length > 0, "id value not set") #validate that _some_ id was returned
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def test_create_message_invalid_phone_number
|
|
53
|
+
body = MessageRequest.new
|
|
54
|
+
body.application_id = MESSAGING_APPLICATION_ID
|
|
55
|
+
body.to = ["+1invalid"]
|
|
56
|
+
body.from = PHONE_NUMBER_OUTBOUND
|
|
57
|
+
body.text = "Ruby Integration"
|
|
58
|
+
begin
|
|
59
|
+
@bandwidth_client.messaging_client.client.create_message(ACCOUNT_ID, :body => body)
|
|
60
|
+
#workaround to make sure that if the above error is not raised, the build will fail
|
|
61
|
+
assert(false, "Expected exception not raised")
|
|
62
|
+
rescue MessagingException => e
|
|
63
|
+
assert(e.description.length > 0, "description value not set")
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def test_upload_download_media
|
|
68
|
+
#define constants for upload media and download media
|
|
69
|
+
media_file_name = 'ruby_integration' #future update to add special symbols
|
|
70
|
+
media_file = '12345' #todo: check a binary string
|
|
71
|
+
|
|
72
|
+
#media upload
|
|
73
|
+
@bandwidth_client.messaging_client.client.upload_media(ACCOUNT_ID, media_file_name, media_file.length.to_s, media_file, :content_type => "application/octet-stream", :cache_control => "no-cache")
|
|
74
|
+
|
|
75
|
+
#media download
|
|
76
|
+
downloaded_media_file = @bandwidth_client.messaging_client.client.get_media(ACCOUNT_ID, media_file_name).data
|
|
77
|
+
|
|
78
|
+
assert_equal(downloaded_media_file, media_file, "Downloaded media file not equal to upload")
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def test_create_call_and_get_call_state
|
|
82
|
+
body = ApiCreateCallRequest.new
|
|
83
|
+
body.from = PHONE_NUMBER_OUTBOUND
|
|
84
|
+
body.to = PHONE_NUMBER_INBOUND
|
|
85
|
+
body.application_id = VOICE_APPLICATION_ID
|
|
86
|
+
body.answer_url = CALLBACK_URL
|
|
87
|
+
response = @bandwidth_client.voice_client.client.create_call(ACCOUNT_ID, :body => body)
|
|
88
|
+
assert(response.data.call_id.length > 0, "call_id value not set")
|
|
89
|
+
|
|
90
|
+
#Get phone call information
|
|
91
|
+
response = @bandwidth_client.voice_client.client.get_call_state(ACCOUNT_ID, response.data.call_id)
|
|
92
|
+
assert(response.data.state.length > 0, "state value not set")
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_create_call_invalid_phone_number
|
|
96
|
+
body = ApiCreateCallRequest.new
|
|
97
|
+
body.from = PHONE_NUMBER_OUTBOUND
|
|
98
|
+
body.to = "+1invalid"
|
|
99
|
+
body.application_id = VOICE_APPLICATION_ID
|
|
100
|
+
body.answer_url = CALLBACK_URL
|
|
101
|
+
|
|
102
|
+
begin
|
|
103
|
+
@bandwidth_client.voice_client.client.create_call(ACCOUNT_ID, :body => body)
|
|
104
|
+
#workaround to make sure that if the above error is not raised, the build will fail
|
|
105
|
+
assert(false, "Expected exception not raised")
|
|
106
|
+
rescue ApiErrorResponseException => e
|
|
107
|
+
assert(e.description.length > 0, "description value not set")
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def test_forward
|
|
112
|
+
forward = Bandwidth::Voice::Forward.new({
|
|
113
|
+
:to => "+15554443333",
|
|
114
|
+
:from => "+13334445555",
|
|
115
|
+
:call_timeout => 25,
|
|
116
|
+
:diversion_treatment => "none",
|
|
117
|
+
:diversion_reason => "away"
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
response = Bandwidth::Voice::Response.new()
|
|
121
|
+
response.push(forward)
|
|
122
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Forward to="+15554443333" from="+13334445555" callTimeout="25" diversionTreatment="none" diversionReason="away"/></Response>'
|
|
123
|
+
actual = response.to_bxml()
|
|
124
|
+
assert_equal(expected, actual)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def test_gather
|
|
128
|
+
gather = Bandwidth::Voice::Gather.new({
|
|
129
|
+
:gather_url => "https://test.com",
|
|
130
|
+
:gather_method => "POST",
|
|
131
|
+
:username => "user",
|
|
132
|
+
:password => "pass",
|
|
133
|
+
:tag => "tag",
|
|
134
|
+
:terminating_digits => "#",
|
|
135
|
+
:max_digits => 3,
|
|
136
|
+
:inter_digit_timeout => 5,
|
|
137
|
+
:first_digit_timeout => "10",
|
|
138
|
+
:repeat_count => 1,
|
|
139
|
+
:gather_fallback_url => "https://test.com",
|
|
140
|
+
:gather_fallback_method => "GET",
|
|
141
|
+
:fallback_username => "fuser",
|
|
142
|
+
:fallback_password => "fpass"
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
response = Bandwidth::Voice::Response.new()
|
|
146
|
+
response.push(gather)
|
|
147
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Gather gatherUrl="https://test.com" gatherMethod="POST" terminatingDigits="#" tag="tag" maxDigits="3" interDigitTimeout="5" username="user" password="pass" firstDigitTimeout="10" repeatCount="1" gatherFallbackUrl="https://test.com" gatherFallbackMethod="GET" fallbackUsername="fuser" fallbackPassword="fpass"></Gather></Response>'
|
|
148
|
+
actual = response.to_bxml()
|
|
149
|
+
assert_equal(expected, actual)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def test_gather_nested_speak_sentence
|
|
153
|
+
speak_sentence = Bandwidth::Voice::SpeakSentence.new({
|
|
154
|
+
:sentence => "test"
|
|
155
|
+
})
|
|
156
|
+
gather = Bandwidth::Voice::Gather.new({
|
|
157
|
+
:speak_sentence => speak_sentence
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
response = Bandwidth::Voice::Response.new()
|
|
161
|
+
response.push(gather)
|
|
162
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Gather><SpeakSentence>test</SpeakSentence></Gather></Response>'
|
|
163
|
+
actual = response.to_bxml()
|
|
164
|
+
assert_equal(expected, actual)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def test_gather_nested_play_audio
|
|
168
|
+
play_audio = Bandwidth::Voice::PlayAudio.new({
|
|
169
|
+
:url => "https://test.com"
|
|
170
|
+
})
|
|
171
|
+
gather = Bandwidth::Voice::Gather.new({
|
|
172
|
+
:play_audio => play_audio
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
response = Bandwidth::Voice::Response.new()
|
|
176
|
+
response.push(gather)
|
|
177
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Gather><PlayAudio>https://test.com</PlayAudio></Gather></Response>'
|
|
178
|
+
actual = response.to_bxml()
|
|
179
|
+
assert_equal(expected, actual)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def test_gather_multiple_nested_verbs
|
|
183
|
+
play_audio = Bandwidth::Voice::PlayAudio.new({
|
|
184
|
+
:url => "https://test.com"
|
|
185
|
+
})
|
|
186
|
+
speak_sentence = Bandwidth::Voice::SpeakSentence.new({
|
|
187
|
+
:sentence => "test"
|
|
188
|
+
})
|
|
189
|
+
gather = Bandwidth::Voice::Gather.new({
|
|
190
|
+
:nested_verbs => [play_audio, speak_sentence]
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
response = Bandwidth::Voice::Response.new()
|
|
194
|
+
response.push(gather)
|
|
195
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Gather><PlayAudio>https://test.com</PlayAudio><SpeakSentence>test</SpeakSentence></Gather></Response>'
|
|
196
|
+
actual = response.to_bxml()
|
|
197
|
+
assert_equal(expected, actual)
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def test_hangup
|
|
201
|
+
hangup = Bandwidth::Voice::Hangup.new()
|
|
202
|
+
|
|
203
|
+
response = Bandwidth::Voice::Response.new()
|
|
204
|
+
response.push(hangup)
|
|
205
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Hangup/></Response>'
|
|
206
|
+
actual = response.to_bxml()
|
|
207
|
+
assert_equal(expected, actual)
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def test_pause
|
|
211
|
+
pause = Bandwidth::Voice::Pause.new({
|
|
212
|
+
:duration => 2
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
response = Bandwidth::Voice::Response.new()
|
|
216
|
+
response.push(pause)
|
|
217
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Pause duration="2"/></Response>'
|
|
218
|
+
actual = response.to_bxml()
|
|
219
|
+
assert_equal(expected, actual)
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
def test_pause_recording
|
|
223
|
+
pause_recording = Bandwidth::Voice::PauseRecording.new()
|
|
224
|
+
|
|
225
|
+
response = Bandwidth::Voice::Response.new()
|
|
226
|
+
response.push(pause_recording)
|
|
227
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><PauseRecording/></Response>'
|
|
228
|
+
actual = response.to_bxml()
|
|
229
|
+
assert_equal(expected, actual)
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
def test_play_audio
|
|
233
|
+
play_audio = Bandwidth::Voice::PlayAudio.new({
|
|
234
|
+
:url => "https://test.com",
|
|
235
|
+
:username => "user",
|
|
236
|
+
:password => "pass"
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
response = Bandwidth::Voice::Response.new()
|
|
240
|
+
response.push(play_audio)
|
|
241
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><PlayAudio username="user" password="pass">https://test.com</PlayAudio></Response>'
|
|
242
|
+
actual = response.to_bxml()
|
|
243
|
+
assert_equal(expected, actual)
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
def test_record
|
|
247
|
+
record = Bandwidth::Voice::Record.new({
|
|
248
|
+
:record_complete_url => "https://complete.com",
|
|
249
|
+
:record_complete_method => "POST",
|
|
250
|
+
:recording_available_url => "https://available.com",
|
|
251
|
+
:recording_available_method => "GET",
|
|
252
|
+
:transcribe => false,
|
|
253
|
+
:transcription_available_url => "https://transcribe.com",
|
|
254
|
+
:transcription_available_method => "POST",
|
|
255
|
+
:username => "user",
|
|
256
|
+
:password => "pass",
|
|
257
|
+
:tag => "tag",
|
|
258
|
+
:terminating_digits => "#",
|
|
259
|
+
:max_duration => 3,
|
|
260
|
+
:silence_timeout => 5,
|
|
261
|
+
:file_format => "wav",
|
|
262
|
+
:record_complete_fallback_url => "https://test.com",
|
|
263
|
+
:record_complete_fallback_method => "GET",
|
|
264
|
+
:fallback_username => "fuser",
|
|
265
|
+
:fallback_password => "fpass"
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
response = Bandwidth::Voice::Response.new()
|
|
269
|
+
response.push(record)
|
|
270
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Record tag="tag" username="user" password="pass" recordCompleteUrl="https://complete.com" recordCompleteMethod="POST" recordingAvailableUrl="https://available.com" recordingAvailableMethod="GET" terminatingDigits="#" maxDuration="3" fileFormat="wav" transcribe="false" transcriptionAvailableUrl="https://transcribe.com" transcriptionAvailableMethod="POST" silenceTimeout="5" recordCompleteFallbackUrl="https://test.com" recordCompleteFallbackMethod="GET" fallbackUsername="fuser" fallbackPassword="fpass"/></Response>'
|
|
271
|
+
actual = response.to_bxml()
|
|
272
|
+
assert_equal(expected, actual)
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
def test_redirect
|
|
276
|
+
redirect = Bandwidth::Voice::Redirect.new({
|
|
277
|
+
:redirect_url => "https://redirect.com",
|
|
278
|
+
:redirect_method => "GET",
|
|
279
|
+
:username => "user",
|
|
280
|
+
:password => "pass",
|
|
281
|
+
:tag => "tag",
|
|
282
|
+
:redirect_fallback_url => "https://test.com",
|
|
283
|
+
:redirect_fallback_method => "GET",
|
|
284
|
+
:fallback_username => "fuser",
|
|
285
|
+
:fallback_password => "fpass"
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
response = Bandwidth::Voice::Response.new()
|
|
289
|
+
response.push(redirect)
|
|
290
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Redirect redirectUrl="https://redirect.com" redirectMethod="GET" tag="tag" username="user" password="pass" redirectFallbackUrl="https://test.com" redirectFallbackMethod="GET" fallbackUsername="fuser" fallbackPassword="fpass"/></Response>'
|
|
291
|
+
actual = response.to_bxml()
|
|
292
|
+
assert_equal(expected, actual)
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
def test_resume_recording
|
|
296
|
+
resume_recording = Bandwidth::Voice::ResumeRecording.new()
|
|
297
|
+
|
|
298
|
+
response = Bandwidth::Voice::Response.new()
|
|
299
|
+
response.push(resume_recording)
|
|
300
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><ResumeRecording/></Response>'
|
|
301
|
+
actual = response.to_bxml()
|
|
302
|
+
assert_equal(expected, actual)
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
def test_send_dtmf
|
|
306
|
+
send_dtmf = Bandwidth::Voice::SendDtmf.new({
|
|
307
|
+
:dtmf => "12w34",
|
|
308
|
+
:tone_duration => 75,
|
|
309
|
+
:tone_interval => 65
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
response = Bandwidth::Voice::Response.new()
|
|
313
|
+
response.push(send_dtmf)
|
|
314
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><SendDtmf toneDuration="75" toneInterval="65">12w34</SendDtmf></Response>'
|
|
315
|
+
actual = response.to_bxml()
|
|
316
|
+
assert_equal(expected, actual)
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
def test_speak_sentence
|
|
320
|
+
speak_sentence = Bandwidth::Voice::SpeakSentence.new({
|
|
321
|
+
:sentence => "test",
|
|
322
|
+
:voice => "julie",
|
|
323
|
+
:gender => "female",
|
|
324
|
+
:locale => "en_US"
|
|
325
|
+
})
|
|
326
|
+
|
|
327
|
+
response = Bandwidth::Voice::Response.new()
|
|
328
|
+
response.push(speak_sentence)
|
|
329
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><SpeakSentence voice="julie" locale="en_US" gender="female">test</SpeakSentence></Response>'
|
|
330
|
+
actual = response.to_bxml()
|
|
331
|
+
assert_equal(expected, actual)
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
def test_speak_sentence_ssml
|
|
335
|
+
speak_sentence = Bandwidth::Voice::SpeakSentence.new({
|
|
336
|
+
:sentence => 'Hello, you have reached the home of <lang xml:lang="es-MX">Antonio Mendoza</lang>.Please leave a message.',
|
|
337
|
+
})
|
|
338
|
+
|
|
339
|
+
response = Bandwidth::Voice::Response.new()
|
|
340
|
+
response.push(speak_sentence)
|
|
341
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><SpeakSentence>Hello, you have reached the home of <lang xml:lang="es-MX">Antonio Mendoza</lang>.Please leave a message.</SpeakSentence></Response>'
|
|
342
|
+
actual = response.to_bxml()
|
|
343
|
+
assert_equal(expected, actual)
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
def test_start_recording
|
|
347
|
+
start_recording = Bandwidth::Voice::StartRecording.new({
|
|
348
|
+
:recording_available_url => "https://available.com",
|
|
349
|
+
:recording_available_method => "POST",
|
|
350
|
+
:transcribe => false,
|
|
351
|
+
:transcription_available_url => "https://transcribe.com",
|
|
352
|
+
:transcription_available_method => "GET",
|
|
353
|
+
:username => "user",
|
|
354
|
+
:password => "pass",
|
|
355
|
+
:tag => "tag",
|
|
356
|
+
:file_format => "mp3",
|
|
357
|
+
:multi_channel => true
|
|
358
|
+
})
|
|
359
|
+
|
|
360
|
+
response = Bandwidth::Voice::Response.new()
|
|
361
|
+
response.push(start_recording)
|
|
362
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StartRecording tag="tag" username="user" password="pass" recordingAvailableUrl="https://available.com" recordingAvailableMethod="POST" fileFormat="mp3" multiChannel="true" transcribe="false" transcriptionAvailableUrl="https://transcribe.com" transcriptionAvailableMethod="GET"/></Response>'
|
|
363
|
+
actual = response.to_bxml()
|
|
364
|
+
assert_equal(expected, actual)
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
def test_stop_recording
|
|
368
|
+
stop_recording = Bandwidth::Voice::StopRecording.new()
|
|
369
|
+
|
|
370
|
+
response = Bandwidth::Voice::Response.new()
|
|
371
|
+
response.push(stop_recording)
|
|
372
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StopRecording/></Response>'
|
|
373
|
+
actual = response.to_bxml()
|
|
374
|
+
assert_equal(expected, actual)
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
def test_transfer
|
|
378
|
+
phone_number = Bandwidth::Voice::PhoneNumber.new({
|
|
379
|
+
:number => "+15554443333",
|
|
380
|
+
:transfer_answer_url => "https://phoneanswer.com",
|
|
381
|
+
:transfer_answer_method => "GET",
|
|
382
|
+
:transfer_disconnect_url => "https://phonedisconnect.com",
|
|
383
|
+
:transfer_disconnect_method => "POST",
|
|
384
|
+
:username => "phoneuser",
|
|
385
|
+
:password => "phonepassword",
|
|
386
|
+
:tag => "phonetag",
|
|
387
|
+
:transfer_answer_fallback_url => "https://test.com",
|
|
388
|
+
:transfer_answer_fallback_method => "GET",
|
|
389
|
+
:fallback_username => "fuser",
|
|
390
|
+
:fallback_password => "fpass"
|
|
391
|
+
})
|
|
392
|
+
transfer = Bandwidth::Voice::Transfer.new({
|
|
393
|
+
:transfer_caller_id => "+13334445555",
|
|
394
|
+
:call_timeout => 3,
|
|
395
|
+
:transfer_complete_url => "https://transfercomplete.com",
|
|
396
|
+
:transfer_complete_method => "POST",
|
|
397
|
+
:username => "transferuser",
|
|
398
|
+
:password => "transferpass",
|
|
399
|
+
:tag => "transfertag",
|
|
400
|
+
:diversion_treatment => "none",
|
|
401
|
+
:diversion_reason => "away",
|
|
402
|
+
:phone_numbers => [phone_number],
|
|
403
|
+
:transfer_complete_fallback_url => "https://test.com",
|
|
404
|
+
:transfer_complete_fallback_method => "GET",
|
|
405
|
+
:fallback_username => "fusern",
|
|
406
|
+
:fallback_password => "fpassw"
|
|
407
|
+
})
|
|
408
|
+
|
|
409
|
+
response = Bandwidth::Voice::Response.new()
|
|
410
|
+
response.push(transfer)
|
|
411
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Transfer transferCallerId="+13334445555" callTimeout="3" tag="transfertag" transferCompleteUrl="https://transfercomplete.com" transferCompleteMethod="POST" username="transferuser" password="transferpass" diversionTreatment="none" diversionReason="away" transferCompleteFallbackUrl="https://test.com" transferCompleteFallbackMethod="GET" fallbackUsername="fusern" fallbackPassword="fpassw"><PhoneNumber transferAnswerUrl="https://phoneanswer.com" transferAnswerMethod="GET" transferDisconnectUrl="https://phonedisconnect.com" transferDisconnectMethod="POST" username="phoneuser" password="phonepassword" tag="phonetag" transferAnswerFallbackUrl="https://test.com" transferAnswerFallbackMethod="GET" fallbackUsername="fuser" fallbackPassword="fpass">+15554443333</PhoneNumber></Transfer></Response>'
|
|
412
|
+
actual = response.to_bxml()
|
|
413
|
+
assert_equal(expected, actual)
|
|
414
|
+
end
|
|
415
|
+
|
|
416
|
+
def test_conference
|
|
417
|
+
conference = Bandwidth::Voice::Conference.new({
|
|
418
|
+
:conference_name => 'my-conference',
|
|
419
|
+
:mute => false,
|
|
420
|
+
:hold => true,
|
|
421
|
+
:call_ids_to_coach => "c-123,c-234",
|
|
422
|
+
:conference_event_url => "https://test.com",
|
|
423
|
+
:conference_event_method => "POST",
|
|
424
|
+
:username => "user",
|
|
425
|
+
:password => "pass",
|
|
426
|
+
:tag => "tag",
|
|
427
|
+
:conference_event_fallback_url => "https://test2.com",
|
|
428
|
+
:conference_event_fallback_method => "POST",
|
|
429
|
+
:fallback_username => "fuser",
|
|
430
|
+
:fallback_password => "fpass"
|
|
431
|
+
})
|
|
432
|
+
response = Bandwidth::Voice::Response.new()
|
|
433
|
+
response.push(conference)
|
|
434
|
+
|
|
435
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Conference mute="false" hold="true" callIdsToCoach="c-123,c-234" conferenceEventUrl="https://test.com" conferenceEventMethod="POST" username="user" password="pass" tag="tag" conferenceEventFallbackUrl="https://test2.com" conferenceEventFallbackMethod="POST" fallbackUsername="fuser" fallbackPassword="fpass">my-conference</Conference></Response>'
|
|
436
|
+
actual = response.to_bxml()
|
|
437
|
+
assert_equal(expected, actual)
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
def test_conference_coach_ids_array
|
|
441
|
+
conference = Bandwidth::Voice::Conference.new({
|
|
442
|
+
:conference_name => 'my-conference',
|
|
443
|
+
:call_ids_to_coach => ["c-123", "c-234"],
|
|
444
|
+
})
|
|
445
|
+
response = Bandwidth::Voice::Response.new()
|
|
446
|
+
response.push(conference)
|
|
447
|
+
|
|
448
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Conference callIdsToCoach="c-123,c-234">my-conference</Conference></Response>'
|
|
449
|
+
actual = response.to_bxml()
|
|
450
|
+
assert_equal(expected, actual)
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
def test_conference_no_coach
|
|
454
|
+
conference = Bandwidth::Voice::Conference.new({
|
|
455
|
+
:conference_name => 'my-conference'
|
|
456
|
+
})
|
|
457
|
+
response = Bandwidth::Voice::Response.new()
|
|
458
|
+
response.push(conference)
|
|
459
|
+
|
|
460
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Conference>my-conference</Conference></Response>'
|
|
461
|
+
actual = response.to_bxml()
|
|
462
|
+
assert_equal(expected, actual)
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
def test_mfa_messaging
|
|
466
|
+
body = TwoFactorCodeRequestSchema.new
|
|
467
|
+
body.from = PHONE_NUMBER_MFA
|
|
468
|
+
body.to = PHONE_NUMBER_INBOUND
|
|
469
|
+
body.application_id = MFA_MESSAGING_APPLICATION_ID
|
|
470
|
+
body.scope = "scope"
|
|
471
|
+
body.digits = 6
|
|
472
|
+
body.message = "Your temporary {NAME} {SCOPE} code is {CODE}"
|
|
473
|
+
|
|
474
|
+
response = @bandwidth_client.two_factor_auth_client.mfa.create_messaging_two_factor(ACCOUNT_ID, body)
|
|
475
|
+
assert(response.data.message_id.length > 0, "message id value not set")
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
def test_mfa_voice
|
|
479
|
+
body = TwoFactorCodeRequestSchema.new
|
|
480
|
+
body.from = PHONE_NUMBER_MFA
|
|
481
|
+
body.to = PHONE_NUMBER_INBOUND
|
|
482
|
+
body.application_id = MFA_VOICE_APPLICATION_ID
|
|
483
|
+
body.scope = "scope"
|
|
484
|
+
body.digits = 6
|
|
485
|
+
body.message = "Your temporary {NAME} {SCOPE} code is {CODE}"
|
|
486
|
+
|
|
487
|
+
response = @bandwidth_client.two_factor_auth_client.mfa.create_voice_two_factor(ACCOUNT_ID, body)
|
|
488
|
+
assert(response.data.call_id.length > 0, "call id value not set")
|
|
489
|
+
end
|
|
490
|
+
|
|
491
|
+
def test_mfa_verify
|
|
492
|
+
body = TwoFactorVerifyRequestSchema.new
|
|
493
|
+
body.to = PHONE_NUMBER_INBOUND
|
|
494
|
+
body.application_id = MFA_VOICE_APPLICATION_ID
|
|
495
|
+
body.scope = "scope"
|
|
496
|
+
body.code = "123456"
|
|
497
|
+
body.expiration_time_in_minutes = 3
|
|
498
|
+
response = @bandwidth_client.two_factor_auth_client.mfa.create_verify_two_factor(ACCOUNT_ID, body)
|
|
499
|
+
#Ruby has no check to see if variables are of type boolean
|
|
500
|
+
#An explicit true/false check is required
|
|
501
|
+
assert(response.data.valid == true || response.data.valid == false, "'valid' variable is not a boolean")
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
def test_bridge
|
|
505
|
+
bridge = Bandwidth::Voice::Bridge.new({
|
|
506
|
+
:call_id => "c-c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d",
|
|
507
|
+
:bridge_complete_url => "https://test.com",
|
|
508
|
+
:bridge_complete_method => "POST",
|
|
509
|
+
:bridge_target_complete_url => "https://test2.com",
|
|
510
|
+
:bridge_target_complete_method => "GET",
|
|
511
|
+
:username => "user",
|
|
512
|
+
:password => "pass",
|
|
513
|
+
:tag => "custom tag",
|
|
514
|
+
:bridge_complete_fallback_url => "https://test3.com",
|
|
515
|
+
:bridge_complete_fallback_method => "GET",
|
|
516
|
+
:bridge_target_complete_fallback_url => "https://test4.com",
|
|
517
|
+
:bridge_target_complete_fallback_method => "POST",
|
|
518
|
+
:fallback_username => "fuser",
|
|
519
|
+
:fallback_password => "fpass"
|
|
520
|
+
})
|
|
521
|
+
|
|
522
|
+
response = Bandwidth::Voice::Response.new()
|
|
523
|
+
response.push(bridge)
|
|
524
|
+
|
|
525
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Bridge bridgeCompleteUrl="https://test.com" bridgeCompleteMethod="POST" bridgeTargetCompleteUrl="https://test2.com" bridgeTargetCompleteMethod="GET" username="user" password="pass" tag="custom tag" bridgeCompleteFallbackUrl="https://test3.com" bridgeCompleteFallbackMethod="GET" bridgeTargetCompleteFallbackUrl="https://test4.com" bridgeTargetCompleteFallbackMethod="POST" fallbackUsername="fuser" fallbackPassword="fpass">c-c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d</Bridge></Response>'
|
|
526
|
+
actual = response.to_bxml()
|
|
527
|
+
assert_equal(expected, actual)
|
|
528
|
+
end
|
|
529
|
+
|
|
530
|
+
def test_ring
|
|
531
|
+
ring = Bandwidth::Voice::Ring.new({
|
|
532
|
+
:duration => 5
|
|
533
|
+
})
|
|
534
|
+
|
|
535
|
+
response = Bandwidth::Voice::Response.new()
|
|
536
|
+
response.push(ring)
|
|
537
|
+
|
|
538
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Ring duration="5"/></Response>'
|
|
539
|
+
actual = response.to_bxml()
|
|
540
|
+
assert_equal(expected, actual)
|
|
541
|
+
end
|
|
542
|
+
|
|
543
|
+
def test_start_gather
|
|
544
|
+
start_gather = Bandwidth::Voice::StartGather.new({
|
|
545
|
+
:username => "user",
|
|
546
|
+
:password => "pass",
|
|
547
|
+
:tag => "custom tag",
|
|
548
|
+
:dtmf_url => "https://test.com",
|
|
549
|
+
:dtmf_method => "GET"
|
|
550
|
+
})
|
|
551
|
+
|
|
552
|
+
response = Bandwidth::Voice::Response.new()
|
|
553
|
+
response.push(start_gather)
|
|
554
|
+
|
|
555
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StartGather username="user" password="pass" tag="custom tag" dtmfUrl="https://test.com" dtmfMethod="GET"/></Response>'
|
|
556
|
+
actual = response.to_bxml()
|
|
557
|
+
assert_equal(expected, actual)
|
|
558
|
+
end
|
|
559
|
+
|
|
560
|
+
def test_stop_gather
|
|
561
|
+
stop_gather = Bandwidth::Voice::StopGather.new()
|
|
562
|
+
|
|
563
|
+
response = Bandwidth::Voice::Response.new()
|
|
564
|
+
response.push(stop_gather)
|
|
565
|
+
|
|
566
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StopGather/></Response>'
|
|
567
|
+
actual = response.to_bxml()
|
|
568
|
+
assert_equal(expected, actual)
|
|
569
|
+
end
|
|
570
|
+
end
|