bandwidth-sdk 6.2.0 → 9.0.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.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bandwidth/api_helper.rb +19 -29
  3. data/lib/bandwidth/client.rb +8 -8
  4. data/lib/bandwidth/configuration.rb +20 -32
  5. data/lib/bandwidth/http/auth/{two_factor_auth_basic_auth.rb → multi_factor_auth_basic_auth.rb} +3 -3
  6. data/lib/bandwidth/http/faraday_client.rb +1 -1
  7. data/lib/bandwidth/messaging_lib/messaging/client.rb +14 -5
  8. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +78 -71
  9. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +3 -5
  10. data/lib/bandwidth/messaging_lib/messaging/exceptions/messaging_exception.rb +5 -2
  11. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb +31 -11
  12. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +54 -25
  13. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +102 -24
  14. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +23 -4
  15. data/lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb +20 -4
  16. data/lib/bandwidth/messaging_lib/messaging/models/media.rb +27 -80
  17. data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +32 -14
  18. data/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +28 -8
  19. data/lib/bandwidth/messaging_lib/messaging/models/tag.rb +20 -4
  20. data/lib/bandwidth/models/base_model.rb +30 -8
  21. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/client.rb +15 -6
  22. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/controllers/base_controller.rb +3 -5
  23. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/controllers/mfa_controller.rb +28 -23
  24. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/exceptions/error_with_request_exception.rb +5 -2
  25. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/exceptions/forbidden_request_exception.rb +4 -1
  26. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/exceptions/unauthorized_request_exception.rb +4 -1
  27. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_code_request_schema.rb +27 -12
  28. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_messaging_response.rb +17 -2
  29. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_verify_code_response.rb +17 -2
  30. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_verify_request_schema.rb +29 -10
  31. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_voice_response.rb +17 -2
  32. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth.rb +23 -0
  33. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +212 -210
  34. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +3 -5
  35. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb +4 -1
  36. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +17 -2
  37. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +20 -4
  38. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +28 -7
  39. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +43 -18
  40. data/lib/bandwidth/utilities/date_time_helper.rb +156 -0
  41. data/lib/bandwidth/utilities/file_wrapper.rb +1 -2
  42. data/lib/bandwidth/voice_lib/voice/client.rb +14 -5
  43. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +418 -379
  44. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +3 -5
  45. data/lib/bandwidth/voice_lib/voice/exceptions/{api_error_response_exception.rb → api_error_exception.rb} +8 -5
  46. data/lib/bandwidth/voice_lib/voice/models/call_callback.rb +343 -0
  47. data/lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb +250 -0
  48. data/lib/bandwidth/voice_lib/voice/models/call_state.rb +284 -0
  49. data/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb +2 -20
  50. data/lib/bandwidth/voice_lib/voice/models/conference_callback.rb +211 -0
  51. data/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb +2 -20
  52. data/lib/bandwidth/voice_lib/voice/models/{conference_member_detail.rb → conference_member_state.rb} +43 -20
  53. data/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb +173 -0
  54. data/lib/bandwidth/voice_lib/voice/models/conference_state.rb +153 -0
  55. data/lib/bandwidth/voice_lib/voice/models/create_call_request.rb +301 -0
  56. data/lib/bandwidth/voice_lib/voice/models/create_call_response.rb +256 -0
  57. data/lib/bandwidth/voice_lib/voice/models/diversion.rb +80 -0
  58. data/lib/bandwidth/voice_lib/voice/models/fallback_method_enum.rb +17 -0
  59. data/lib/bandwidth/voice_lib/voice/models/machine_detection_configuration.rb +218 -0
  60. data/lib/bandwidth/voice_lib/voice/models/mode_enum.rb +20 -0
  61. data/lib/bandwidth/voice_lib/voice/models/{modify_call_recording_state.rb → modify_call_recording_request.rb} +19 -6
  62. data/lib/bandwidth/voice_lib/voice/models/modify_call_request.rb +156 -0
  63. data/lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb +144 -0
  64. data/lib/bandwidth/voice_lib/voice/models/state1_enum.rb +7 -4
  65. data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +4 -7
  66. data/lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb +108 -0
  67. data/lib/bandwidth/voice_lib/voice/models/transcript.rb +20 -4
  68. data/lib/bandwidth/voice_lib/voice/models/transcription.rb +35 -17
  69. data/lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb +89 -0
  70. data/lib/bandwidth/voice_lib/voice/models/transcription_response.rb +18 -1
  71. data/lib/bandwidth/voice_lib/voice.rb +20 -18
  72. data/lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb +7 -2
  73. data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +4 -4
  74. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +75 -64
  75. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +3 -5
  76. data/lib/bandwidth/web_rtc_lib/web_rtc/exceptions/error_exception.rb +5 -2
  77. data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +20 -5
  78. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +37 -14
  79. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +15 -2
  80. data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +20 -4
  81. data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +20 -3
  82. data/lib/bandwidth.rb +20 -18
  83. data/test/integration/test_integration.rb +92 -57
  84. metadata +35 -31
  85. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +0 -22
  86. data/lib/bandwidth/voice_lib/voice/models/api_call_response.rb +0 -207
  87. data/lib/bandwidth/voice_lib/voice/models/api_call_state_response.rb +0 -164
  88. data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +0 -248
  89. data/lib/bandwidth/voice_lib/voice/models/api_modify_call_request.rb +0 -116
  90. data/lib/bandwidth/voice_lib/voice/models/api_modify_conference_request.rb +0 -107
  91. data/lib/bandwidth/voice_lib/voice/models/api_transcribe_recording_request.rb +0 -80
  92. data/lib/bandwidth/voice_lib/voice/models/conference_detail.rb +0 -108
  93. data/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata_response.rb +0 -126
  94. data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +0 -47
  95. data/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +0 -190
  96. data/lib/bandwidth/voice_lib/voice/models/state2_enum.rb +0 -20
  97. data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +0 -29
  98. data/lib/bandwidth/voice_lib/voice/models/status3_enum.rb +0 -32
