bandwidth-sdk 7.0.0 → 9.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -0
  3. data/lib/bandwidth/api_helper.rb +19 -17
  4. data/lib/bandwidth/configuration.rb +7 -19
  5. data/lib/bandwidth/http/faraday_client.rb +1 -1
  6. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +53 -42
  7. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +3 -5
  8. data/lib/bandwidth/messaging_lib/messaging/exceptions/messaging_exception.rb +5 -2
  9. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb +31 -11
  10. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +54 -25
  11. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +65 -32
  12. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +23 -4
  13. data/lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb +20 -4
  14. data/lib/bandwidth/messaging_lib/messaging/models/media.rb +23 -6
  15. data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +32 -14
  16. data/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +28 -8
  17. data/lib/bandwidth/messaging_lib/messaging/models/tag.rb +20 -4
  18. data/lib/bandwidth/models/base_model.rb +11 -0
  19. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/base_controller.rb +3 -5
  20. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/mfa_controller.rb +21 -16
  21. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb +5 -2
  22. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/forbidden_request_exception.rb +4 -1
  23. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/unauthorized_request_exception.rb +4 -1
  24. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_code_request_schema.rb +27 -12
  25. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_messaging_response.rb +17 -2
  26. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_code_response.rb +17 -2
  27. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_request_schema.rb +29 -10
  28. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_voice_response.rb +17 -2
  29. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +212 -210
  30. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +3 -5
  31. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb +4 -1
  32. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +17 -2
  33. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +20 -4
  34. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +28 -7
  35. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +43 -18
  36. data/lib/bandwidth/utilities/date_time_helper.rb +2 -2
  37. data/lib/bandwidth/utilities/file_wrapper.rb +1 -2
  38. data/lib/bandwidth/voice_lib/bxml/verbs/ring.rb +2 -1
  39. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +171 -150
  40. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +3 -5
  41. data/lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb +6 -3
  42. data/lib/bandwidth/voice_lib/voice/models/call_callback.rb +343 -0
  43. data/lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb +78 -37
  44. data/lib/bandwidth/voice_lib/voice/models/call_state.rb +94 -42
  45. data/lib/bandwidth/voice_lib/voice/models/conference_callback.rb +211 -0
  46. data/lib/bandwidth/voice_lib/voice/models/conference_member_state.rb +35 -12
  47. data/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb +55 -24
  48. data/lib/bandwidth/voice_lib/voice/models/conference_state.rb +54 -17
  49. data/lib/bandwidth/voice_lib/voice/models/create_call_request.rb +173 -96
  50. data/lib/bandwidth/voice_lib/voice/models/create_call_response.rb +85 -41
  51. data/lib/bandwidth/voice_lib/voice/models/diversion.rb +80 -0
  52. data/lib/bandwidth/voice_lib/voice/models/fallback_method_enum.rb +17 -0
  53. data/lib/bandwidth/voice_lib/voice/models/machine_detection_configuration.rb +218 -0
  54. data/lib/bandwidth/voice_lib/voice/models/mode_enum.rb +20 -0
  55. data/lib/bandwidth/voice_lib/voice/models/modify_call_recording_request.rb +15 -2
  56. data/lib/bandwidth/voice_lib/voice/models/modify_call_request.rb +59 -19
  57. data/lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb +55 -18
  58. data/lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb +40 -12
  59. data/lib/bandwidth/voice_lib/voice/models/transcript.rb +20 -4
  60. data/lib/bandwidth/voice_lib/voice/models/transcription.rb +80 -0
  61. data/lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb +26 -8
  62. data/lib/bandwidth/voice_lib/voice/models/transcription_response.rb +18 -1
  63. data/lib/bandwidth/voice_lib/voice.rb +7 -1
  64. data/lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb +7 -2
  65. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +61 -50
  66. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +3 -5
  67. data/lib/bandwidth/web_rtc_lib/web_rtc/exceptions/error_exception.rb +5 -2
  68. data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +20 -5
  69. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +37 -14
  70. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +15 -2
  71. data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +20 -4
  72. data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +20 -3
  73. data/lib/bandwidth.rb +19 -18
  74. data/test/integration/test_integration.rb +95 -58
  75. metadata +10 -3
