bandwidth-sdk 7.0.0 → 9.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/README.md +10 -0
- data/lib/bandwidth/api_helper.rb +19 -17
- data/lib/bandwidth/configuration.rb +7 -19
- data/lib/bandwidth/http/faraday_client.rb +1 -1
- data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +53 -42
- data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/messaging_lib/messaging/exceptions/messaging_exception.rb +5 -2
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb +31 -11
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +54 -25
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +65 -32
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +23 -4
- data/lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb +20 -4
- data/lib/bandwidth/messaging_lib/messaging/models/media.rb +23 -6
- data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +32 -14
- data/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +28 -8
- data/lib/bandwidth/messaging_lib/messaging/models/tag.rb +20 -4
- data/lib/bandwidth/models/base_model.rb +11 -0
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/mfa_controller.rb +21 -16
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb +5 -2
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/forbidden_request_exception.rb +4 -1
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/unauthorized_request_exception.rb +4 -1
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_code_request_schema.rb +27 -12
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_messaging_response.rb +17 -2
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_code_response.rb +17 -2
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_request_schema.rb +29 -10
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_voice_response.rb +17 -2
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +212 -210
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb +4 -1
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +17 -2
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +20 -4
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +28 -7
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +43 -18
- data/lib/bandwidth/utilities/date_time_helper.rb +2 -2
- data/lib/bandwidth/utilities/file_wrapper.rb +1 -2
- data/lib/bandwidth/voice_lib/bxml/verbs/ring.rb +2 -1
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +171 -150
- data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb +6 -3
- data/lib/bandwidth/voice_lib/voice/models/call_callback.rb +343 -0
- data/lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb +78 -37
- data/lib/bandwidth/voice_lib/voice/models/call_state.rb +94 -42
- data/lib/bandwidth/voice_lib/voice/models/conference_callback.rb +211 -0
- data/lib/bandwidth/voice_lib/voice/models/conference_member_state.rb +35 -12
- data/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb +55 -24
- data/lib/bandwidth/voice_lib/voice/models/conference_state.rb +54 -17
- data/lib/bandwidth/voice_lib/voice/models/create_call_request.rb +173 -96
- data/lib/bandwidth/voice_lib/voice/models/create_call_response.rb +85 -41
- data/lib/bandwidth/voice_lib/voice/models/diversion.rb +80 -0
- data/lib/bandwidth/voice_lib/voice/models/fallback_method_enum.rb +17 -0
- data/lib/bandwidth/voice_lib/voice/models/machine_detection_configuration.rb +218 -0
- data/lib/bandwidth/voice_lib/voice/models/mode_enum.rb +20 -0
- data/lib/bandwidth/voice_lib/voice/models/modify_call_recording_request.rb +15 -2
- data/lib/bandwidth/voice_lib/voice/models/modify_call_request.rb +59 -19
- data/lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb +55 -18
- data/lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb +40 -12
- data/lib/bandwidth/voice_lib/voice/models/transcript.rb +20 -4
- data/lib/bandwidth/voice_lib/voice/models/transcription.rb +80 -0
- data/lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb +26 -8
- data/lib/bandwidth/voice_lib/voice/models/transcription_response.rb +18 -1
- data/lib/bandwidth/voice_lib/voice.rb +7 -1
- data/lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb +7 -2
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +61 -50
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/web_rtc_lib/web_rtc/exceptions/error_exception.rb +5 -2
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +20 -5
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +37 -14
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +15 -2
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +20 -4
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +20 -3
- data/lib/bandwidth.rb +19 -18
- data/test/integration/test_integration.rb +95 -58
- metadata +10 -3
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
module Bandwidth
|
|
7
7
|
# ParticipantSubscription Model.
|
|
8
8
|
class ParticipantSubscription < BaseModel
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
9
12
|
# Participant the subscriber should be subscribed to
|
|
10
13
|
# @return [String]
|
|
11
14
|
attr_accessor :participant_id
|
|
@@ -17,8 +20,18 @@ module Bandwidth
|
|
|
17
20
|
@_hash
|
|
18
21
|
end
|
|
19
22
|
|
|
23
|
+
# An array for optional fields
|
|
24
|
+
def optionals
|
|
25
|
+
[]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# An array for nullable fields
|
|
29
|
+
def nullables
|
|
30
|
+
[]
|
|
31
|
+
end
|
|
32
|
+
|
|
20
33
|
def initialize(participant_id = nil)
|
|
21
|
-
@participant_id = participant_id
|
|
34
|
+
@participant_id = participant_id unless participant_id == SKIP
|
|
22
35
|
end
|
|
23
36
|
|
|
24
37
|
# Creates an instance of the object from a hash.
|
|
@@ -26,7 +39,7 @@ module Bandwidth
|
|
|
26
39
|
return nil unless hash
|
|
27
40
|
|
|
28
41
|
# Extract variables from the hash.
|
|
29
|
-
participant_id = hash['participantId']
|
|
42
|
+
participant_id = hash.key?('participantId') ? hash['participantId'] : SKIP
|
|
30
43
|
|
|
31
44
|
# Create object from extracted values.
|
|
32
45
|
ParticipantSubscription.new(participant_id)
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
module Bandwidth
|
|
7
7
|
# A session object
|
|
8
8
|
class Session < BaseModel
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
9
12
|
# Unique id of the session
|
|
10
13
|
# @return [String]
|
|
11
14
|
attr_accessor :id
|
|
@@ -22,10 +25,23 @@ module Bandwidth
|
|
|
22
25
|
@_hash
|
|
23
26
|
end
|
|
24
27
|
|
|
28
|
+
# An array for optional fields
|
|
29
|
+
def optionals
|
|
30
|
+
%w[
|
|
31
|
+
id
|
|
32
|
+
tag
|
|
33
|
+
]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# An array for nullable fields
|
|
37
|
+
def nullables
|
|
38
|
+
[]
|
|
39
|
+
end
|
|
40
|
+
|
|
25
41
|
def initialize(id = nil,
|
|
26
42
|
tag = nil)
|
|
27
|
-
@id = id
|
|
28
|
-
@tag = tag
|
|
43
|
+
@id = id unless id == SKIP
|
|
44
|
+
@tag = tag unless tag == SKIP
|
|
29
45
|
end
|
|
30
46
|
|
|
31
47
|
# Creates an instance of the object from a hash.
|
|
@@ -33,8 +49,8 @@ module Bandwidth
|
|
|
33
49
|
return nil unless hash
|
|
34
50
|
|
|
35
51
|
# Extract variables from the hash.
|
|
36
|
-
id = hash['id']
|
|
37
|
-
tag = hash['tag']
|
|
52
|
+
id = hash.key?('id') ? hash['id'] : SKIP
|
|
53
|
+
tag = hash.key?('tag') ? hash['tag'] : SKIP
|
|
38
54
|
|
|
39
55
|
# Create object from extracted values.
|
|
40
56
|
Session.new(id,
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
module Bandwidth
|
|
7
7
|
# Subscriptions Model.
|
|
8
8
|
class Subscriptions < BaseModel
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
9
12
|
# Session the subscriptions are associated with
|
|
10
13
|
# If this is the only field, the subscriber will be subscribed to all
|
|
11
14
|
# participants in the session (including any participants that are later
|
|
@@ -25,10 +28,22 @@ module Bandwidth
|
|
|
25
28
|
@_hash
|
|
26
29
|
end
|
|
27
30
|
|
|
31
|
+
# An array for optional fields
|
|
32
|
+
def optionals
|
|
33
|
+
%w[
|
|
34
|
+
participants
|
|
35
|
+
]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# An array for nullable fields
|
|
39
|
+
def nullables
|
|
40
|
+
[]
|
|
41
|
+
end
|
|
42
|
+
|
|
28
43
|
def initialize(session_id = nil,
|
|
29
44
|
participants = nil)
|
|
30
|
-
@session_id = session_id
|
|
31
|
-
@participants = participants
|
|
45
|
+
@session_id = session_id unless session_id == SKIP
|
|
46
|
+
@participants = participants unless participants == SKIP
|
|
32
47
|
end
|
|
33
48
|
|
|
34
49
|
# Creates an instance of the object from a hash.
|
|
@@ -36,7 +51,7 @@ module Bandwidth
|
|
|
36
51
|
return nil unless hash
|
|
37
52
|
|
|
38
53
|
# Extract variables from the hash.
|
|
39
|
-
session_id = hash['sessionId']
|
|
54
|
+
session_id = hash.key?('sessionId') ? hash['sessionId'] : SKIP
|
|
40
55
|
# Parameter is an array, so we need to iterate through it
|
|
41
56
|
participants = nil
|
|
42
57
|
unless hash['participants'].nil?
|
|
@@ -46,6 +61,8 @@ module Bandwidth
|
|
|
46
61
|
end
|
|
47
62
|
end
|
|
48
63
|
|
|
64
|
+
participants = SKIP unless hash.key?('participants')
|
|
65
|
+
|
|
49
66
|
# Create object from extracted values.
|
|
50
67
|
Subscriptions.new(session_id,
|
|
51
68
|
participants)
|
data/lib/bandwidth.rb
CHANGED
|
@@ -9,40 +9,41 @@ require 'faraday'
|
|
|
9
9
|
require 'certifi'
|
|
10
10
|
require 'logging'
|
|
11
11
|
|
|
12
|
-
require_relative 'bandwidth/api_helper
|
|
13
|
-
require_relative 'bandwidth/client
|
|
12
|
+
require_relative 'bandwidth/api_helper'
|
|
13
|
+
require_relative 'bandwidth/client'
|
|
14
14
|
|
|
15
15
|
# Utilities
|
|
16
|
-
require_relative 'bandwidth/utilities/file_wrapper
|
|
17
|
-
require_relative 'bandwidth/utilities/date_time_helper
|
|
16
|
+
require_relative 'bandwidth/utilities/file_wrapper'
|
|
17
|
+
require_relative 'bandwidth/utilities/date_time_helper'
|
|
18
18
|
|
|
19
19
|
# Http
|
|
20
|
-
require_relative 'bandwidth/http/api_response
|
|
21
|
-
require_relative 'bandwidth/http/http_call_back
|
|
22
|
-
require_relative 'bandwidth/http/http_client
|
|
23
|
-
require_relative 'bandwidth/http/faraday_client
|
|
24
|
-
require_relative 'bandwidth/http/http_method_enum
|
|
25
|
-
require_relative 'bandwidth/http/http_request
|
|
26
|
-
require_relative 'bandwidth/http/http_response
|
|
20
|
+
require_relative 'bandwidth/http/api_response'
|
|
21
|
+
require_relative 'bandwidth/http/http_call_back'
|
|
22
|
+
require_relative 'bandwidth/http/http_client'
|
|
23
|
+
require_relative 'bandwidth/http/faraday_client'
|
|
24
|
+
require_relative 'bandwidth/http/http_method_enum'
|
|
25
|
+
require_relative 'bandwidth/http/http_request'
|
|
26
|
+
require_relative 'bandwidth/http/http_response'
|
|
27
27
|
|
|
28
28
|
# Models
|
|
29
|
-
require_relative 'bandwidth/models/base_model
|
|
29
|
+
require_relative 'bandwidth/models/base_model'
|
|
30
30
|
|
|
31
31
|
# Exceptions
|
|
32
|
-
require_relative 'bandwidth/exceptions/api_exception
|
|
32
|
+
require_relative 'bandwidth/exceptions/api_exception'
|
|
33
33
|
|
|
34
|
-
require_relative 'bandwidth/configuration
|
|
34
|
+
require_relative 'bandwidth/configuration'
|
|
35
35
|
|
|
36
36
|
# Namespaces
|
|
37
37
|
require_relative 'bandwidth/messaging_lib/messaging'
|
|
38
|
-
require_relative 'bandwidth/http/auth/messaging_basic_auth
|
|
38
|
+
require_relative 'bandwidth/http/auth/messaging_basic_auth'
|
|
39
39
|
require_relative 'bandwidth/multi_factor_auth_lib/multi_factor_auth'
|
|
40
|
-
require_relative 'bandwidth/http/auth/multi_factor_auth_basic_auth
|
|
40
|
+
require_relative 'bandwidth/http/auth/multi_factor_auth_basic_auth'
|
|
41
41
|
require_relative 'bandwidth/phone_number_lookup_lib/phone_number_lookup'
|
|
42
|
-
require_relative 'bandwidth/http/auth/phone_number_lookup_basic_auth
|
|
42
|
+
require_relative 'bandwidth/http/auth/phone_number_lookup_basic_auth'
|
|
43
43
|
require_relative 'bandwidth/voice_lib/voice'
|
|
44
|
-
require_relative 'bandwidth/http/auth/voice_basic_auth
|
|
44
|
+
require_relative 'bandwidth/http/auth/voice_basic_auth'
|
|
45
45
|
require_relative 'bandwidth/web_rtc_lib/web_rtc'
|
|
46
|
+
require_relative 'bandwidth/http/auth/web_rtc_basic_auth'
|
|
46
47
|
require_relative 'bandwidth/http/auth/web_rtc_basic_auth.rb'
|
|
47
48
|
|
|
48
49
|
# External Files
|
|
@@ -3,25 +3,24 @@
|
|
|
3
3
|
# A simple integration test against Bandwidth's APIs
|
|
4
4
|
|
|
5
5
|
require 'test/unit'
|
|
6
|
+
require 'securerandom'
|
|
6
7
|
require_relative '../../lib/bandwidth.rb'
|
|
7
8
|
|
|
8
9
|
include Bandwidth
|
|
9
10
|
include Bandwidth::Voice
|
|
10
11
|
include Bandwidth::Messaging
|
|
11
12
|
include Bandwidth::MultiFactorAuth
|
|
13
|
+
include Bandwidth::WebRtc
|
|
12
14
|
|
|
13
15
|
begin
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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")
|
|
16
|
+
BW_USERNAME = ENV.fetch("BW_USERNAME")
|
|
17
|
+
BW_PASSWORD = ENV.fetch("BW_PASSWORD")
|
|
18
|
+
BW_ACCOUNT_ID = ENV.fetch("BW_ACCOUNT_ID")
|
|
19
|
+
BW_VOICE_APPLICATION_ID = ENV.fetch("BW_VOICE_APPLICATION_ID")
|
|
20
|
+
BW_MESSAGING_APPLICATION_ID = ENV.fetch("BW_MESSAGING_APPLICATION_ID")
|
|
21
|
+
BASE_CALLBACK_URL = ENV.fetch("BASE_CALLBACK_URL")
|
|
22
|
+
BW_NUMBER = ENV.fetch("BW_NUMBER")
|
|
23
|
+
USER_NUMBER = ENV.fetch("USER_NUMBER")
|
|
25
24
|
rescue
|
|
26
25
|
puts "Environmental variables not found"
|
|
27
26
|
exit(-1)
|
|
@@ -30,35 +29,35 @@ end
|
|
|
30
29
|
class IntegrationTest < Test::Unit::TestCase
|
|
31
30
|
def setup
|
|
32
31
|
@bandwidth_client = Bandwidth::Client.new(
|
|
33
|
-
voice_basic_auth_user_name:
|
|
34
|
-
voice_basic_auth_password:
|
|
35
|
-
messaging_basic_auth_user_name:
|
|
36
|
-
messaging_basic_auth_password:
|
|
37
|
-
multi_factor_auth_basic_auth_user_name:
|
|
38
|
-
multi_factor_auth_basic_auth_password:
|
|
39
|
-
phone_number_lookup_basic_auth_user_name:
|
|
40
|
-
phone_number_lookup_basic_auth_password:
|
|
32
|
+
voice_basic_auth_user_name: BW_USERNAME,
|
|
33
|
+
voice_basic_auth_password: BW_PASSWORD,
|
|
34
|
+
messaging_basic_auth_user_name: BW_USERNAME,
|
|
35
|
+
messaging_basic_auth_password: BW_PASSWORD,
|
|
36
|
+
multi_factor_auth_basic_auth_user_name: BW_USERNAME,
|
|
37
|
+
multi_factor_auth_basic_auth_password: BW_PASSWORD,
|
|
38
|
+
phone_number_lookup_basic_auth_user_name: BW_USERNAME,
|
|
39
|
+
phone_number_lookup_basic_auth_password: BW_PASSWORD
|
|
41
40
|
)
|
|
42
41
|
end
|
|
43
42
|
|
|
44
43
|
def test_create_message
|
|
45
44
|
body = MessageRequest.new
|
|
46
|
-
body.application_id =
|
|
47
|
-
body.to = [
|
|
48
|
-
body.from =
|
|
45
|
+
body.application_id = BW_MESSAGING_APPLICATION_ID
|
|
46
|
+
body.to = [USER_NUMBER]
|
|
47
|
+
body.from = BW_NUMBER
|
|
49
48
|
body.text = "Ruby Integration"
|
|
50
|
-
response = @bandwidth_client.messaging_client.client.create_message(
|
|
49
|
+
response = @bandwidth_client.messaging_client.client.create_message(BW_ACCOUNT_ID, body)
|
|
51
50
|
assert(response.data.id.length > 0, "id value not set") #validate that _some_ id was returned
|
|
52
51
|
end
|
|
53
52
|
|
|
54
53
|
def test_create_message_invalid_phone_number
|
|
55
54
|
body = MessageRequest.new
|
|
56
|
-
body.application_id =
|
|
55
|
+
body.application_id = BW_MESSAGING_APPLICATION_ID
|
|
57
56
|
body.to = ["+1invalid"]
|
|
58
|
-
body.from =
|
|
57
|
+
body.from = BW_NUMBER
|
|
59
58
|
body.text = "Ruby Integration"
|
|
60
59
|
begin
|
|
61
|
-
@bandwidth_client.messaging_client.client.create_message(
|
|
60
|
+
@bandwidth_client.messaging_client.client.create_message(BW_ACCOUNT_ID, body)
|
|
62
61
|
#workaround to make sure that if the above error is not raised, the build will fail
|
|
63
62
|
assert(false, "Expected exception not raised")
|
|
64
63
|
rescue MessagingException => e
|
|
@@ -68,41 +67,66 @@ class IntegrationTest < Test::Unit::TestCase
|
|
|
68
67
|
|
|
69
68
|
def test_upload_download_media
|
|
70
69
|
#define constants for upload media and download media
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
media_id = "text-media-id-" + SecureRandom.uuid
|
|
71
|
+
media = "Hello world"
|
|
73
72
|
|
|
74
73
|
#media upload
|
|
75
|
-
@bandwidth_client.messaging_client.client.upload_media(
|
|
74
|
+
@bandwidth_client.messaging_client.client.upload_media(BW_ACCOUNT_ID, media_id, media, :content_type => "application/octet-stream", :cache_control => "no-cache")
|
|
76
75
|
|
|
77
76
|
#media download
|
|
78
|
-
|
|
77
|
+
downloaded_media = @bandwidth_client.messaging_client.client.get_media(BW_ACCOUNT_ID, media_id).data
|
|
79
78
|
|
|
80
|
-
assert_equal(
|
|
79
|
+
assert_equal(downloaded_media, media, "Downloaded media file not equal to upload")
|
|
81
80
|
end
|
|
82
81
|
|
|
83
82
|
def test_create_call_and_get_call_state
|
|
84
83
|
body = CreateCallRequest.new
|
|
85
|
-
body.from =
|
|
86
|
-
body.to =
|
|
87
|
-
body.application_id =
|
|
88
|
-
body.answer_url =
|
|
89
|
-
response = @bandwidth_client.voice_client.client.create_call(
|
|
84
|
+
body.from = BW_NUMBER
|
|
85
|
+
body.to = USER_NUMBER
|
|
86
|
+
body.application_id = BW_VOICE_APPLICATION_ID
|
|
87
|
+
body.answer_url = BASE_CALLBACK_URL
|
|
88
|
+
response = @bandwidth_client.voice_client.client.create_call(BW_ACCOUNT_ID, body)
|
|
90
89
|
assert(response.data.call_id.length > 0, "call_id value not set")
|
|
91
90
|
|
|
92
91
|
#Get phone call information
|
|
93
|
-
response = @bandwidth_client.voice_client.client.get_call(
|
|
92
|
+
response = @bandwidth_client.voice_client.client.get_call(BW_ACCOUNT_ID, response.data.call_id)
|
|
93
|
+
assert(response.data.state.length > 0, "state value not set")
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def test_create_call_with_amd_and_get_call_state
|
|
97
|
+
machine_detection = MachineDetectionConfiguration.new
|
|
98
|
+
machine_detection.mode = 'async'
|
|
99
|
+
machine_detection.detection_timeout = 5.0
|
|
100
|
+
machine_detection.silence_timeout = 5.0
|
|
101
|
+
machine_detection.speech_threshold = 5.0
|
|
102
|
+
machine_detection.speech_end_threshold = 5.0
|
|
103
|
+
machine_detection.delay_result = true
|
|
104
|
+
machine_detection.callback_url = BASE_CALLBACK_URL + '/machineDetection'
|
|
105
|
+
machine_detection.callback_method = 'POST'
|
|
106
|
+
|
|
107
|
+
body = CreateCallRequest.new
|
|
108
|
+
body.from = BW_NUMBER
|
|
109
|
+
body.to = USER_NUMBER
|
|
110
|
+
body.application_id = BW_VOICE_APPLICATION_ID
|
|
111
|
+
body.answer_url = BASE_CALLBACK_URL
|
|
112
|
+
body.machine_detection = machine_detection
|
|
113
|
+
response = @bandwidth_client.voice_client.client.create_call(BW_ACCOUNT_ID, body)
|
|
114
|
+
assert(response.data.call_id.length > 0, "call_id value not set")
|
|
115
|
+
|
|
116
|
+
#Get phone call information
|
|
117
|
+
response = @bandwidth_client.voice_client.client.get_call(BW_ACCOUNT_ID, response.data.call_id)
|
|
94
118
|
assert(response.data.state.length > 0, "state value not set")
|
|
95
119
|
end
|
|
96
120
|
|
|
97
121
|
def test_create_call_invalid_phone_number
|
|
98
122
|
body = CreateCallRequest.new
|
|
99
|
-
body.from =
|
|
123
|
+
body.from = BW_NUMBER
|
|
100
124
|
body.to = "+1invalid"
|
|
101
|
-
body.application_id =
|
|
102
|
-
body.answer_url =
|
|
125
|
+
body.application_id = BW_VOICE_APPLICATION_ID
|
|
126
|
+
body.answer_url = BASE_CALLBACK_URL
|
|
103
127
|
|
|
104
128
|
begin
|
|
105
|
-
@bandwidth_client.voice_client.client.create_call(
|
|
129
|
+
@bandwidth_client.voice_client.client.create_call(BW_ACCOUNT_ID, :body => body)
|
|
106
130
|
#workaround to make sure that if the above error is not raised, the build will fail
|
|
107
131
|
assert(false, "Expected exception not raised")
|
|
108
132
|
rescue ApiErrorException => e
|
|
@@ -466,38 +490,38 @@ class IntegrationTest < Test::Unit::TestCase
|
|
|
466
490
|
|
|
467
491
|
def test_mfa_messaging
|
|
468
492
|
body = TwoFactorCodeRequestSchema.new
|
|
469
|
-
body.from =
|
|
470
|
-
body.to =
|
|
471
|
-
body.application_id =
|
|
493
|
+
body.from = BW_NUMBER
|
|
494
|
+
body.to = USER_NUMBER
|
|
495
|
+
body.application_id = BW_MESSAGING_APPLICATION_ID
|
|
472
496
|
body.scope = "scope"
|
|
473
497
|
body.digits = 6
|
|
474
498
|
body.message = "Your temporary {NAME} {SCOPE} code is {CODE}"
|
|
475
499
|
|
|
476
|
-
response = @bandwidth_client.multi_factor_auth_client.mfa.create_messaging_two_factor(
|
|
500
|
+
response = @bandwidth_client.multi_factor_auth_client.mfa.create_messaging_two_factor(BW_ACCOUNT_ID, body)
|
|
477
501
|
assert(response.data.message_id.length > 0, "message id value not set")
|
|
478
502
|
end
|
|
479
503
|
|
|
480
504
|
def test_mfa_voice
|
|
481
505
|
body = TwoFactorCodeRequestSchema.new
|
|
482
|
-
body.from =
|
|
483
|
-
body.to =
|
|
484
|
-
body.application_id =
|
|
506
|
+
body.from = BW_NUMBER
|
|
507
|
+
body.to = USER_NUMBER
|
|
508
|
+
body.application_id = BW_VOICE_APPLICATION_ID
|
|
485
509
|
body.scope = "scope"
|
|
486
510
|
body.digits = 6
|
|
487
511
|
body.message = "Your temporary {NAME} {SCOPE} code is {CODE}"
|
|
488
512
|
|
|
489
|
-
response = @bandwidth_client.multi_factor_auth_client.mfa.create_voice_two_factor(
|
|
513
|
+
response = @bandwidth_client.multi_factor_auth_client.mfa.create_voice_two_factor(BW_ACCOUNT_ID, body)
|
|
490
514
|
assert(response.data.call_id.length > 0, "call id value not set")
|
|
491
515
|
end
|
|
492
516
|
|
|
493
517
|
def test_mfa_verify
|
|
494
518
|
body = TwoFactorVerifyRequestSchema.new
|
|
495
|
-
body.to =
|
|
496
|
-
body.application_id =
|
|
519
|
+
body.to = "+1000" + rand(1111111..9999999).to_s
|
|
520
|
+
body.application_id = BW_VOICE_APPLICATION_ID
|
|
497
521
|
body.scope = "scope"
|
|
498
522
|
body.code = "123456"
|
|
499
523
|
body.expiration_time_in_minutes = 3
|
|
500
|
-
response = @bandwidth_client.multi_factor_auth_client.mfa.create_verify_two_factor(
|
|
524
|
+
response = @bandwidth_client.multi_factor_auth_client.mfa.create_verify_two_factor(BW_ACCOUNT_ID, body)
|
|
501
525
|
#Ruby has no check to see if variables are of type boolean
|
|
502
526
|
#An explicit true/false check is required
|
|
503
527
|
assert(response.data.valid == true || response.data.valid == false, "'valid' variable is not a boolean")
|
|
@@ -531,13 +555,14 @@ class IntegrationTest < Test::Unit::TestCase
|
|
|
531
555
|
|
|
532
556
|
def test_ring
|
|
533
557
|
ring = Bandwidth::Voice::Ring.new({
|
|
534
|
-
:duration => 5
|
|
558
|
+
:duration => 5,
|
|
559
|
+
:answer_call => false
|
|
535
560
|
})
|
|
536
561
|
|
|
537
562
|
response = Bandwidth::Voice::Response.new()
|
|
538
563
|
response.push(ring)
|
|
539
564
|
|
|
540
|
-
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Ring duration="5"/></Response>'
|
|
565
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Ring duration="5" answerCall="false"/></Response>'
|
|
541
566
|
actual = response.to_bxml()
|
|
542
567
|
assert_equal(expected, actual)
|
|
543
568
|
end
|
|
@@ -558,7 +583,7 @@ class IntegrationTest < Test::Unit::TestCase
|
|
|
558
583
|
actual = response.to_bxml()
|
|
559
584
|
assert_equal(expected, actual)
|
|
560
585
|
end
|
|
561
|
-
|
|
586
|
+
|
|
562
587
|
def test_stop_gather
|
|
563
588
|
stop_gather = Bandwidth::Voice::StopGather.new()
|
|
564
589
|
|
|
@@ -572,12 +597,24 @@ class IntegrationTest < Test::Unit::TestCase
|
|
|
572
597
|
|
|
573
598
|
def test_tn_lookup
|
|
574
599
|
body = OrderRequest.new
|
|
575
|
-
body.tns = [
|
|
576
|
-
create_response = @bandwidth_client.phone_number_lookup_client.client.create_lookup_request(
|
|
600
|
+
body.tns = [BW_NUMBER]
|
|
601
|
+
create_response = @bandwidth_client.phone_number_lookup_client.client.create_lookup_request(BW_ACCOUNT_ID, body)
|
|
577
602
|
assert(create_response.data.request_id.length > 0, "request_id value not set")
|
|
578
603
|
|
|
579
604
|
request_id = create_response.data.request_id
|
|
580
|
-
get_response = @bandwidth_client.phone_number_lookup_client.client.get_lookup_request_status(
|
|
605
|
+
get_response = @bandwidth_client.phone_number_lookup_client.client.get_lookup_request_status(BW_ACCOUNT_ID, request_id)
|
|
581
606
|
assert(get_response.data.status.length > 0, "status value not set")
|
|
582
607
|
end
|
|
608
|
+
|
|
609
|
+
def test_webrtc_generate_bxml
|
|
610
|
+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Transfer><SipUri uui="93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt">sip:sipx.webrtc.bandwidth.com:5060</SipUri></Transfer></Response>'
|
|
611
|
+
actual = Bandwidth::WebRtc.generate_bxml('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4')
|
|
612
|
+
assert_equal(expected, actual)
|
|
613
|
+
end
|
|
614
|
+
|
|
615
|
+
def test_webrtc_generate_transfer_bxml_verb
|
|
616
|
+
expected = '<Transfer><SipUri uui="93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt">sip:sipx.webrtc.bandwidth.com:5060</SipUri></Transfer>'
|
|
617
|
+
actual = Bandwidth::WebRtc.generate_transfer_bxml_verb('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4')
|
|
618
|
+
assert_equal(expected, actual)
|
|
619
|
+
end
|
|
583
620
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bandwidth-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 9.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- APIMatic SDK Generator
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-11-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: logging
|
|
@@ -235,9 +235,11 @@ files:
|
|
|
235
235
|
- lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb
|
|
236
236
|
- lib/bandwidth/voice_lib/voice/models/answer_fallback_method_enum.rb
|
|
237
237
|
- lib/bandwidth/voice_lib/voice/models/answer_method_enum.rb
|
|
238
|
+
- lib/bandwidth/voice_lib/voice/models/call_callback.rb
|
|
238
239
|
- lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb
|
|
239
240
|
- lib/bandwidth/voice_lib/voice/models/call_state.rb
|
|
240
241
|
- lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb
|
|
242
|
+
- lib/bandwidth/voice_lib/voice/models/conference_callback.rb
|
|
241
243
|
- lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb
|
|
242
244
|
- lib/bandwidth/voice_lib/voice/models/conference_member_state.rb
|
|
243
245
|
- lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb
|
|
@@ -246,7 +248,11 @@ files:
|
|
|
246
248
|
- lib/bandwidth/voice_lib/voice/models/create_call_response.rb
|
|
247
249
|
- lib/bandwidth/voice_lib/voice/models/direction_enum.rb
|
|
248
250
|
- lib/bandwidth/voice_lib/voice/models/disconnect_method_enum.rb
|
|
251
|
+
- lib/bandwidth/voice_lib/voice/models/diversion.rb
|
|
252
|
+
- lib/bandwidth/voice_lib/voice/models/fallback_method_enum.rb
|
|
249
253
|
- lib/bandwidth/voice_lib/voice/models/file_format_enum.rb
|
|
254
|
+
- lib/bandwidth/voice_lib/voice/models/machine_detection_configuration.rb
|
|
255
|
+
- lib/bandwidth/voice_lib/voice/models/mode_enum.rb
|
|
250
256
|
- lib/bandwidth/voice_lib/voice/models/modify_call_recording_request.rb
|
|
251
257
|
- lib/bandwidth/voice_lib/voice/models/modify_call_request.rb
|
|
252
258
|
- lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb
|
|
@@ -257,6 +263,7 @@ files:
|
|
|
257
263
|
- lib/bandwidth/voice_lib/voice/models/status_enum.rb
|
|
258
264
|
- lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb
|
|
259
265
|
- lib/bandwidth/voice_lib/voice/models/transcript.rb
|
|
266
|
+
- lib/bandwidth/voice_lib/voice/models/transcription.rb
|
|
260
267
|
- lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb
|
|
261
268
|
- lib/bandwidth/voice_lib/voice/models/transcription_response.rb
|
|
262
269
|
- lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb
|
|
@@ -298,5 +305,5 @@ requirements: []
|
|
|
298
305
|
rubygems_version: 3.2.22
|
|
299
306
|
signing_key:
|
|
300
307
|
specification_version: 4
|
|
301
|
-
summary:
|
|
308
|
+
summary: Bandwidth
|
|
302
309
|
test_files: []
|