@@ -6,6 +6,9 @@
6
6
  module Bandwidth
7
7
  # A participant object
8
8
  class Participant < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
9
12
  # Unique id of the participant
10
13
  # @return [String]
11
14
  attr_accessor :id
@@ -49,6 +52,26 @@ module Bandwidth
49
52
  @_hash
50
53
  end
51
54
 
55
+ # An array for optional fields
56
+ def optionals
57
+ %w[
58
+ id
59
+ callback_url
60
+ publish_permissions
61
+ sessions
62
+ subscriptions
63
+ tag
64
+ device_api_version
65
+ ]
66
+ end
67
+
68
+ # An array for nullable fields
69
+ def nullables
70
+ %w[
71
+ callback_url
72
+ ]
73
+ end
74
+
52
75
  def initialize(id = nil,
53
76
  callback_url = nil,
54
77
  publish_permissions = nil,
@@ -56,13 +79,13 @@ module Bandwidth
56
79
  subscriptions = nil,
57
80
  tag = nil,
58
81
  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
82
+ @id = id unless id == SKIP
83
+ @callback_url = callback_url unless callback_url == SKIP
84
+ @publish_permissions = publish_permissions unless publish_permissions == SKIP
85
+ @sessions = sessions unless sessions == SKIP
86
+ @subscriptions = subscriptions unless subscriptions == SKIP
87
+ @tag = tag unless tag == SKIP
88
+ @device_api_version = device_api_version unless device_api_version == SKIP
66
89
  end
67
90
 
68
91
  # Creates an instance of the object from a hash.
@@ -70,13 +93,13 @@ module Bandwidth
70
93
  return nil unless hash
71
94
 
72
95
  # 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']
96
+ id = hash.key?('id') ? hash['id'] : SKIP
97
+ callback_url = hash.key?('callbackUrl') ? hash['callbackUrl'] : SKIP
98
+ publish_permissions =
99
+ hash.key?('publishPermissions') ? hash['publishPermissions'] : SKIP
100
+ sessions = hash.key?('sessions') ? hash['sessions'] : SKIP
101
+ subscriptions = Subscriptions.from_hash(hash['subscriptions']) if hash['subscriptions']
102
+ tag = hash.key?('tag') ? hash['tag'] : SKIP
80
103
  device_api_version = hash['deviceApiVersion'] ||= DeviceApiVersionEnum::V2
81
104
 
82
105
  # Create object from extracted values.
@@ -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,39 +9,41 @@ require 'faraday'
9
9
  require 'certifi'
10
10
  require 'logging'
11
11
 
12
- require_relative 'bandwidth/api_helper.rb'
13
- require_relative 'bandwidth/client.rb'
12
+ require_relative 'bandwidth/api_helper'
13
+ require_relative 'bandwidth/client'
14
14
 
15
15
  # Utilities
16
- require_relative 'bandwidth/utilities/file_wrapper.rb'
16
+ require_relative 'bandwidth/utilities/file_wrapper'
17
+ require_relative 'bandwidth/utilities/date_time_helper'
17
18
 
18
19
  # Http
19
- require_relative 'bandwidth/http/api_response.rb'
20
- require_relative 'bandwidth/http/http_call_back.rb'
21
- require_relative 'bandwidth/http/http_client.rb'
22
- require_relative 'bandwidth/http/faraday_client.rb'
23
- require_relative 'bandwidth/http/http_method_enum.rb'
24
- require_relative 'bandwidth/http/http_request.rb'
25
- require_relative 'bandwidth/http/http_response.rb'
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'
26
27
 
27
28
  # Models
28
- require_relative 'bandwidth/models/base_model.rb'
29
+ require_relative 'bandwidth/models/base_model'
29
30
 
30
31
  # Exceptions
31
- require_relative 'bandwidth/exceptions/api_exception.rb'
32
+ require_relative 'bandwidth/exceptions/api_exception'
32
33
 
33
- require_relative 'bandwidth/configuration.rb'
34
+ require_relative 'bandwidth/configuration'
34
35
 
35
36
  # Namespaces
36
37
  require_relative 'bandwidth/messaging_lib/messaging'
37
- require_relative 'bandwidth/http/auth/messaging_basic_auth.rb'
38
- require_relative 'bandwidth/two_factor_auth_lib/two_factor_auth'
39
- require_relative 'bandwidth/http/auth/two_factor_auth_basic_auth.rb'
38
+ require_relative 'bandwidth/http/auth/messaging_basic_auth'
39
+ require_relative 'bandwidth/multi_factor_auth_lib/multi_factor_auth'
40
+ require_relative 'bandwidth/http/auth/multi_factor_auth_basic_auth'
40
41
  require_relative 'bandwidth/phone_number_lookup_lib/phone_number_lookup'
41
- require_relative 'bandwidth/http/auth/phone_number_lookup_basic_auth.rb'
42
+ require_relative 'bandwidth/http/auth/phone_number_lookup_basic_auth'
42
43
  require_relative 'bandwidth/voice_lib/voice'
43
- require_relative 'bandwidth/http/auth/voice_basic_auth.rb'
44
+ require_relative 'bandwidth/http/auth/voice_basic_auth'
44
45
  require_relative 'bandwidth/web_rtc_lib/web_rtc'
46
+ require_relative 'bandwidth/http/auth/web_rtc_basic_auth'
45
47
  require_relative 'bandwidth/http/auth/web_rtc_basic_auth.rb'
46
48
 
47
49
  # External Files
@@ -8,20 +8,18 @@ require_relative '../../lib/bandwidth.rb'
8
8
  include Bandwidth
9
9
  include Bandwidth::Voice
10
10
  include Bandwidth::Messaging
11
- include Bandwidth::TwoFactorAuth
11
+ include Bandwidth::MultiFactorAuth
12
+ include Bandwidth::WebRtc
12
13
 
13
14
  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")
15
+ BW_USERNAME = ENV.fetch("BW_USERNAME")
16
+ BW_PASSWORD = ENV.fetch("BW_PASSWORD")
17
+ BW_ACCOUNT_ID = ENV.fetch("BW_ACCOUNT_ID")
18
+ BW_VOICE_APPLICATION_ID = ENV.fetch("BW_VOICE_APPLICATION_ID")
19
+ BW_MESSAGING_APPLICATION_ID = ENV.fetch("BW_MESSAGING_APPLICATION_ID")
20
+ BASE_CALLBACK_URL = ENV.fetch("BASE_CALLBACK_URL")
21
+ BW_NUMBER = ENV.fetch("BW_NUMBER")
22
+ USER_NUMBER = ENV.fetch("USER_NUMBER")
25
23
  rescue
26
24
  puts "Environmental variables not found"
27
25
  exit(-1)
@@ -30,35 +28,35 @@ end
30
28
  class IntegrationTest < Test::Unit::TestCase
31
29
  def setup
32
30
  @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
31
+ voice_basic_auth_user_name: BW_USERNAME,
32
+ voice_basic_auth_password: BW_PASSWORD,
33
+ messaging_basic_auth_user_name: BW_USERNAME,
34
+ messaging_basic_auth_password: BW_PASSWORD,
35
+ multi_factor_auth_basic_auth_user_name: BW_USERNAME,
36
+ multi_factor_auth_basic_auth_password: BW_PASSWORD,
37
+ phone_number_lookup_basic_auth_user_name: BW_USERNAME,
38
+ phone_number_lookup_basic_auth_password: BW_PASSWORD
41
39
  )