@@ -19,14 +19,12 @@ module Bandwidth
19
19
 
20
20
  def validate_parameters(args)
21
21
  args.each do |_name, value|
22
- if value.nil?
23
- raise ArgumentError, "Required parameter #{_name} cannot be nil."
24
- end
22
+ raise ArgumentError, "Required parameter #{_name} cannot be nil." if value.nil?
25
23
  end
26
24
  end
27
25
 
28
26
  def execute_request(request, binary: false)
29
- @http_call_back.on_before_request(request) if @http_call_back
27
+ @http_call_back&.on_before_request(request)
30
28
 
31
29
  APIHelper.clean_hash(request.headers)
32
30
  request.headers.merge!(@global_headers)
@@ -36,7 +34,7 @@ module Bandwidth
36
34
  else
37
35
  config.http_client.execute_as_string(request)
38
36
  end
39
- @http_call_back.on_after_response(response) if @http_call_back
37
+ @http_call_back&.on_after_response(response)
40
38
 
41
39
  response
42
40
  end
@@ -6,6 +6,9 @@
6
6
  module Bandwidth
7
7
  # Accounts Tnlookup 400 Error class.
8
8
  class AccountsTnlookup400ErrorException < APIException
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
9
12
  # A description of what validation error occurred.
10
13
  # @return [String]
11
14
  attr_accessor :message
@@ -23,7 +26,7 @@ module Bandwidth
23
26
  # @param [Hash] The deserialized response sent by the server in the
24
27
  # response body.
25
28
  def unbox(hash)
26
- @message = hash['message']
29
+ @message = hash.key?('message') ? hash['message'] : SKIP
27
30
  end
28
31
  end
29
32
  end
@@ -6,6 +6,9 @@
6
6
  module Bandwidth
7
7
  # Create TN Lookup Request
8
8
  class OrderRequest < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
9
12
  # TODO: Write general description for this method
10
13
  # @return [List of String]
11
14
  attr_accessor :tns
@@ -17,8 +20,20 @@ module Bandwidth
17
20
  @_hash
18
21
  end
19
22
 
23
+ # An array for optional fields
24
+ def optionals
25
+ %w[
26
+ tns
27
+ ]
28
+ end
29
+
30
+ # An array for nullable fields
31
+ def nullables
32
+ []
33
+ end
34
+
20
35
  def initialize(tns = nil)
21
- @tns = tns
36
+ @tns = tns unless tns == SKIP
22
37
  end
23
38
 
24
39
  # Creates an instance of the object from a hash.
@@ -26,7 +41,7 @@ module Bandwidth
26
41
  return nil unless hash
27
42
 
28
43
  # Extract variables from the hash.
29
- tns = hash['tns']
44
+ tns = hash.key?('tns') ? hash['tns'] : SKIP
30
45
 
31
46
  # Create object from extracted values.
32
47
  OrderRequest.new(tns)
@@ -7,6 +7,9 @@ module Bandwidth
7
7
  # The request has been accepted for processing but not yet finished and in a
8
8
  # terminal state (COMPLETE, PARTIAL_COMPLETE, or FAILED)
9
9
  class OrderResponse < BaseModel
10
+ SKIP = Object.new
11
+ private_constant :SKIP
12
+
10
13
  # TODO: Write general description for this method
11
14
  # @return [String]
12
15
  attr_accessor :request_id
@@ -23,10 +26,23 @@ module Bandwidth
23
26
  @_hash
24
27
  end
25
28
 
29
+ # An array for optional fields
30
+ def optionals
31
+ %w[
32
+ request_id
33
+ status
34
+ ]
35
+ end
36
+
37
+ # An array for nullable fields
38
+ def nullables
39
+ []
40
+ end
41
+
26
42
  def initialize(request_id = nil,
27
43
  status = nil)
28
- @request_id = request_id
29
- @status = status
44
+ @request_id = request_id unless request_id == SKIP
45
+ @status = status unless status == SKIP
30
46
  end
