bandwidth-sdk 6.2.0 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -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,
@@ -0,0 +1,156 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require 'date'
7
+ module Bandwidth
8
+ # A utility that supports dateTime conversion to different formats
9
+ class DateTimeHelper
10
+ # Safely converts a DateTime object into a rfc1123 format string
11
+ # @param [DateTime] The DateTime object
12
+ # @return [String] The rfc1123 formatted datetime string
13
+ def self.to_rfc1123(date_time)
14
+ date_time&.httpdate
15
+ end
16
+
17
+ # Safely converts a map of DateTime objects into a map of rfc1123 format string
18
+ # @param [hash] a map of DateTime objects
19
+ # @return [hash] a map of rfc1123 formatted datetime string
20
+ def self.to_rfc1123_map(date_time, hash, key)
21
+ return if date_time.nil?
22
+
23
+ hash[key] = {}
24
+ date_time.each do |k, v|
25
+ hash[key][k] =
26
+ if v.is_a?(BaseModel)
27
+ v.to_hash
28
+ else
29
+ v.is_a?(DateTime) ? DateTimeHelper.to_rfc1123(v) : v
30
+ end
31
+ end
32
+ hash[key]
33
+ end
34
+
35
+ # Safely converts an array of DateTime objects into an array of rfc1123 format string
36
+ # @param [Array] an array of DateTime objects
37
+ # @return [Array] an array of rfc1123 formatted datetime string
38
+ def self.to_rfc1123_array(date_time, hash, key)
39
+ return if date_time.nil?
40
+
41
+ hash[key] = date_time.map do |v|
42
+ if v.is_a?(BaseModel)
43
+ v.to_hash
44
+ else
45
+ v.is_a?(DateTime) ? DateTimeHelper.to_rfc1123(v) : v
46
+ end
47
+ end
48
+ end
49
+
50
+ # Safely converts a DateTime object into a unix format string
51
+ # @param [DateTime] The DateTime object
52
+ # @return [String] The unix formatted datetime string
53
+ def self.to_unix(date_time)
54
+ date_time.to_time.utc.to_i unless date_time.nil?
55
+ end
56
+
57
+ # Safely converts a map of DateTime objects into a map of unix format string
58
+ # @param [hash] a map of DateTime objects
59
+ # @return [hash] a map of unix formatted datetime string
60
+ def self.to_unix_map(date_time, hash, key)
61
+ return if date_time.nil?
62
+
63
+ hash[key] = {}
64
+ date_time.each do |k, v|
65
+ hash[key][k] =
66
+ if v.is_a?(BaseModel)
67
+ v.to_hash
68
+ else
69
+ v.is_a?(DateTime) ? DateTimeHelper.to_unix(v) : v
70
+ end
71
+ end
72
+ hash[key]
73
+ end
74
+
75
+ # Safely converts an array of DateTime objects into a map of unix format string
76
+ # @param [hash] an array of DateTime objects
77
+ # @return [hash] an array of unix formatted datetime string
78
+ def self.to_unix_array(date_time, hash, key)
79
+ return if date_time.nil?
80
+
81
+ hash[key] = date_time.map do |v|
82
+ if v.is_a?(BaseModel)
83
+ v.to_hash
84
+ else
85
+ v.is_a?(DateTime) ? DateTimeHelper.to_unix(v) : v
86
+ end
87
+ end
88
+ end
89
+
90
+ # Safely converts a DateTime object into a rfc3339 format string
91
+ # @param [DateTime] The DateTime object
92
+ # @return [String] The rfc3339 formatted datetime string
93
+ def self.to_rfc3339(date_time)
94
+ date_time&.rfc3339
95
+ end
96
+
97
+ # Safely converts a map of DateTime objects into a map of rfc1123 format string
98
+ # @param [hash] a map of DateTime objects
99
+ # @return [hash] a map of rfc1123 formatted datetime string
100
+ def self.to_rfc3339_map(date_time, hash, key)
101
+ return if date_time.nil?
102
+
103
+ hash[key] = {}
104
+ date_time.each do |k, v|
105
+ hash[key][k] =
106
+ if v.is_a?(BaseModel)
107
+ v.to_hash
108
+ else
109
+ v.is_a?(DateTime) ? DateTimeHelper.to_rfc3339(v) : v
110
+ end
111
+ end
112
+ hash[key]
113
+ end
114
+
115
+ # Safely converts an array of DateTime objects into an array of rfc1123 format string
116
+ # @param [Array] an array of DateTime objects
117
+ # @return [Array] an array of rfc1123 formatted datetime string
118
+ def self.to_rfc3339_array(date_time, hash, key)
119
+ return if date_time.nil?
120
+
121
+ hash[key] = date_time.map do |v|
122
+ if v.is_a?(BaseModel)
123
+ v.to_hash
124
+ else
125
+ v.is_a?(DateTime) ? DateTimeHelper.to_rfc3339(v) : v
126
+ end
127
+ end
128
+ end
129
+
130
+ # Safely converts a rfc1123 format string into a DateTime object
131
+ # @param [String] The rfc1123 formatted datetime string
132
+ # @return [DateTime] A DateTime object
133
+ def self.from_rfc1123(date_time)
134
+ DateTime.httpdate(date_time)
135
+ end
136
+
137
+ # Safely converts a unix format string into a DateTime object
138
+ # @param [String] The unix formatted datetime string
139
+ # @return [DateTime] A DateTime object
140
+ def self.from_unix(date_time)
141
+ Time.at(date_time.to_i).utc.to_datetime
142
+ end
143
+
144
+ # Safely converts a rfc3339 format string into a DateTime object
145
+ # @param [String] The rfc3339 formatted datetime string
146
+ # @return [DateTime] A DateTime object
147
+ def self.from_rfc3339(date_time)
148
+ # missing timezone information
149
+ if date_time.end_with?('Z') || date_time.index('+')
150
+ DateTime.rfc3339(date_time)
151
+ else
152
+ DateTime.rfc3339("#{date_time}Z")
153
+ end
154
+ end
155
+ end
156
+ end
@@ -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
@@ -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: 1, environment: Environment::PRODUCTION,
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
- two_factor_auth_basic_auth_user_name: 'TODO: Replace',
24
- two_factor_auth_basic_auth_password: 'TODO: Replace',
26
+ multi_factor_auth_basic_auth_user_name: 'TODO: Replace',
27
+ multi_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
- two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
40
- two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
46
+ multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name,
47
+ multi_factor_auth_basic_auth_password: multi_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,