42
40
  end
43
41
 
44
42
  def test_create_message
45
43
  body = MessageRequest.new
46
- body.application_id = MESSAGING_APPLICATION_ID
47
- body.to = [PHONE_NUMBER_INBOUND]
48
- body.from = PHONE_NUMBER_OUTBOUND
44
+ body.application_id = BW_MESSAGING_APPLICATION_ID
45
+ body.to = [USER_NUMBER]
46
+ body.from = BW_NUMBER
49
47
  body.text = "Ruby Integration"
50
- response = @bandwidth_client.messaging_client.client.create_message(ACCOUNT_ID, body)
48
+ response = @bandwidth_client.messaging_client.client.create_message(BW_ACCOUNT_ID, body)
51
49
  assert(response.data.id.length > 0, "id value not set") #validate that _some_ id was returned
52
50
  end
53
51
 
54
52
  def test_create_message_invalid_phone_number
55
53
  body = MessageRequest.new
56
- body.application_id = MESSAGING_APPLICATION_ID
54
+ body.application_id = BW_MESSAGING_APPLICATION_ID
57
55
  body.to = ["+1invalid"]
58
- body.from = PHONE_NUMBER_OUTBOUND
56
+ body.from = BW_NUMBER
59
57
  body.text = "Ruby Integration"