31
47
 
32
48
  # Creates an instance of the object from a hash.
@@ -34,8 +50,8 @@ module Bandwidth
34
50
  return nil unless hash
35
51
 
36
52
  # Extract variables from the hash.
37
- request_id = hash['requestId']
38
- status = hash['status']
53
+ request_id = hash.key?('requestId') ? hash['requestId'] : SKIP
54
+ status = hash.key?('status') ? hash['status'] : SKIP
39
55
 
40
56
  # Create object from extracted values.
41
57
  OrderResponse.new(request_id,
@@ -10,6 +10,9 @@ module Bandwidth
10
10
  # will be available for it. Any other Response Code will indicate no
11
11
  # information was available for the TN.
12
12
  class OrderStatus < BaseModel
13
+ SKIP = Object.new
14
+ private_constant :SKIP
15
+
13
16
  # The requestId.
14
17
  # @return [String]
15
18
  attr_accessor :request_id
@@ -37,14 +40,29 @@ module Bandwidth
37
40
  @_hash
38
41
  end
39
42
 
43
+ # An array for optional fields
44
+ def optionals
45
+ %w[
46
+ request_id
47
+ status
48
+ failed_telephone_numbers
49
+ result
50
+ ]
51
+ end
52
+
53
+ # An array for nullable fields
54
+ def nullables
55
+ []
56
+ end
57
+
40
58
  def initialize(request_id = nil,
41
59
  status = nil,
42
60
  failed_telephone_numbers = nil,
43
61
  result = nil)
44
- @request_id = request_id
45
- @status = status
46
- @failed_telephone_numbers = failed_telephone_numbers
47
- @result = result
62
+ @request_id = request_id unless request_id == SKIP
63
+ @status = status unless status == SKIP
64
+ @failed_telephone_numbers = failed_telephone_numbers unless failed_telephone_numbers == SKIP
65
+ @result = result unless result == SKIP
48
66
  end
49
67
 
50
68
  # Creates an instance of the object from a hash.
@@ -52,9 +70,10 @@ module Bandwidth
52
70
  return nil unless hash
53
71
 
54
72
  # Extract variables from the hash.
55
- request_id = hash['requestId']
56
- status = hash['status']
57
- failed_telephone_numbers = hash['failedTelephoneNumbers']
73
+ request_id = hash.key?('requestId') ? hash['requestId'] : SKIP
74
+ status = hash.key?('status') ? hash['status'] : SKIP
75
+ failed_telephone_numbers =
76
+ hash.key?('failedTelephoneNumbers') ? hash['failedTelephoneNumbers'] : SKIP
58
77
  # Parameter is an array, so we need to iterate through it
59
78
  result = nil
60
79
  unless hash['result'].nil?
@@ -64,6 +83,8 @@ module Bandwidth
64
83
  end
65
84
  end
66
85
 
86
+ result = SKIP unless hash.key?('result')
87
+
67
88
  # Create object from extracted values.
68
89
  OrderStatus.new(request_id,
69
90
  status,
@@ -6,6 +6,9 @@
6
6
  module Bandwidth
7
7
  # Result Model.
8
8
  class Result < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
9
12
  # Our vendor's response code.
10
13
  # @return [Integer]
11
14
  attr_accessor :response_code
@@ -57,6 +60,26 @@ module Bandwidth
57
60
  @_hash
58
61
  end
59
62
 
63
+ # An array for optional fields
64
+ def optionals
65
+ %w[
66
+ response_code
67
+ message
68
+ e_164_format
69
+ formatted
70
+ country
71
+ line_type
72
+ line_provider
73
+ mobile_country_code
74
+ mobile_network_code
75
+ ]
76
+ end
77
+
78
+ # An array for nullable fields
79
+ def nullables
80
+ []
81
+ end
82
+
60
83
  def initialize(response_code = nil,
61
84
  message = nil,
62
85
  e_164_format = nil,
@@ -66,15 +89,15 @@ module Bandwidth
66
89
  line_provider = nil,
67
90
  mobile_country_code = nil,
68
91
  mobile_network_code = nil)
69
- @response_code = response_code
70
- @message = message
71
- @e_164_format = e_164_format
72
- @formatted = formatted
73
- @country = country
74
- @line_type = line_type
75
- @line_provider = line_provider
76
- @mobile_country_code = mobile_country_code
77
- @mobile_network_code = mobile_network_code
92
+ @response_code = response_code unless response_code == SKIP
93
+ @message = message unless message == SKIP
94
+ @e_164_format = e_164_format unless e_164_format == SKIP
95
+ @formatted = formatted unless formatted == SKIP
96
+ @country = country unless country == SKIP
97
+ @line_type = line_type unless line_type == SKIP
98
+ @line_provider = line_provider unless line_provider == SKIP
99
+ @mobile_country_code = mobile_country_code unless mobile_country_code == SKIP
100
+ @mobile_network_code = mobile_network_code unless mobile_network_code == SKIP
78
101
  end
79
102
 
80
103
  # Creates an instance of the object from a hash.
@@ -82,15 +105,17 @@ module Bandwidth
82
105
  return nil unless hash
83
106
 
84
107
  # Extract variables from the hash.
85
- response_code = hash['Response Code']
86
- message = hash['Message']
87
- e_164_format = hash['E.164 Format']
88
- formatted = hash['Formatted']
89
- country = hash['Country']
90
- line_type = hash['Line Type']
91
- line_provider = hash['Line Provider']
92
- mobile_country_code = hash['Mobile Country Code']
93
- mobile_network_code = hash['Mobile Network Code']
108
+ response_code = hash.key?('Response Code') ? hash['Response Code'] : SKIP
109
+ message = hash.key?('Message') ? hash['Message'] : SKIP
110
+ e_164_format = hash.key?('E.164 Format') ? hash['E.164 Format'] : SKIP
111
+ formatted = hash.key?('Formatted') ? hash['Formatted'] : SKIP
112
+ country = hash.key?('Country') ? hash['Country'] : SKIP
113
+ line_type = hash.key?('Line Type') ? hash['Line Type'] : SKIP
114
+ line_provider = hash.key?('Line Provider') ? hash['Line Provider'] : SKIP
115
+ mobile_country_code =
116
+ hash.key?('Mobile Country Code') ? hash['Mobile Country Code'] : SKIP
117
+ mobile_network_code =
118
+ hash.key?('Mobile Network Code') ? hash['Mobile Network Code'] : SKIP
94
119
 
95
120
  # Create object from extracted values.
96
121
  Result.new(response_code,
@@ -11,7 +11,7 @@ module Bandwidth
11
11
  # @param [DateTime] The DateTime object
12
12
  # @return [String] The rfc1123 formatted datetime string
13
13
  def self.to_rfc1123(date_time)
14
- date_time.httpdate unless date_time.nil?
14
+ date_time&.httpdate
15
15
  end
16
16
 
17
17
  # Safely converts a map of DateTime objects into a map of rfc1123 format string
@@ -91,7 +91,7 @@ module Bandwidth
91
91
  # @param [DateTime] The DateTime object
92
92
  # @return [String] The rfc3339 formatted datetime string
93
93
  def self.to_rfc3339(date_time)
94
- date_time.rfc3339 unless date_time.nil?
94
+ date_time&.rfc3339
95
95
  end
96
96
 
97
97
  # Safely converts a map of DateTime objects into a map of rfc1123 format string
@@ -6,8 +6,7 @@
6
6
  module Bandwidth
7
7
  # A utility to allow users to set the content-type for files
8
8
  class FileWrapper
9
- attr_reader :content_type
10
- attr_reader :file
9
+ attr_reader :content_type, :file
11
10
 
12
11
  def initialize(file, content_type: 'application/octet-stream')
13
12
  @file = file
@@ -7,7 +7,8 @@ module Bandwidth
7
7
 
8
8
  def to_bxml(xml)
9
9
  xml.Ring(compact_hash({
10
- 'duration' => duration
10
+ 'duration' => duration,
11
+ 'answerCall' => answer_call
11
12
  }))
12
13
  end
13
14
  end