bandwidth-sdk 3.13.2 → 6.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +90 -13
- data/lib/bandwidth.rb +2 -0
- data/lib/bandwidth/api_helper.rb +5 -5
- data/lib/bandwidth/client.rb +15 -1
- data/lib/bandwidth/configuration.rb +40 -4
- data/lib/bandwidth/http/api_response.rb +2 -0
- data/lib/bandwidth/http/auth/phone_number_lookup_basic_auth.rb +22 -0
- data/lib/bandwidth/http/faraday_client.rb +14 -4
- data/lib/bandwidth/messaging_lib/messaging.rb +4 -0
- data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +135 -20
- data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
- 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/phone_number_lookup_lib/phone_number_lookup.rb +20 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/client.rb +60 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +1551 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +49 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth/exceptions/invalid_request_exception.rb → phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb} +5 -5
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +35 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +45 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +74 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +107 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +4 -2
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +4 -4
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/{api_controller.rb → mfa_controller.rb} +65 -14
- 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_verify_request_schema.rb +0 -19
- data/lib/bandwidth/voice_lib/voice.rb +1 -1
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +51 -52
- data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +77 -17
- data/lib/bandwidth/voice_lib/voice/models/{call_engine_modify_conference_request.rb → api_modify_conference_request.rb} +14 -14
- data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +3 -3
- data/lib/bandwidth/web_rtc_lib/web_rtc.rb +1 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +10 -1
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +24 -24
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +1 -1
- 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 +11 -2
- data/test/controllers/controller_test_base.rb +21 -0
- data/test/http_response_catcher.rb +19 -0
- data/test/integration/test_integration.rb +583 -0
- data/test/test_helper.rb +94 -0
- metadata +66 -11
@@ -4,8 +4,8 @@
|
|
4
4
|
# ( https://apimatic.io ).
|
5
5
|
|
6
6
|
module Bandwidth
|
7
|
-
#
|
8
|
-
class
|
7
|
+
# ApiModifyConferenceRequest Model.
|
8
|
+
class ApiModifyConferenceRequest < BaseModel
|
9
9
|
# TODO: Write general description for this method
|
10
10
|
# @return [StatusEnum]
|
11
11
|
attr_accessor :status
|
@@ -57,8 +57,8 @@ module Bandwidth
|
|
57
57
|
@_hash
|
58
58
|
end
|
59
59
|
|
60
|
-
def initialize(
|
61
|
-
|
60
|
+
def initialize(status = nil,
|
61
|
+
redirect_url = nil,
|
62
62
|
redirect_fallback_url = nil,
|
63
63
|
redirect_method = nil,
|
64
64
|
redirect_fallback_method = nil,
|
@@ -82,8 +82,8 @@ module Bandwidth
|
|
82
82
|
return nil unless hash
|
83
83
|
|
84
84
|
# Extract variables from the hash.
|
85
|
-
redirect_url = hash['redirectUrl']
|
86
85
|
status = hash['status']
|
86
|
+
redirect_url = hash['redirectUrl']
|
87
87
|
redirect_fallback_url = hash['redirectFallbackUrl']
|
88
88
|
redirect_method = hash['redirectMethod']
|
89
89
|
redirect_fallback_method = hash['redirectFallbackMethod']
|
@@ -93,15 +93,15 @@ module Bandwidth
|
|
93
93
|
fallback_password = hash['fallbackPassword']
|
94
94
|
|
95
95
|
# Create object from extracted values.
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
96
|
+
ApiModifyConferenceRequest.new(status,
|
97
|
+
redirect_url,
|
98
|
+
redirect_fallback_url,
|
99
|
+
redirect_method,
|
100
|
+
redirect_fallback_method,
|
101
|
+
username,
|
102
|
+
password,
|
103
|
+
fallback_username,
|
104
|
+
fallback_password)
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
@@ -8,13 +8,13 @@ module Bandwidth
|
|
8
8
|
class StateEnum
|
9
9
|
STATE_ENUM = [
|
10
10
|
# TODO: Write general description for DISCONNECTED
|
11
|
-
DISCONNECTED = '
|
11
|
+
DISCONNECTED = 'DISCONNECTED'.freeze,
|
12
12
|
|
13
13
|
# TODO: Write general description for ANSWERED
|
14
|
-
ANSWERED = '
|
14
|
+
ANSWERED = 'ANSWERED'.freeze,
|
15
15
|
|
16
16
|
# TODO: Write general description for INITIATED
|
17
|
-
INITIATED = '
|
17
|
+
INITIATED = 'INITIATED'.freeze
|
18
18
|
].freeze
|
19
19
|
end
|
20
20
|
end
|
@@ -12,6 +12,7 @@ require_relative 'web_rtc/models/participant.rb'
|
|
12
12
|
require_relative 'web_rtc/models/subscriptions.rb'
|
13
13
|
require_relative 'web_rtc/models/participant_subscription.rb'
|
14
14
|
require_relative 'web_rtc/models/accounts_participants_response.rb'
|
15
|
+
require_relative 'web_rtc/models/device_api_version_enum.rb'
|
15
16
|
require_relative 'web_rtc/models/publish_permission_enum.rb'
|
16
17
|
|
17
18
|
# Exceptions
|
@@ -16,12 +16,17 @@ module Bandwidth
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
|
19
|
-
backoff_factor:
|
19
|
+
backoff_factor: 2,
|
20
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
21
|
+
retry_methods: %i[get put get put],
|
22
|
+
environment: Environment::PRODUCTION,
|
20
23
|
base_url: 'https://www.example.com',
|
21
24
|
messaging_basic_auth_user_name: 'TODO: Replace',
|
22
25
|
messaging_basic_auth_password: 'TODO: Replace',
|
23
26
|
two_factor_auth_basic_auth_user_name: 'TODO: Replace',
|
24
27
|
two_factor_auth_basic_auth_password: 'TODO: Replace',
|
28
|
+
phone_number_lookup_basic_auth_user_name: 'TODO: Replace',
|
29
|
+
phone_number_lookup_basic_auth_password: 'TODO: Replace',
|
25
30
|
voice_basic_auth_user_name: 'TODO: Replace',
|
26
31
|
voice_basic_auth_password: 'TODO: Replace',
|
27
32
|
web_rtc_basic_auth_user_name: 'TODO: Replace',
|
@@ -32,12 +37,16 @@ module Bandwidth
|
|
32
37
|
max_retries: max_retries,
|
33
38
|
retry_interval: retry_interval,
|
34
39
|
backoff_factor: backoff_factor,
|
40
|
+
retry_statuses: retry_statuses,
|
41
|
+
retry_methods: retry_methods,
|
35
42
|
environment: environment,
|
36
43
|
base_url: base_url,
|
37
44
|
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
38
45
|
messaging_basic_auth_password: messaging_basic_auth_password,
|
39
46
|
two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
|
40
47
|
two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
|
48
|
+
phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name,
|
49
|
+
phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password,
|
41
50
|
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
42
51
|
voice_basic_auth_password: voice_basic_auth_password,
|
43
52
|
web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
|
@@ -24,7 +24,7 @@ module WebRtc
|
|
24
24
|
_query_builder << '/accounts/{accountId}/participants'
|
25
25
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
26
26
|
_query_builder,
|
27
|
-
'accountId' => { 'value' => account_id, 'encode' =>
|
27
|
+
'accountId' => { 'value' => account_id, 'encode' => false }
|
28
28
|
)
|
29
29
|
_query_url = APIHelper.clean_url _query_builder
|
30
30
|
|
@@ -87,8 +87,8 @@ module WebRtc
|
|
87
87
|
_query_builder << '/accounts/{accountId}/participants/{participantId}'
|
88
88
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
89
89
|
_query_builder,
|
90
|
-
'accountId' => { 'value' => account_id, 'encode' =>
|
91
|
-
'participantId' => { 'value' => participant_id, 'encode' =>
|
90
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
91
|
+
'participantId' => { 'value' => participant_id, 'encode' => false }
|
92
92
|
)
|
93
93
|
_query_url = APIHelper.clean_url _query_builder
|
94
94
|
|
@@ -148,8 +148,8 @@ module WebRtc
|
|
148
148
|
_query_builder << '/accounts/{accountId}/participants/{participantId}'
|
149
149
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
150
150
|
_query_builder,
|
151
|
-
'accountId' => { 'value' => account_id, 'encode' =>
|
152
|
-
'participantId' => { 'value' => participant_id, 'encode' =>
|
151
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
152
|
+
'participantId' => { 'value' => participant_id, 'encode' => false }
|
153
153
|
)
|
154
154
|
_query_url = APIHelper.clean_url _query_builder
|
155
155
|
|
@@ -202,7 +202,7 @@ module WebRtc
|
|
202
202
|
_query_builder << '/accounts/{accountId}/sessions'
|
203
203
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
204
204
|
_query_builder,
|
205
|
-
'accountId' => { 'value' => account_id, 'encode' =>
|
205
|
+
'accountId' => { 'value' => account_id, 'encode' => false }
|
206
206
|
)
|
207
207
|
_query_url = APIHelper.clean_url _query_builder
|
208
208
|
|
@@ -264,8 +264,8 @@ module WebRtc
|
|
264
264
|
_query_builder << '/accounts/{accountId}/sessions/{sessionId}'
|
265
265
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
266
266
|
_query_builder,
|
267
|
-
'accountId' => { 'value' => account_id, 'encode' =>
|
268
|
-
'sessionId' => { 'value' => session_id, 'encode' =>
|
267
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
268
|
+
'sessionId' => { 'value' => session_id, 'encode' => false }
|
269
269
|
)
|
270
270
|
_query_url = APIHelper.clean_url _query_builder
|
271
271
|
|
@@ -325,8 +325,8 @@ module WebRtc
|
|
325
325
|
_query_builder << '/accounts/{accountId}/sessions/{sessionId}'
|
326
326
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
327
327
|
_query_builder,
|
328
|
-
'accountId' => { 'value' => account_id, 'encode' =>
|
329
|
-
'sessionId' => { 'value' => session_id, 'encode' =>
|
328
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
329
|
+
'sessionId' => { 'value' => session_id, 'encode' => false }
|
330
330
|
)
|
331
331
|
_query_url = APIHelper.clean_url _query_builder
|
332
332
|
|
@@ -377,8 +377,8 @@ module WebRtc
|
|
377
377
|
_query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants'
|
378
378
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
379
379
|
_query_builder,
|
380
|
-
'accountId' => { 'value' => account_id, 'encode' =>
|
381
|
-
'sessionId' => { 'value' => session_id, 'encode' =>
|
380
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
381
|
+
'sessionId' => { 'value' => session_id, 'encode' => false }
|
382
382
|
)
|
383
383
|
_query_url = APIHelper.clean_url _query_builder
|
384
384
|
|
@@ -445,9 +445,9 @@ module WebRtc
|
|
445
445
|
_query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}'
|
446
446
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
447
447
|
_query_builder,
|
448
|
-
'accountId' => { 'value' => account_id, 'encode' =>
|
449
|
-
'sessionId' => { 'value' => session_id, 'encode' =>
|
450
|
-
'participantId' => { 'value' => participant_id, 'encode' =>
|
448
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
449
|
+
'sessionId' => { 'value' => session_id, 'encode' => false },
|
450
|
+
'participantId' => { 'value' => participant_id, 'encode' => false }
|
451
451
|
)
|
452
452
|
_query_url = APIHelper.clean_url _query_builder
|
453
453
|
|
@@ -509,9 +509,9 @@ module WebRtc
|
|
509
509
|
_query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}'
|
510
510
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
511
511
|
_query_builder,
|
512
|
-
'accountId' => { 'value' => account_id, 'encode' =>
|
513
|
-
'participantId' => { 'value' => participant_id, 'encode' =>
|
514
|
-
'sessionId' => { 'value' => session_id, 'encode' =>
|
512
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
513
|
+
'participantId' => { 'value' => participant_id, 'encode' => false },
|
514
|
+
'sessionId' => { 'value' => session_id, 'encode' => false }
|
515
515
|
)
|
516
516
|
_query_url = APIHelper.clean_url _query_builder
|
517
517
|
|
@@ -564,9 +564,9 @@ module WebRtc
|
|
564
564
|
_query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}/subscriptions'
|
565
565
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
566
566
|
_query_builder,
|
567
|
-
'accountId' => { 'value' => account_id, 'encode' =>
|
568
|
-
'participantId' => { 'value' => participant_id, 'encode' =>
|
569
|
-
'sessionId' => { 'value' => session_id, 'encode' =>
|
567
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
568
|
+
'participantId' => { 'value' => participant_id, 'encode' => false },
|
569
|
+
'sessionId' => { 'value' => session_id, 'encode' => false }
|
570
570
|
)
|
571
571
|
_query_url = APIHelper.clean_url _query_builder
|
572
572
|
|
@@ -634,9 +634,9 @@ module WebRtc
|
|
634
634
|
_query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}/subscriptions'
|
635
635
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
636
636
|
_query_builder,
|
637
|
-
'accountId' => { 'value' => account_id, 'encode' =>
|
638
|
-
'participantId' => { 'value' => participant_id, 'encode' =>
|
639
|
-
'sessionId' => { 'value' => session_id, 'encode' =>
|
637
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
638
|
+
'participantId' => { 'value' => participant_id, 'encode' => false },
|
639
|
+
'sessionId' => { 'value' => session_id, 'encode' => false }
|
640
640
|
)
|
641
641
|
_query_url = APIHelper.clean_url _query_builder
|
642
642
|
|
@@ -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
|
@@ -32,6 +32,10 @@ module Bandwidth
|
|
32
32
|
# @return [String]
|
33
33
|
attr_accessor :tag
|
34
34
|
|
35
|
+
# Optional field to define the device api version of this participant
|
36
|
+
# @return [DeviceApiVersionEnum]
|
37
|
+
attr_accessor :device_api_version
|
38
|
+
|
35
39
|
# A mapping from model property names to API property names.
|
36
40
|
def self.names
|
37
41
|
@_hash = {} if @_hash.nil?
|
@@ -41,6 +45,7 @@ module Bandwidth
|
|
41
45
|
@_hash['sessions'] = 'sessions'
|
42
46
|
@_hash['subscriptions'] = 'subscriptions'
|
43
47
|
@_hash['tag'] = 'tag'
|
48
|
+
@_hash['device_api_version'] = 'deviceApiVersion'
|
44
49
|
@_hash
|
45
50
|
end
|
46
51
|
|
@@ -49,13 +54,15 @@ module Bandwidth
|
|
49
54
|
publish_permissions = nil,
|
50
55
|
sessions = nil,
|
51
56
|
subscriptions = nil,
|
52
|
-
tag = nil
|
57
|
+
tag = nil,
|
58
|
+
device_api_version = DeviceApiVersionEnum::V2)
|
53
59
|
@id = id
|
54
60
|
@callback_url = callback_url
|
55
61
|
@publish_permissions = publish_permissions
|
56
62
|
@sessions = sessions
|
57
63
|
@subscriptions = subscriptions
|
58
64
|
@tag = tag
|
65
|
+
@device_api_version = device_api_version
|
59
66
|
end
|
60
67
|
|
61
68
|
# Creates an instance of the object from a hash.
|
@@ -70,6 +77,7 @@ module Bandwidth
|
|
70
77
|
subscriptions = Subscriptions.from_hash(hash['subscriptions']) if
|
71
78
|
hash['subscriptions']
|
72
79
|
tag = hash['tag']
|
80
|
+
device_api_version = hash['deviceApiVersion'] ||= DeviceApiVersionEnum::V2
|
73
81
|
|
74
82
|
# Create object from extracted values.
|
75
83
|
Participant.new(id,
|
@@ -77,7 +85,8 @@ module Bandwidth
|
|
77
85
|
publish_permissions,
|
78
86
|
sessions,
|
79
87
|
subscriptions,
|
80
|
-
tag
|
88
|
+
tag,
|
89
|
+
device_api_version)
|
81
90
|
end
|
82
91
|
end
|
83
92
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require 'json'
|
7
|
+
require 'minitest/autorun'
|
8
|
+
require 'minitest/hell'
|
9
|
+
require 'minitest/pride'
|
10
|
+
require 'minitest/proveit'
|
11
|
+
require 'bandwidth'
|
12
|
+
require_relative '../test_helper'
|
13
|
+
require_relative '../http_response_catcher'
|
14
|
+
|
15
|
+
class ControllerTestBase < Minitest::Test
|
16
|
+
parallelize_me!
|
17
|
+
include Bandwidth
|
18
|
+
|
19
|
+
# Create configuration and set any test parameters
|
20
|
+
CONFIG = Configuration.new
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
class HttpResponseCatcher < Bandwidth::HttpCallBack
|
7
|
+
attr_accessor :response
|
8
|
+
|
9
|
+
def on_before_request(request)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Catching the response
|
13
|
+
def on_after_response(response)
|
14
|
+
@response = response
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
|
@@ -0,0 +1,583 @@
|
|
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
|
+
phone_number_lookup_basic_auth_user_name: USERNAME,
|
40
|
+
phone_number_lookup_basic_auth_password: PASSWORD
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_create_message
|
45
|
+
body = MessageRequest.new
|
46
|
+
body.application_id = MESSAGING_APPLICATION_ID
|
47
|
+
body.to = [PHONE_NUMBER_INBOUND]
|
48
|
+
body.from = PHONE_NUMBER_OUTBOUND
|
49
|
+
body.text = "Ruby Integration"
|
50
|
+
response = @bandwidth_client.messaging_client.client.create_message(ACCOUNT_ID, body)
|
51
|
+
assert(response.data.id.length > 0, "id value not set") #validate that _some_ id was returned
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_create_message_invalid_phone_number
|
55
|
+
body = MessageRequest.new
|
56
|
+
body.application_id = MESSAGING_APPLICATION_ID
|
57
|
+
body.to = ["+1invalid"]
|
58
|
+
body.from = PHONE_NUMBER_OUTBOUND
|
59
|
+
body.text = "Ruby Integration"
|
60
|
+
begin
|
61
|
+
@bandwidth_client.messaging_client.client.create_message(ACCOUNT_ID, :body => body)
|
62
|
+
#workaround to make sure that if the above error is not raised, the build will fail
|
63
|
+
assert(false, "Expected exception not raised")
|
64
|
+
rescue MessagingException => e
|
65
|
+
assert(e.description.length > 0, "description value not set")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_upload_download_media
|
70
|
+
#define constants for upload media and download media
|
71
|
+
media_file_name = 'ruby_integration' #future update to add special symbols
|
72
|
+
media_file = '12345' #todo: check a binary string
|
73
|
+
|
74
|
+
#media upload
|
75
|
+
@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")
|
76
|
+
|
77
|
+
#media download
|
78
|
+
downloaded_media_file = @bandwidth_client.messaging_client.client.get_media(ACCOUNT_ID, media_file_name).data
|
79
|
+
|
80
|
+
assert_equal(downloaded_media_file, media_file, "Downloaded media file not equal to upload")
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_create_call_and_get_call_state
|
84
|
+
body = ApiCreateCallRequest.new
|
85
|
+
body.from = PHONE_NUMBER_OUTBOUND
|
86
|
+
body.to = PHONE_NUMBER_INBOUND
|
87
|
+
body.application_id = VOICE_APPLICATION_ID
|
88
|
+
body.answer_url = CALLBACK_URL
|
89
|
+
response = @bandwidth_client.voice_client.client.create_call(ACCOUNT_ID, :body => body)
|
90
|
+
assert(response.data.call_id.length > 0, "call_id value not set")
|
91
|
+
|
92
|
+
#Get phone call information
|
93
|
+
response = @bandwidth_client.voice_client.client.get_call_state(ACCOUNT_ID, response.data.call_id)
|
94
|
+
assert(response.data.state.length > 0, "state value not set")
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_create_call_invalid_phone_number
|
98
|
+
body = ApiCreateCallRequest.new
|
99
|
+
body.from = PHONE_NUMBER_OUTBOUND
|
100
|
+
body.to = "+1invalid"
|
101
|
+
body.application_id = VOICE_APPLICATION_ID
|
102
|
+
body.answer_url = CALLBACK_URL
|
103
|
+
|
104
|
+
begin
|
105
|
+
@bandwidth_client.voice_client.client.create_call(ACCOUNT_ID, :body => body)
|
106
|
+
#workaround to make sure that if the above error is not raised, the build will fail
|
107
|
+
assert(false, "Expected exception not raised")
|
108
|
+
rescue ApiErrorResponseException => e
|
109
|
+
assert(e.description.length > 0, "description value not set")
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_forward
|
114
|
+
forward = Bandwidth::Voice::Forward.new({
|
115
|
+
:to => "+15554443333",
|
116
|
+
:from => "+13334445555",
|
117
|
+
:call_timeout => 25,
|
118
|
+
:diversion_treatment => "none",
|
119
|
+
:diversion_reason => "away"
|
120
|
+
})
|
121
|
+
|
122
|
+
response = Bandwidth::Voice::Response.new()
|
123
|
+
response.push(forward)
|
124
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Forward to="+15554443333" from="+13334445555" callTimeout="25" diversionTreatment="none" diversionReason="away"/></Response>'
|
125
|
+
actual = response.to_bxml()
|
126
|
+
assert_equal(expected, actual)
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_gather
|
130
|
+
gather = Bandwidth::Voice::Gather.new({
|
131
|
+
:gather_url => "https://test.com",
|
132
|
+
:gather_method => "POST",
|
133
|
+
:username => "user",
|
134
|
+
:password => "pass",
|
135
|
+
:tag => "tag",
|
136
|
+
:terminating_digits => "#",
|
137
|
+
:max_digits => 3,
|
138
|
+
:inter_digit_timeout => 5,
|
139
|
+
:first_digit_timeout => "10",
|
140
|
+
:repeat_count => 1,
|
141
|
+
:gather_fallback_url => "https://test.com",
|
142
|
+
:gather_fallback_method => "GET",
|
143
|
+
:fallback_username => "fuser",
|
144
|
+
:fallback_password => "fpass"
|
145
|
+
})
|
146
|
+
|
147
|
+
response = Bandwidth::Voice::Response.new()
|
148
|
+
response.push(gather)
|
149
|
+
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>'
|
150
|
+
actual = response.to_bxml()
|
151
|
+
assert_equal(expected, actual)
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_gather_nested_speak_sentence
|
155
|
+
speak_sentence = Bandwidth::Voice::SpeakSentence.new({
|
156
|
+
:sentence => "test"
|
157
|
+
})
|
158
|
+
gather = Bandwidth::Voice::Gather.new({
|
159
|
+
:speak_sentence => speak_sentence
|
160
|
+
})
|
161
|
+
|
162
|
+
response = Bandwidth::Voice::Response.new()
|
163
|
+
response.push(gather)
|
164
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Gather><SpeakSentence>test</SpeakSentence></Gather></Response>'
|
165
|
+
actual = response.to_bxml()
|
166
|
+
assert_equal(expected, actual)
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_gather_nested_play_audio
|
170
|
+
play_audio = Bandwidth::Voice::PlayAudio.new({
|
171
|
+
:url => "https://test.com"
|
172
|
+
})
|
173
|
+
gather = Bandwidth::Voice::Gather.new({
|
174
|
+
:play_audio => play_audio
|
175
|
+
})
|
176
|
+
|
177
|
+
response = Bandwidth::Voice::Response.new()
|
178
|
+
response.push(gather)
|
179
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Gather><PlayAudio>https://test.com</PlayAudio></Gather></Response>'
|
180
|
+
actual = response.to_bxml()
|
181
|
+
assert_equal(expected, actual)
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_gather_multiple_nested_verbs
|
185
|
+
play_audio = Bandwidth::Voice::PlayAudio.new({
|
186
|
+
:url => "https://test.com"
|
187
|
+
})
|
188
|
+
speak_sentence = Bandwidth::Voice::SpeakSentence.new({
|
189
|
+
:sentence => "test"
|
190
|
+
})
|
191
|
+
gather = Bandwidth::Voice::Gather.new({
|
192
|
+
:nested_verbs => [play_audio, speak_sentence]
|
193
|
+
})
|
194
|
+
|
195
|
+
response = Bandwidth::Voice::Response.new()
|
196
|
+
response.push(gather)
|
197
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Gather><PlayAudio>https://test.com</PlayAudio><SpeakSentence>test</SpeakSentence></Gather></Response>'
|
198
|
+
actual = response.to_bxml()
|
199
|
+
assert_equal(expected, actual)
|
200
|
+
end
|
201
|
+
|
202
|
+
def test_hangup
|
203
|
+
hangup = Bandwidth::Voice::Hangup.new()
|
204
|
+
|
205
|
+
response = Bandwidth::Voice::Response.new()
|
206
|
+
response.push(hangup)
|
207
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Hangup/></Response>'
|
208
|
+
actual = response.to_bxml()
|
209
|
+
assert_equal(expected, actual)
|
210
|
+
end
|
211
|
+
|
212
|
+
def test_pause
|
213
|
+
pause = Bandwidth::Voice::Pause.new({
|
214
|
+
:duration => 2
|
215
|
+
})
|
216
|
+
|
217
|
+
response = Bandwidth::Voice::Response.new()
|
218
|
+
response.push(pause)
|
219
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Pause duration="2"/></Response>'
|
220
|
+
actual = response.to_bxml()
|
221
|
+
assert_equal(expected, actual)
|
222
|
+
end
|
223
|
+
|
224
|
+
def test_pause_recording
|
225
|
+
pause_recording = Bandwidth::Voice::PauseRecording.new()
|
226
|
+
|
227
|
+
response = Bandwidth::Voice::Response.new()
|
228
|
+
response.push(pause_recording)
|
229
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><PauseRecording/></Response>'
|
230
|
+
actual = response.to_bxml()
|
231
|
+
assert_equal(expected, actual)
|
232
|
+
end
|
233
|
+
|
234
|
+
def test_play_audio
|
235
|
+
play_audio = Bandwidth::Voice::PlayAudio.new({
|
236
|
+
:url => "https://test.com",
|
237
|
+
:username => "user",
|
238
|
+
:password => "pass"
|
239
|
+
})
|
240
|
+
|
241
|
+
response = Bandwidth::Voice::Response.new()
|
242
|
+
response.push(play_audio)
|
243
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><PlayAudio username="user" password="pass">https://test.com</PlayAudio></Response>'
|
244
|
+
actual = response.to_bxml()
|
245
|
+
assert_equal(expected, actual)
|
246
|
+
end
|
247
|
+
|
248
|
+
def test_record
|
249
|
+
record = Bandwidth::Voice::Record.new({
|
250
|
+
:record_complete_url => "https://complete.com",
|
251
|
+
:record_complete_method => "POST",
|
252
|
+
:recording_available_url => "https://available.com",
|
253
|
+
:recording_available_method => "GET",
|
254
|
+
:transcribe => false,
|
255
|
+
:transcription_available_url => "https://transcribe.com",
|
256
|
+
:transcription_available_method => "POST",
|
257
|
+
:username => "user",
|
258
|
+
:password => "pass",
|
259
|
+
:tag => "tag",
|
260
|
+
:terminating_digits => "#",
|
261
|
+
:max_duration => 3,
|
262
|
+
:silence_timeout => 5,
|
263
|
+
:file_format => "wav",
|
264
|
+
:record_complete_fallback_url => "https://test.com",
|
265
|
+
:record_complete_fallback_method => "GET",
|
266
|
+
:fallback_username => "fuser",
|
267
|
+
:fallback_password => "fpass"
|
268
|
+
})
|
269
|
+
|
270
|
+
response = Bandwidth::Voice::Response.new()
|
271
|
+
response.push(record)
|
272
|
+
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>'
|
273
|
+
actual = response.to_bxml()
|
274
|
+
assert_equal(expected, actual)
|
275
|
+
end
|
276
|
+
|
277
|
+
def test_redirect
|
278
|
+
redirect = Bandwidth::Voice::Redirect.new({
|
279
|
+
:redirect_url => "https://redirect.com",
|
280
|
+
:redirect_method => "GET",
|
281
|
+
:username => "user",
|
282
|
+
:password => "pass",
|
283
|
+
:tag => "tag",
|
284
|
+
:redirect_fallback_url => "https://test.com",
|
285
|
+
:redirect_fallback_method => "GET",
|
286
|
+
:fallback_username => "fuser",
|
287
|
+
:fallback_password => "fpass"
|
288
|
+
})
|
289
|
+
|
290
|
+
response = Bandwidth::Voice::Response.new()
|
291
|
+
response.push(redirect)
|
292
|
+
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>'
|
293
|
+
actual = response.to_bxml()
|
294
|
+
assert_equal(expected, actual)
|
295
|
+
end
|
296
|
+
|
297
|
+
def test_resume_recording
|
298
|
+
resume_recording = Bandwidth::Voice::ResumeRecording.new()
|
299
|
+
|
300
|
+
response = Bandwidth::Voice::Response.new()
|
301
|
+
response.push(resume_recording)
|
302
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><ResumeRecording/></Response>'
|
303
|
+
actual = response.to_bxml()
|
304
|
+
assert_equal(expected, actual)
|
305
|
+
end
|
306
|
+
|
307
|
+
def test_send_dtmf
|
308
|
+
send_dtmf = Bandwidth::Voice::SendDtmf.new({
|
309
|
+
:dtmf => "12w34",
|
310
|
+
:tone_duration => 75,
|
311
|
+
:tone_interval => 65
|
312
|
+
})
|
313
|
+
|
314
|
+
response = Bandwidth::Voice::Response.new()
|
315
|
+
response.push(send_dtmf)
|
316
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><SendDtmf toneDuration="75" toneInterval="65">12w34</SendDtmf></Response>'
|
317
|
+
actual = response.to_bxml()
|
318
|
+
assert_equal(expected, actual)
|
319
|
+
end
|
320
|
+
|
321
|
+
def test_speak_sentence
|
322
|
+
speak_sentence = Bandwidth::Voice::SpeakSentence.new({
|
323
|
+
:sentence => "test",
|
324
|
+
:voice => "julie",
|
325
|
+
:gender => "female",
|
326
|
+
:locale => "en_US"
|
327
|
+
})
|
328
|
+
|
329
|
+
response = Bandwidth::Voice::Response.new()
|
330
|
+
response.push(speak_sentence)
|
331
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><SpeakSentence voice="julie" locale="en_US" gender="female">test</SpeakSentence></Response>'
|
332
|
+
actual = response.to_bxml()
|
333
|
+
assert_equal(expected, actual)
|
334
|
+
end
|
335
|
+
|
336
|
+
def test_speak_sentence_ssml
|
337
|
+
speak_sentence = Bandwidth::Voice::SpeakSentence.new({
|
338
|
+
:sentence => 'Hello, you have reached the home of <lang xml:lang="es-MX">Antonio Mendoza</lang>.Please leave a message.',
|
339
|
+
})
|
340
|
+
|
341
|
+
response = Bandwidth::Voice::Response.new()
|
342
|
+
response.push(speak_sentence)
|
343
|
+
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>'
|
344
|
+
actual = response.to_bxml()
|
345
|
+
assert_equal(expected, actual)
|
346
|
+
end
|
347
|
+
|
348
|
+
def test_start_recording
|
349
|
+
start_recording = Bandwidth::Voice::StartRecording.new({
|
350
|
+
:recording_available_url => "https://available.com",
|
351
|
+
:recording_available_method => "POST",
|
352
|
+
:transcribe => false,
|
353
|
+
:transcription_available_url => "https://transcribe.com",
|
354
|
+
:transcription_available_method => "GET",
|
355
|
+
:username => "user",
|
356
|
+
:password => "pass",
|
357
|
+
:tag => "tag",
|
358
|
+
:file_format => "mp3",
|
359
|
+
:multi_channel => true
|
360
|
+
})
|
361
|
+
|
362
|
+
response = Bandwidth::Voice::Response.new()
|
363
|
+
response.push(start_recording)
|
364
|
+
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>'
|
365
|
+
actual = response.to_bxml()
|
366
|
+
assert_equal(expected, actual)
|
367
|
+
end
|
368
|
+
|
369
|
+
def test_stop_recording
|
370
|
+
stop_recording = Bandwidth::Voice::StopRecording.new()
|
371
|
+
|
372
|
+
response = Bandwidth::Voice::Response.new()
|
373
|
+
response.push(stop_recording)
|
374
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StopRecording/></Response>'
|
375
|
+
actual = response.to_bxml()
|
376
|
+
assert_equal(expected, actual)
|
377
|
+
end
|
378
|
+
|
379
|
+
def test_transfer
|
380
|
+
phone_number = Bandwidth::Voice::PhoneNumber.new({
|
381
|
+
:number => "+15554443333",
|
382
|
+
:transfer_answer_url => "https://phoneanswer.com",
|
383
|
+
:transfer_answer_method => "GET",
|
384
|
+
:transfer_disconnect_url => "https://phonedisconnect.com",
|
385
|
+
:transfer_disconnect_method => "POST",
|
386
|
+
:username => "phoneuser",
|
387
|
+
:password => "phonepassword",
|
388
|
+
:tag => "phonetag",
|
389
|
+
:transfer_answer_fallback_url => "https://test.com",
|
390
|
+
:transfer_answer_fallback_method => "GET",
|
391
|
+
:fallback_username => "fuser",
|
392
|
+
:fallback_password => "fpass"
|
393
|
+
})
|
394
|
+
transfer = Bandwidth::Voice::Transfer.new({
|
395
|
+
:transfer_caller_id => "+13334445555",
|
396
|
+
:call_timeout => 3,
|
397
|
+
:transfer_complete_url => "https://transfercomplete.com",
|
398
|
+
:transfer_complete_method => "POST",
|
399
|
+
:username => "transferuser",
|
400
|
+
:password => "transferpass",
|
401
|
+
:tag => "transfertag",
|
402
|
+
:diversion_treatment => "none",
|
403
|
+
:diversion_reason => "away",
|
404
|
+
:phone_numbers => [phone_number],
|
405
|
+
:transfer_complete_fallback_url => "https://test.com",
|
406
|
+
:transfer_complete_fallback_method => "GET",
|
407
|
+
:fallback_username => "fusern",
|
408
|
+
:fallback_password => "fpassw"
|
409
|
+
})
|
410
|
+
|
411
|
+
response = Bandwidth::Voice::Response.new()
|
412
|
+
response.push(transfer)
|
413
|
+
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>'
|
414
|
+
actual = response.to_bxml()
|
415
|
+
assert_equal(expected, actual)
|
416
|
+
end
|
417
|
+
|
418
|
+
def test_conference
|
419
|
+
conference = Bandwidth::Voice::Conference.new({
|
420
|
+
:conference_name => 'my-conference',
|
421
|
+
:mute => false,
|
422
|
+
:hold => true,
|
423
|
+
:call_ids_to_coach => "c-123,c-234",
|
424
|
+
:conference_event_url => "https://test.com",
|
425
|
+
:conference_event_method => "POST",
|
426
|
+
:username => "user",
|
427
|
+
:password => "pass",
|
428
|
+
:tag => "tag",
|
429
|
+
:conference_event_fallback_url => "https://test2.com",
|
430
|
+
:conference_event_fallback_method => "POST",
|
431
|
+
:fallback_username => "fuser",
|
432
|
+
:fallback_password => "fpass"
|
433
|
+
})
|
434
|
+
response = Bandwidth::Voice::Response.new()
|
435
|
+
response.push(conference)
|
436
|
+
|
437
|
+
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>'
|
438
|
+
actual = response.to_bxml()
|
439
|
+
assert_equal(expected, actual)
|
440
|
+
end
|
441
|
+
|
442
|
+
def test_conference_coach_ids_array
|
443
|
+
conference = Bandwidth::Voice::Conference.new({
|
444
|
+
:conference_name => 'my-conference',
|
445
|
+
:call_ids_to_coach => ["c-123", "c-234"],
|
446
|
+
})
|
447
|
+
response = Bandwidth::Voice::Response.new()
|
448
|
+
response.push(conference)
|
449
|
+
|
450
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Conference callIdsToCoach="c-123,c-234">my-conference</Conference></Response>'
|
451
|
+
actual = response.to_bxml()
|
452
|
+
assert_equal(expected, actual)
|
453
|
+
end
|
454
|
+
|
455
|
+
def test_conference_no_coach
|
456
|
+
conference = Bandwidth::Voice::Conference.new({
|
457
|
+
:conference_name => 'my-conference'
|
458
|
+
})
|
459
|
+
response = Bandwidth::Voice::Response.new()
|
460
|
+
response.push(conference)
|
461
|
+
|
462
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Conference>my-conference</Conference></Response>'
|
463
|
+
actual = response.to_bxml()
|
464
|
+
assert_equal(expected, actual)
|
465
|
+
end
|
466
|
+
|
467
|
+
def test_mfa_messaging
|
468
|
+
body = TwoFactorCodeRequestSchema.new
|
469
|
+
body.from = PHONE_NUMBER_MFA
|
470
|
+
body.to = PHONE_NUMBER_INBOUND
|
471
|
+
body.application_id = MFA_MESSAGING_APPLICATION_ID
|
472
|
+
body.scope = "scope"
|
473
|
+
body.digits = 6
|
474
|
+
body.message = "Your temporary {NAME} {SCOPE} code is {CODE}"
|
475
|
+
|
476
|
+
response = @bandwidth_client.two_factor_auth_client.mfa.create_messaging_two_factor(ACCOUNT_ID, body)
|
477
|
+
assert(response.data.message_id.length > 0, "message id value not set")
|
478
|
+
end
|
479
|
+
|
480
|
+
def test_mfa_voice
|
481
|
+
body = TwoFactorCodeRequestSchema.new
|
482
|
+
body.from = PHONE_NUMBER_MFA
|
483
|
+
body.to = PHONE_NUMBER_INBOUND
|
484
|
+
body.application_id = MFA_VOICE_APPLICATION_ID
|
485
|
+
body.scope = "scope"
|
486
|
+
body.digits = 6
|
487
|
+
body.message = "Your temporary {NAME} {SCOPE} code is {CODE}"
|
488
|
+
|
489
|
+
response = @bandwidth_client.two_factor_auth_client.mfa.create_voice_two_factor(ACCOUNT_ID, body)
|
490
|
+
assert(response.data.call_id.length > 0, "call id value not set")
|
491
|
+
end
|
492
|
+
|
493
|
+
def test_mfa_verify
|
494
|
+
body = TwoFactorVerifyRequestSchema.new
|
495
|
+
body.to = PHONE_NUMBER_INBOUND
|
496
|
+
body.application_id = MFA_VOICE_APPLICATION_ID
|
497
|
+
body.scope = "scope"
|
498
|
+
body.code = "123456"
|
499
|
+
body.expiration_time_in_minutes = 3
|
500
|
+
response = @bandwidth_client.two_factor_auth_client.mfa.create_verify_two_factor(ACCOUNT_ID, body)
|
501
|
+
#Ruby has no check to see if variables are of type boolean
|
502
|
+
#An explicit true/false check is required
|
503
|
+
assert(response.data.valid == true || response.data.valid == false, "'valid' variable is not a boolean")
|
504
|
+
end
|
505
|
+
|
506
|
+
def test_bridge
|
507
|
+
bridge = Bandwidth::Voice::Bridge.new({
|
508
|
+
:call_id => "c-c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d",
|
509
|
+
:bridge_complete_url => "https://test.com",
|
510
|
+
:bridge_complete_method => "POST",
|
511
|
+
:bridge_target_complete_url => "https://test2.com",
|
512
|
+
:bridge_target_complete_method => "GET",
|
513
|
+
:username => "user",
|
514
|
+
:password => "pass",
|
515
|
+
:tag => "custom tag",
|
516
|
+
:bridge_complete_fallback_url => "https://test3.com",
|
517
|
+
:bridge_complete_fallback_method => "GET",
|
518
|
+
:bridge_target_complete_fallback_url => "https://test4.com",
|
519
|
+
:bridge_target_complete_fallback_method => "POST",
|
520
|
+
:fallback_username => "fuser",
|
521
|
+
:fallback_password => "fpass"
|
522
|
+
})
|
523
|
+
|
524
|
+
response = Bandwidth::Voice::Response.new()
|
525
|
+
response.push(bridge)
|
526
|
+
|
527
|
+
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>'
|
528
|
+
actual = response.to_bxml()
|
529
|
+
assert_equal(expected, actual)
|
530
|
+
end
|
531
|
+
|
532
|
+
def test_ring
|
533
|
+
ring = Bandwidth::Voice::Ring.new({
|
534
|
+
:duration => 5
|
535
|
+
})
|
536
|
+
|
537
|
+
response = Bandwidth::Voice::Response.new()
|
538
|
+
response.push(ring)
|
539
|
+
|
540
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Ring duration="5"/></Response>'
|
541
|
+
actual = response.to_bxml()
|
542
|
+
assert_equal(expected, actual)
|
543
|
+
end
|
544
|
+
|
545
|
+
def test_start_gather
|
546
|
+
start_gather = Bandwidth::Voice::StartGather.new({
|
547
|
+
:username => "user",
|
548
|
+
:password => "pass",
|
549
|
+
:tag => "custom tag",
|
550
|
+
:dtmf_url => "https://test.com",
|
551
|
+
:dtmf_method => "GET"
|
552
|
+
})
|
553
|
+
|
554
|
+
response = Bandwidth::Voice::Response.new()
|
555
|
+
response.push(start_gather)
|
556
|
+
|
557
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StartGather username="user" password="pass" tag="custom tag" dtmfUrl="https://test.com" dtmfMethod="GET"/></Response>'
|
558
|
+
actual = response.to_bxml()
|
559
|
+
assert_equal(expected, actual)
|
560
|
+
end
|
561
|
+
|
562
|
+
def test_stop_gather
|
563
|
+
stop_gather = Bandwidth::Voice::StopGather.new()
|
564
|
+
|
565
|
+
response = Bandwidth::Voice::Response.new()
|
566
|
+
response.push(stop_gather)
|
567
|
+
|
568
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StopGather/></Response>'
|
569
|
+
actual = response.to_bxml()
|
570
|
+
assert_equal(expected, actual)
|
571
|
+
end
|
572
|
+
|
573
|
+
def test_tn_lookup
|
574
|
+
body = OrderRequest.new
|
575
|
+
body.tns = [PHONE_NUMBER_OUTBOUND]
|
576
|
+
create_response = @bandwidth_client.phone_number_lookup_client.client.create_lookup_request(ACCOUNT_ID, body)
|
577
|
+
assert(create_response.data.request_id.length > 0, "request_id value not set")
|
578
|
+
|
579
|
+
request_id = create_response.data.request_id
|
580
|
+
get_response = @bandwidth_client.phone_number_lookup_client.client.get_lookup_request_status(ACCOUNT_ID, request_id)
|
581
|
+
assert(get_response.data.status.length > 0, "status value not set")
|
582
|
+
end
|
583
|
+
end
|