60
58
  begin
61
- @bandwidth_client.messaging_client.client.create_message(ACCOUNT_ID, :body => body)
59
+ @bandwidth_client.messaging_client.client.create_message(BW_ACCOUNT_ID, body)
62
60
  #workaround to make sure that if the above error is not raised, the build will fail
63
61
  assert(false, "Expected exception not raised")
64
62
  rescue MessagingException => e
@@ -72,40 +70,65 @@ class IntegrationTest < Test::Unit::TestCase
72
70
  media_file = '12345' #todo: check a binary string
73
71
 
74
72
  #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")
73
+ @bandwidth_client.messaging_client.client.upload_media(BW_ACCOUNT_ID, media_file_name, media_file, :content_type => "application/octet-stream", :cache_control => "no-cache")
76
74
 
77
75
  #media download
78
- downloaded_media_file = @bandwidth_client.messaging_client.client.get_media(ACCOUNT_ID, media_file_name).data
76
+ downloaded_media_file = @bandwidth_client.messaging_client.client.get_media(BW_ACCOUNT_ID, media_file_name).data
79
77
 
80
78
  assert_equal(downloaded_media_file, media_file, "Downloaded media file not equal to upload")
81
79
  end
82
80
 
83
81
  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)
82
+ body = CreateCallRequest.new
83
+ body.from = BW_NUMBER
84
+ body.to = USER_NUMBER
85
+ body.application_id = BW_VOICE_APPLICATION_ID
86
+ body.answer_url = BASE_CALLBACK_URL
87
+ response = @bandwidth_client.voice_client.client.create_call(BW_ACCOUNT_ID, body)
90
88
  assert(response.data.call_id.length > 0, "call_id value not set")
91
89
 
92
90
  #Get phone call information
93
- response = @bandwidth_client.voice_client.client.get_call_state(ACCOUNT_ID, response.data.call_id)
91
+ response = @bandwidth_client.voice_client.client.get_call(BW_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_with_amd_and_get_call_state
96
+ machine_detection = MachineDetectionConfiguration.new
97
+ machine_detection.mode = 'async'
98
+ machine_detection.detection_timeout = 5.0
99
+ machine_detection.silence_timeout = 5.0
100
+ machine_detection.speech_threshold = 5.0
101
+ machine_detection.speech_end_threshold = 5.0
102
+ machine_detection.delay_result = true
103
+ machine_detection.callback_url = BASE_CALLBACK_URL + '/machineDetection'
104
+ machine_detection.callback_method = 'POST'
105
+
106
+ body = CreateCallRequest.new
107
+ body.from = BW_NUMBER
108
+ body.to = USER_NUMBER
109
+ body.application_id = BW_VOICE_APPLICATION_ID
110
+ body.answer_url = BASE_CALLBACK_URL
111
+ body.machine_detection = machine_detection
112
+ response = @bandwidth_client.voice_client.client.create_call(BW_ACCOUNT_ID, body)
113
+ assert(response.data.call_id.length > 0, "call_id value not set")
114
+
115
+ #Get phone call information
116
+ response = @bandwidth_client.voice_client.client.get_call(BW_ACCOUNT_ID, response.data.call_id)
94
117
  assert(response.data.state.length > 0, "state value not set")
95
118
  end
96
119
 
97
120
  def test_create_call_invalid_phone_number
98
- body = ApiCreateCallRequest.new
99
- body.from = PHONE_NUMBER_OUTBOUND
121
+ body = CreateCallRequest.new
122
+ body.from = BW_NUMBER
100
123
  body.to = "+1invalid"
101
- body.application_id = VOICE_APPLICATION_ID
102
- body.answer_url = CALLBACK_URL
124
+ body.application_id = BW_VOICE_APPLICATION_ID
125
+ body.answer_url = BASE_CALLBACK_URL
103
126
 
104
127
  begin
105
- @bandwidth_client.voice_client.client.create_call(ACCOUNT_ID, :body => body)
128
+ @bandwidth_client.voice_client.client.create_call(BW_ACCOUNT_ID, :body => body)
106
129
  #workaround to make sure that if the above error is not raised, the build will fail
107
130
  assert(false, "Expected exception not raised")
108
- rescue ApiErrorResponseException => e
131
+ rescue ApiErrorException => e
109
132
  assert(e.description.length > 0, "description value not set")
110
133
  end
111
134
  end
@@ -466,38 +489,38 @@ class IntegrationTest < Test::Unit::TestCase
466
489
 
467
490
  def test_mfa_messaging
468
491
  body = TwoFactorCodeRequestSchema.new
469
- body.from = PHONE_NUMBER_MFA
470
- body.to = PHONE_NUMBER_INBOUND
471
- body.application_id = MFA_MESSAGING_APPLICATION_ID
492
+ body.from = BW_NUMBER
493
+ body.to = USER_NUMBER
494
+ body.application_id = BW_MESSAGING_APPLICATION_ID
472
495
  body.scope = "scope"
473
496
  body.digits = 6
474
497
  body.message = "Your temporary {NAME} {SCOPE} code is {CODE}"
475
498
 
476
- response = @bandwidth_client.two_factor_auth_client.mfa.create_messaging_two_factor(ACCOUNT_ID, body)
499
+ response = @bandwidth_client.multi_factor_auth_client.mfa.create_messaging_two_factor(BW_ACCOUNT_ID, body)
477
500
  assert(response.data.message_id.length > 0, "message id value not set")
478
501
  end
479
502
 
480
503
  def test_mfa_voice
481
504
  body = TwoFactorCodeRequestSchema.new
482
- body.from = PHONE_NUMBER_MFA
483
- body.to = PHONE_NUMBER_INBOUND
484
- body.application_id = MFA_VOICE_APPLICATION_ID
505
+ body.from = BW_NUMBER
506
+ body.to = USER_NUMBER
507
+ body.application_id = BW_VOICE_APPLICATION_ID
485
508
  body.scope = "scope"
486
509
  body.digits = 6
487
510
  body.message = "Your temporary {NAME} {SCOPE} code is {CODE}"
488
511
 
489
- response = @bandwidth_client.two_factor_auth_client.mfa.create_voice_two_factor(ACCOUNT_ID, body)
512
+ response = @bandwidth_client.multi_factor_auth_client.mfa.create_voice_two_factor(BW_ACCOUNT_ID, body)
490
513
  assert(response.data.call_id.length > 0, "call id value not set")
491
514
  end
492
515
 
493
516
  def test_mfa_verify
494
517
  body = TwoFactorVerifyRequestSchema.new
495
- body.to = PHONE_NUMBER_INBOUND
496
- body.application_id = MFA_VOICE_APPLICATION_ID
518
+ body.to = USER_NUMBER
519
+ body.application_id = BW_VOICE_APPLICATION_ID
497
520
  body.scope = "scope"
498
521
  body.code = "123456"
499
522
  body.expiration_time_in_minutes = 3
500
- response = @bandwidth_client.two_factor_auth_client.mfa.create_verify_two_factor(ACCOUNT_ID, body)
523
+ response = @bandwidth_client.multi_factor_auth_client.mfa.create_verify_two_factor(BW_ACCOUNT_ID, body)
501
524
  #Ruby has no check to see if variables are of type boolean
502
525
  #An explicit true/false check is required
503
526
  assert(response.data.valid == true || response.data.valid == false, "'valid' variable is not a boolean")
@@ -558,7 +581,7 @@ class IntegrationTest < Test::Unit::TestCase
558
581
  actual = response.to_bxml()
559
582
  assert_equal(expected, actual)
560
583
  end
561
-
584
+
562
585
  def test_stop_gather
563
586
  stop_gather = Bandwidth::Voice::StopGather.new()
564
587
 
@@ -572,12 +595,24 @@ class IntegrationTest < Test::Unit::TestCase
572
595
 
573
596
  def test_tn_lookup
574
597
  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)
598
+ body.tns = [BW_NUMBER]
599
+ create_response = @bandwidth_client.phone_number_lookup_client.client.create_lookup_request(BW_ACCOUNT_ID, body)
577
600
  assert(create_response.data.request_id.length > 0, "request_id value not set")
578
601
 
579
602
  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)
603
+ get_response = @bandwidth_client.phone_number_lookup_client.client.get_lookup_request_status(BW_ACCOUNT_ID, request_id)
581
604
  assert(get_response.data.status.length > 0, "status value not set")
582
605
  end
606
+
607
+ def test_webrtc_generate_bxml
608
+ 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>'
609
+ actual = Bandwidth::WebRtc.generate_bxml('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4')
610
+ assert_equal(expected, actual)
611
+ end
612
+
613
+ def test_webrtc_generate_transfer_bxml_verb
614
+ expected = '<Transfer><SipUri uui="93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt">sip:sipx.webrtc.bandwidth.com:5060</SipUri></Transfer>'
615
+ actual = Bandwidth::WebRtc.generate_transfer_bxml_verb('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4')
616
+ assert_equal(expected, actual)
617
+ end
583
618
  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: 6.2.0
4
+ version: 9.0.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-07-12 00:00:00.000000000 Z
11
+ date: 2021-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logging
@@ -155,8 +155,8 @@ files:
155
155
  - lib/bandwidth/exceptions/api_exception.rb
156
156
  - lib/bandwidth/http/api_response.rb
157
157
  - lib/bandwidth/http/auth/messaging_basic_auth.rb
158
+ - lib/bandwidth/http/auth/multi_factor_auth_basic_auth.rb
158
159
  - lib/bandwidth/http/auth/phone_number_lookup_basic_auth.rb
159
- - lib/bandwidth/http/auth/two_factor_auth_basic_auth.rb
160
160
  - lib/bandwidth/http/auth/voice_basic_auth.rb
161
161
  - lib/bandwidth/http/auth/web_rtc_basic_auth.rb
162
162
  - lib/bandwidth/http/faraday_client.rb
@@ -181,6 +181,18 @@ files:
181
181
  - lib/bandwidth/messaging_lib/messaging/models/priority_enum.rb
182
182
  - lib/bandwidth/messaging_lib/messaging/models/tag.rb
183
183
  - lib/bandwidth/models/base_model.rb
184
+ - lib/bandwidth/multi_factor_auth_lib/multi_factor_auth.rb
185
+ - lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/client.rb
186
+ - lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/base_controller.rb
187
+ - lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/mfa_controller.rb
188
+ - lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb
189
+ - lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/forbidden_request_exception.rb
190
+ - lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/unauthorized_request_exception.rb
191
+ - lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_code_request_schema.rb
192
+ - lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_messaging_response.rb
193
+ - lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_code_response.rb
194
+ - lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_request_schema.rb
195
+ - lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_voice_response.rb
184
196
  - lib/bandwidth/phone_number_lookup_lib/phone_number_lookup.rb
185
197
  - lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/client.rb
186
198
  - lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb
@@ -190,18 +202,7 @@ files:
190
202
  - lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb
191
203
  - lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb
192
204
  - lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb
193
- - lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb
194
- - lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb
195
- - lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb
196
- - lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/mfa_controller.rb
197
- - lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/error_with_request_exception.rb
198
- - lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/forbidden_request_exception.rb
199
- - lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/unauthorized_request_exception.rb
200
- - lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb
201
- - lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_messaging_response.rb
202
- - lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_code_response.rb
203
- - lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb
204
- - lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_voice_response.rb
205
+ - lib/bandwidth/utilities/date_time_helper.rb
205
206
  - lib/bandwidth/utilities/file_wrapper.rb
206
207
  - lib/bandwidth/voice_lib/bxml/bxml.rb
207
208
  - lib/bandwidth/voice_lib/bxml/verbs/bridge.rb
@@ -231,36 +232,39 @@ files:
231
232
  - lib/bandwidth/voice_lib/voice/client.rb
232
233
  - lib/bandwidth/voice_lib/voice/controllers/api_controller.rb
233
234
  - lib/bandwidth/voice_lib/voice/controllers/base_controller.rb
234
- - lib/bandwidth/voice_lib/voice/exceptions/api_error_response_exception.rb
235
+ - lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb
235
236
  - lib/bandwidth/voice_lib/voice/models/answer_fallback_method_enum.rb
236
237
  - lib/bandwidth/voice_lib/voice/models/answer_method_enum.rb
237
- - lib/bandwidth/voice_lib/voice/models/api_call_response.rb
238
- - lib/bandwidth/voice_lib/voice/models/api_call_state_response.rb
239
- - lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb
240
- - lib/bandwidth/voice_lib/voice/models/api_modify_call_request.rb
241
- - lib/bandwidth/voice_lib/voice/models/api_modify_conference_request.rb
242
- - lib/bandwidth/voice_lib/voice/models/api_transcribe_recording_request.rb
238
+ - lib/bandwidth/voice_lib/voice/models/call_callback.rb
239
+ - lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb
240
+ - lib/bandwidth/voice_lib/voice/models/call_state.rb
243
241
  - lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb
244
- - lib/bandwidth/voice_lib/voice/models/conference_detail.rb
242
+ - lib/bandwidth/voice_lib/voice/models/conference_callback.rb
245
243
  - lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb
246
- - lib/bandwidth/voice_lib/voice/models/conference_member_detail.rb
247
- - lib/bandwidth/voice_lib/voice/models/conference_recording_metadata_response.rb
244
+ - lib/bandwidth/voice_lib/voice/models/conference_member_state.rb
245
+ - lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb
246
+ - lib/bandwidth/voice_lib/voice/models/conference_state.rb
247
+ - lib/bandwidth/voice_lib/voice/models/create_call_request.rb
248
+ - lib/bandwidth/voice_lib/voice/models/create_call_response.rb
248
249
  - lib/bandwidth/voice_lib/voice/models/direction_enum.rb
249
- - lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb
250
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
251
253
  - lib/bandwidth/voice_lib/voice/models/file_format_enum.rb
252
- - lib/bandwidth/voice_lib/voice/models/modify_call_recording_state.rb
253
- - lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb
254
+ - lib/bandwidth/voice_lib/voice/models/machine_detection_configuration.rb
255
+ - lib/bandwidth/voice_lib/voice/models/mode_enum.rb
256
+ - lib/bandwidth/voice_lib/voice/models/modify_call_recording_request.rb
257
+ - lib/bandwidth/voice_lib/voice/models/modify_call_request.rb
258
+ - lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb
254
259
  - lib/bandwidth/voice_lib/voice/models/redirect_fallback_method_enum.rb
255
260
  - lib/bandwidth/voice_lib/voice/models/redirect_method_enum.rb
256
261
  - lib/bandwidth/voice_lib/voice/models/state1_enum.rb
257
- - lib/bandwidth/voice_lib/voice/models/state2_enum.rb
258
262
  - lib/bandwidth/voice_lib/voice/models/state_enum.rb
259
- - lib/bandwidth/voice_lib/voice/models/status1_enum.rb
260
- - lib/bandwidth/voice_lib/voice/models/status3_enum.rb
261
263
  - lib/bandwidth/voice_lib/voice/models/status_enum.rb
264
+ - lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb
262
265
  - lib/bandwidth/voice_lib/voice/models/transcript.rb
263
266
  - lib/bandwidth/voice_lib/voice/models/transcription.rb
267
+ - lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb
264
268
  - lib/bandwidth/voice_lib/voice/models/transcription_response.rb
265
269
  - lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb
266
270
  - lib/bandwidth/web_rtc_lib/web_rtc.rb