bandwidth-sdk 5.0.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +90 -13
  3. data/lib/bandwidth.rb +5 -2
  4. data/lib/bandwidth/api_helper.rb +5 -17
  5. data/lib/bandwidth/client.rb +23 -9
  6. data/lib/bandwidth/configuration.rb +54 -18
  7. data/lib/bandwidth/http/auth/{two_factor_auth_basic_auth.rb → multi_factor_auth_basic_auth.rb} +3 -3
  8. data/lib/bandwidth/http/auth/phone_number_lookup_basic_auth.rb +22 -0
  9. data/lib/bandwidth/http/faraday_client.rb +5 -2
  10. data/lib/bandwidth/messaging_lib/messaging.rb +1 -0
  11. data/lib/bandwidth/messaging_lib/messaging/client.rb +14 -5
  12. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +25 -29
  13. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +11 -2
  14. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +47 -2
  15. data/lib/bandwidth/messaging_lib/messaging/models/media.rb +5 -75
  16. data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +13 -2
  17. data/lib/bandwidth/messaging_lib/messaging/models/priority_enum.rb +19 -0
  18. data/lib/bandwidth/models/base_model.rb +19 -8
  19. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth.rb +23 -0
  20. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/client.rb +60 -0
  21. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/controllers/base_controller.rb +0 -0
  22. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth/controllers/api_controller.rb → multi_factor_auth_lib/multi_factor_auth/controllers/mfa_controller.rb} +69 -18
  23. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb +34 -0
  24. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/forbidden_request_exception.rb +29 -0
  25. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/unauthorized_request_exception.rb +29 -0
  26. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_code_request_schema.rb +0 -0
  27. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_messaging_response.rb +0 -0
  28. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_verify_code_response.rb +0 -0
  29. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_verify_request_schema.rb +0 -0
  30. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_voice_response.rb +0 -0
  31. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup.rb +20 -0
  32. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → phone_number_lookup_lib/phone_number_lookup}/client.rb +15 -6
  33. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +1551 -0
  34. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +49 -0
  35. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth/exceptions/invalid_request_exception.rb → phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb} +5 -5
  36. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +35 -0
  37. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +45 -0
  38. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +74 -0
  39. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +107 -0
  40. data/lib/bandwidth/utilities/date_time_helper.rb +156 -0
  41. data/lib/bandwidth/voice_lib/voice.rb +14 -18
  42. data/lib/bandwidth/voice_lib/voice/client.rb +14 -5
  43. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +248 -230
  44. data/lib/bandwidth/voice_lib/voice/exceptions/{api_error_response_exception.rb → api_error_exception.rb} +2 -2
  45. data/lib/bandwidth/voice_lib/voice/models/{recording_metadata_response.rb → call_recording_metadata.rb} +47 -28
  46. data/lib/bandwidth/voice_lib/voice/models/call_state.rb +232 -0
  47. data/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb +2 -20
  48. data/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb +2 -20
  49. data/lib/bandwidth/voice_lib/voice/models/{conference_member_detail.rb → conference_member_state.rb} +8 -8
  50. data/lib/bandwidth/voice_lib/voice/models/{conference_recording_metadata_response.rb → conference_recording_metadata.rb} +34 -18
  51. data/lib/bandwidth/voice_lib/voice/models/{conference_detail.rb → conference_state.rb} +22 -14
  52. data/lib/bandwidth/voice_lib/voice/models/{api_create_call_request.rb → create_call_request.rb} +35 -59
  53. data/lib/bandwidth/voice_lib/voice/models/{api_call_response.rb → create_call_response.rb} +28 -23
  54. data/lib/bandwidth/voice_lib/voice/models/{modify_call_recording_state.rb → modify_call_recording_request.rb} +4 -4
  55. data/lib/bandwidth/voice_lib/voice/models/{api_modify_call_request.rb → modify_call_request.rb} +25 -25
  56. data/lib/bandwidth/voice_lib/voice/models/{api_modify_conference_request.rb → modify_conference_request.rb} +11 -11
  57. data/lib/bandwidth/voice_lib/voice/models/state1_enum.rb +7 -4
  58. data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +4 -7
  59. data/lib/bandwidth/voice_lib/voice/models/{api_transcribe_recording_request.rb → transcribe_recording_request.rb} +8 -8
  60. data/lib/bandwidth/voice_lib/voice/models/{transcription.rb → transcription_metadata.rb} +19 -10
  61. data/lib/bandwidth/web_rtc_lib/web_rtc.rb +1 -0
  62. data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +14 -5
  63. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +14 -14
  64. data/lib/bandwidth/web_rtc_lib/web_rtc/models/device_api_version_enum.rb +17 -0
  65. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +11 -2
  66. data/test/integration/test_integration.rb +583 -0
  67. metadata +47 -35
  68. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +0 -20
  69. data/lib/bandwidth/voice_lib/voice/models/api_call_state_response.rb +0 -164
  70. data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +0 -47
  71. data/lib/bandwidth/voice_lib/voice/models/state2_enum.rb +0 -20
  72. data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +0 -29
  73. data/lib/bandwidth/voice_lib/voice/models/status3_enum.rb +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc4d4b047d53e1e8c3f34b37696455d916a753aa3566dad6d6fb666fc2b3fa61
4
- data.tar.gz: b5cdf37c09788e890f36ef3c78ccf41f0ba18a69291f1424be7f798f207881f9
3
+ metadata.gz: b67b83b111ec3185ce0614d96b9f46ea31270db7e0b44a069cc8d87e16bf2bd5
4
+ data.tar.gz: b4c1575cda3afab5b3a17ccf70883ddd68815ec9e3e55c162d778cc7667dd8ad
5
5
  SHA512:
6
- metadata.gz: 59761140cdddf9f6cda37d7aeeaeff6341a5c0bcc357cf577ae29e8fff0a6cf347f1070536f99db3b2f3f6baae3c2b93edbefb2e94468036c57ffd7a65c279b0
7
- data.tar.gz: bdf68653a8640403d2bc5402c9f5af06055079640ab9229b16ac12cf48290ccffbe2ac38e40c11c3e6b518b1ebaad05344779249d0f79c940d32c3a57b36f5ed
6
+ metadata.gz: 7de5c586dc71cc06134c42008931b6508e5fca4a7baecd02dd94b5d9c5d1e26f10c6266c020ef6c91429a0e50e10678a32803e07c2af30e74833fe0a55ea7f65
7
+ data.tar.gz: 61b41ff9f216fee03ff287270a13666575006b870ecdc38c9edf8b4de93e7db0a4d45d37becf2b11bd52cfba399058739b3e9bea48d086d71d01983ef2da28f7
data/README.md CHANGED
@@ -1,16 +1,14 @@
1
1
  # Bandwidth Ruby SDK
2
-
3
- Bandwidth's API docs can be found at https://dev.bandwidth.com
4
2
 
5
- Ruby specific docs can be found at https://dev.bandwidth.com/sdks/ruby.html
3
+ ## Getting Started
6
4
 
7
- ## Download & Install
5
+ ### Installation
8
6
 
9
7
  ```
10
8
  gem install bandwidth-sdk
11
9
  ```
12
10
 
13
- ## Initialize Bandwidth Client
11
+ ### Initialize
14
12
 
15
13
  ```ruby
16
14
  require 'bandwidth'
@@ -18,21 +16,27 @@ require 'bandwidth'
18
16
  include Bandwidth
19
17
  include Bandwidth::Voice
20
18
  include Bandwidth::Messaging
19
+ include Bandwidth::WebRtc
20
+ include Bandwidth::TwoFactorAuth
21
21
 
22
22
  bandwidth_client = Bandwidth::Client.new(
23
23
  voice_basic_auth_user_name: 'username',
24
24
  voice_basic_auth_password: 'password',
25
- messaging_basic_auth_user_name: 'token',
26
- messaging_basic_auth_password: 'secret',
25
+ messaging_basic_auth_user_name: 'username',
26
+ messaging_basic_auth_password: 'username',
27
+ two_factor_auth_basic_auth_user_name: 'username',
28
+ two_factor_auth_basic_auth_password: 'password',
29
+ web_rtc_basic_auth_user_name: 'username',
30
+ web_rtc_basic_auth_password: 'password'
27
31
  )
32
+ account_id = "12345"
28
33
  ```
29
34
 
30
- ## Create Phone Call
35
+ ### Create Phone Call
31
36
 
32
37
  ```ruby
33
38
  voice_client = bandwidth_client.voice_client.client
34
39
 
35
- account_id = '1'
36
40
  body = ApiCreateCallRequest.new
37
41
  body.from = '+16666666666'
38
42
  body.to = '+17777777777'
@@ -49,7 +53,7 @@ rescue Bandwidth::ErrorResponseException => e
49
53
  end
50
54
  ```
51
55
 
52
- ## Generate BXML
56
+ ### Generate BXML
53
57
 
54
58
  ```ruby
55
59
  response = Bandwidth::Voice::Response.new()
@@ -59,12 +63,11 @@ response.push(hangup)
59
63
  puts response.to_bxml()
60
64
  ```
61
65
 
62
- ## Send Text Message
66
+ ### Send Text Message
63
67
 
64
68
  ```ruby
65
69
  messaging_client = bandwidth_client.messaging_client.client
66
70
 
67
- account_id = '1'
68
71
  body = MessageRequest.new
69
72
  body.application_id = '1-2-3'
70
73
  body.to = ['+17777777777']
@@ -72,7 +75,7 @@ body.from = '+18888888888'
72
75
  body.text = 'Hello from Bandwidth'
73
76
 
74
77
  begin
75
- response = messaging_client.create_message(account_id, :body => body)
78
+ response = messaging_client.create_message(account_id, body)
76
79
  puts response.data.id #1570740275373xbn7mbhsfewasdr
77
80
  puts response.status_code #202
78
81
  rescue Bandwidth::GenericClientException => e
@@ -83,3 +86,77 @@ rescue Bandwidth::PathClientException => e
83
86
  puts e.response_code #400
84
87
  end
85
88
  ```
89
+
90
+ ### Create A MFA Request
91
+
92
+ ```ruby
93
+ auth_client = bandwidth_client.two_factor_auth_client.mfa
94
+
95
+ from_phone = "+18888888888"
96
+ to_phone = "+17777777777"
97
+ messaging_application_id = "1-d-b"
98
+ scope = "scope"
99
+ digits = 6
100
+
101
+ body = TwoFactorCodeRequestSchema.new
102
+ body.from = from_phone
103
+ body.to = to_phone
104
+ body.application_id = messaging_application_id
105
+ body.scope = scope
106
+ body.digits = digits
107
+ body.message = "Your temporary {NAME} {SCOPE} code is {CODE}"
108
+
109
+ auth_client.create_messaging_two_factor(account_id, body)
110
+
111
+ code = "123456" #This is the user input to validate
112
+
113
+ body = TwoFactorVerifyRequestSchema.new
114
+ body.from = from_phone
115
+ body.to = to_phone
116
+ body.application_id = application_id
117
+ body.scope = scope
118
+ body.code = code
119
+ body.digits = digits
120
+ body.expiration_time_in_minutes = 3
121
+
122
+ response = auth_client.create_verify_two_factor(account_id, body)
123
+ puts "Auth status: " + response.data.valid.to_s
124
+ ```
125
+
126
+ ### WebRtc Participant & Session Management
127
+
128
+ ```ruby
129
+ web_rtc_client = bandwidth_client.web_rtc_client.client
130
+
131
+ create_session_body = Session.new
132
+ create_session_body.tag = 'new-session'
133
+
134
+ create_session_response = web_rtc_client.create_session(account_id, :body => create_session_body)
135
+ session_id = create_session_response.data.id
136
+ puts session_id
137
+
138
+ create_participant_body = Participant.new
139
+ create_participant_body.publish_permissions = [
140
+ PublishPermissionEnum::AUDIO,
141
+ PublishPermissionEnum::VIDEO
142
+ ]
143
+ create_participant_body.callback_url = "https://sample.com"
144
+
145
+ create_participant_response = web_rtc_client.create_participant(account_id, :body => create_participant_body)
146
+ participant_id = create_participant_response.data.participant.id
147
+ puts participant_id
148
+
149
+ web_rtc_client.add_participant_to_session(account_id, session_id, participant_id)
150
+ ```
151
+
152
+ ## Supported Ruby Versions
153
+
154
+ This package can be used with Ruby >= 2.0
155
+
156
+ ## Documentation
157
+
158
+ Documentation for this package can be found at https://dev.bandwidth.com/sdks/ruby.html
159
+
160
+ ## Credentials
161
+
162
+ Information for credentials for this package can be found at https://dev.bandwidth.com/guides/accountCredentials.html
data/lib/bandwidth.rb CHANGED
@@ -14,6 +14,7 @@ require_relative 'bandwidth/client.rb'
14
14
 
15
15
  # Utilities
16
16
  require_relative 'bandwidth/utilities/file_wrapper.rb'
17
+ require_relative 'bandwidth/utilities/date_time_helper.rb'
17
18
 
18
19
  # Http
19
20
  require_relative 'bandwidth/http/api_response.rb'
@@ -35,8 +36,10 @@ require_relative 'bandwidth/configuration.rb'
35
36
  # Namespaces
36
37
  require_relative 'bandwidth/messaging_lib/messaging'
37
38
  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'
39
+ require_relative 'bandwidth/multi_factor_auth_lib/multi_factor_auth'
40
+ require_relative 'bandwidth/http/auth/multi_factor_auth_basic_auth.rb'
41
+ require_relative 'bandwidth/phone_number_lookup_lib/phone_number_lookup'
42
+ require_relative 'bandwidth/http/auth/phone_number_lookup_basic_auth.rb'
40
43
  require_relative 'bandwidth/voice_lib/voice'
41
44
  require_relative 'bandwidth/http/auth/voice_basic_auth.rb'
42
45
  require_relative 'bandwidth/web_rtc_lib/web_rtc'
@@ -68,9 +68,7 @@ module Bandwidth
68
68
  # Appends the given set of parameters to the given query string.
69
69
  # @param [String] The query string builder to add the query parameters to.
70
70
  # @param [Hash] The parameters to append.
71
- # @param [String] The format of array parameter serialization.
72
- def self.append_url_with_query_parameters(query_builder, parameters,
73
- array_serialization: 'indexed')
71
+ def self.append_url_with_query_parameters(query_builder, parameters)
74
72
  # Perform parameter validation.
75
73
  unless query_builder.instance_of? String
76
74
  raise ArgumentError, 'Given value for parameter \"query_builder\"
@@ -80,6 +78,8 @@ module Bandwidth
80
78
  # Return if there are no parameters to replace.
81
79
  return query_builder if parameters.nil?
82
80
 
81
+ array_serialization = 'indexed'
82
+
83
83
  parameters.each do |key, value|
84
84
  seperator = query_builder.include?('?') ? '&' : '?'
85
85
  unless value.nil?
@@ -156,8 +156,8 @@ module Bandwidth
156
156
  # Form encodes a hash of parameters.
157
157
  # @param [Hash] The hash of parameters to encode.
158
158
  # @return [Hash] A hash with the same parameters form encoded.
159
- def self.form_encode_parameters(form_parameters,
160
- array_serialization: 'indexed')
159
+ def self.form_encode_parameters(form_parameters)
160
+ array_serialization = 'indexed'
161
161
  encoded = {}
162
162
  form_parameters.each do |key, value|
163
163
  encoded.merge!(APIHelper.form_encode(value, key, formatting:
@@ -273,17 +273,5 @@ module Bandwidth
273
273
  end
274
274
  val
275
275
  end
276
-
277
- # Safely converts a string into an rfc3339 DateTime object
278
- # @param [String] The datetime string
279
- # @return [DateTime] A DateTime object of rfc3339 format
280
- def self.rfc3339(date_time)
281
- # missing timezone information
282
- if date_time.end_with?('Z') || date_time.index('+')
283
- DateTime.rfc3339(date_time)
284
- else
285
- DateTime.rfc3339(date_time + 'Z')
286
- end
287
- end
288
276
  end
289
277
  end
@@ -12,10 +12,15 @@ module Bandwidth
12
12
  def messaging_client
13
13
  @messaging_client ||= Messaging::Client.new(config: config)
14
14
  end
15
- # Access to two_factor_auth_client controller.
16
- # @return [TwoFactorAuth::Client] Returns the client instance.
17
- def two_factor_auth_client
18
- @two_factor_auth_client ||= TwoFactorAuth::Client.new(config: config)
15
+ # Access to multi_factor_auth_client controller.
16
+ # @return [MultiFactorAuth::Client] Returns the client instance.
17
+ def multi_factor_auth_client
18
+ @multi_factor_auth_client ||= MultiFactorAuth::Client.new(config: config)
19
+ end
20
+ # Access to phone_number_lookup_client controller.
21
+ # @return [PhoneNumberLookup::Client] Returns the client instance.
22
+ def phone_number_lookup_client
23
+ @phone_number_lookup_client ||= PhoneNumberLookup::Client.new(config: config)
19
24
  end
20
25
  # Access to voice_client controller.
21
26
  # @return [Voice::Client] Returns the client instance.
@@ -29,12 +34,17 @@ module Bandwidth
29
34
  end
30
35
 
31
36
  def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
32
- backoff_factor: 1, environment: Environment::PRODUCTION,
37
+ backoff_factor: 2,
38
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
39
+ retry_methods: %i[get put get put],
40
+ environment: Environment::PRODUCTION,
33
41
  base_url: 'https://www.example.com',
34
42
  messaging_basic_auth_user_name: 'TODO: Replace',
35
43
  messaging_basic_auth_password: 'TODO: Replace',
36
- two_factor_auth_basic_auth_user_name: 'TODO: Replace',
37
- two_factor_auth_basic_auth_password: 'TODO: Replace',
44
+ multi_factor_auth_basic_auth_user_name: 'TODO: Replace',
45
+ multi_factor_auth_basic_auth_password: 'TODO: Replace',
46
+ phone_number_lookup_basic_auth_user_name: 'TODO: Replace',
47
+ phone_number_lookup_basic_auth_password: 'TODO: Replace',
38
48
  voice_basic_auth_user_name: 'TODO: Replace',
39
49
  voice_basic_auth_password: 'TODO: Replace',
40
50
  web_rtc_basic_auth_user_name: 'TODO: Replace',
@@ -43,12 +53,16 @@ module Bandwidth
43
53
  Configuration.new(timeout: timeout, max_retries: max_retries,
44
54
  retry_interval: retry_interval,
45
55
  backoff_factor: backoff_factor,
56
+ retry_statuses: retry_statuses,
57
+ retry_methods: retry_methods,
46
58
  environment: environment,
47
59
  base_url: base_url,
48
60
  messaging_basic_auth_user_name: messaging_basic_auth_user_name,
49
61
  messaging_basic_auth_password: messaging_basic_auth_password,
50
- two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
51
- two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
62
+ multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name,
63
+ multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password,
64
+ phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name,
65
+ phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password,
52
66
  voice_basic_auth_user_name: voice_basic_auth_user_name,
53
67
  voice_basic_auth_password: voice_basic_auth_password,
54
68
  web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
@@ -17,7 +17,8 @@ module Bandwidth
17
17
  SERVER = [
18
18
  DEFAULT = 'default'.freeze,
19
19
  MESSAGINGDEFAULT = 'MessagingDefault'.freeze,
20
- TWOFACTORAUTHDEFAULT = 'TwoFactorAuthDefault'.freeze,
20
+ MULTIFACTORAUTHDEFAULT = 'MultiFactorAuthDefault'.freeze,
21
+ PHONENUMBERLOOKUPDEFAULT = 'PhoneNumberLookupDefault'.freeze,
21
22
  VOICEDEFAULT = 'VoiceDefault'.freeze,
22
23
  WEBRTCDEFAULT = 'WebRtcDefault'.freeze
23
24
  ].freeze
@@ -32,12 +33,16 @@ module Bandwidth
32
33
  attr_reader :max_retries
33
34
  attr_reader :retry_interval
34
35
  attr_reader :backoff_factor
36
+ attr_reader :retry_statuses
37
+ attr_reader :retry_methods
35
38
  attr_reader :environment
36
39
  attr_reader :base_url
37
40
  attr_reader :messaging_basic_auth_user_name
38
41
  attr_reader :messaging_basic_auth_password
39
- attr_reader :two_factor_auth_basic_auth_user_name
40
- attr_reader :two_factor_auth_basic_auth_password
42
+ attr_reader :multi_factor_auth_basic_auth_user_name
43
+ attr_reader :multi_factor_auth_basic_auth_password
44
+ attr_reader :phone_number_lookup_basic_auth_user_name
45
+ attr_reader :phone_number_lookup_basic_auth_password
41
46
  attr_reader :voice_basic_auth_user_name
42
47
  attr_reader :voice_basic_auth_password
43
48
  attr_reader :web_rtc_basic_auth_user_name
@@ -48,12 +53,17 @@ module Bandwidth
48
53
  end
49
54
 
50
55
  def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
51
- backoff_factor: 1, environment: Environment::PRODUCTION,
56
+ backoff_factor: 2,
57
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
58
+ retry_methods: %i[get put get put],
59
+ environment: Environment::PRODUCTION,
52
60
  base_url: 'https://www.example.com',
53
61
  messaging_basic_auth_user_name: 'TODO: Replace',
54
62
  messaging_basic_auth_password: 'TODO: Replace',
55
- two_factor_auth_basic_auth_user_name: 'TODO: Replace',
56
- two_factor_auth_basic_auth_password: 'TODO: Replace',
63
+ multi_factor_auth_basic_auth_user_name: 'TODO: Replace',
64
+ multi_factor_auth_basic_auth_password: 'TODO: Replace',
65
+ phone_number_lookup_basic_auth_user_name: 'TODO: Replace',
66
+ phone_number_lookup_basic_auth_password: 'TODO: Replace',
57
67
  voice_basic_auth_user_name: 'TODO: Replace',
58
68
  voice_basic_auth_password: 'TODO: Replace',
59
69
  web_rtc_basic_auth_user_name: 'TODO: Replace',
@@ -71,6 +81,12 @@ module Bandwidth
71
81
  # by in order to provide backoff
72
82
  @backoff_factor = backoff_factor
73
83
 
84
+ # A list of HTTP statuses to retry
85
+ @retry_statuses = retry_statuses
86
+
87
+ # A list of HTTP methods to retry
88
+ @retry_methods = retry_methods
89
+
74
90
  # Current API environment
75
91
  @environment = String(environment)
76
92
 
@@ -84,10 +100,16 @@ module Bandwidth
84
100
  @messaging_basic_auth_password = messaging_basic_auth_password
85
101
 
86
102
  # The username to use with basic authentication
87
- @two_factor_auth_basic_auth_user_name = two_factor_auth_basic_auth_user_name
103
+ @multi_factor_auth_basic_auth_user_name = multi_factor_auth_basic_auth_user_name
104
+
105
+ # The password to use with basic authentication
106
+ @multi_factor_auth_basic_auth_password = multi_factor_auth_basic_auth_password
107
+
108
+ # The username to use with basic authentication
109
+ @phone_number_lookup_basic_auth_user_name = phone_number_lookup_basic_auth_user_name
88
110
 
89
111
  # The password to use with basic authentication
90
- @two_factor_auth_basic_auth_password = two_factor_auth_basic_auth_password
112
+ @phone_number_lookup_basic_auth_password = phone_number_lookup_basic_auth_password
91
113
 
92
114
  # The username to use with basic authentication
93
115
  @voice_basic_auth_user_name = voice_basic_auth_user_name
@@ -106,11 +128,14 @@ module Bandwidth
106
128
  end
107
129
 
108
130
  def clone_with(timeout: nil, max_retries: nil, retry_interval: nil,
109
- backoff_factor: nil, environment: nil, base_url: nil,
131
+ backoff_factor: nil, retry_statuses: nil, retry_methods: nil,
132
+ environment: nil, base_url: nil,
110
133
  messaging_basic_auth_user_name: nil,
111
134
  messaging_basic_auth_password: nil,
112
- two_factor_auth_basic_auth_user_name: nil,
113
- two_factor_auth_basic_auth_password: nil,
135
+ multi_factor_auth_basic_auth_user_name: nil,
136
+ multi_factor_auth_basic_auth_password: nil,
137
+ phone_number_lookup_basic_auth_user_name: nil,
138
+ phone_number_lookup_basic_auth_password: nil,
114
139
  voice_basic_auth_user_name: nil,
115
140
  voice_basic_auth_password: nil,
116
141
  web_rtc_basic_auth_user_name: nil,
@@ -119,12 +144,16 @@ module Bandwidth
119
144
  max_retries ||= self.max_retries
120
145
  retry_interval ||= self.retry_interval
121
146
  backoff_factor ||= self.backoff_factor
147
+ retry_statuses ||= self.retry_statuses
148
+ retry_methods ||= self.retry_methods
122
149
  environment ||= self.environment
123
150
  base_url ||= self.base_url
124
151
  messaging_basic_auth_user_name ||= self.messaging_basic_auth_user_name
125
152
  messaging_basic_auth_password ||= self.messaging_basic_auth_password
126
- two_factor_auth_basic_auth_user_name ||= self.two_factor_auth_basic_auth_user_name
127
- two_factor_auth_basic_auth_password ||= self.two_factor_auth_basic_auth_password
153
+ multi_factor_auth_basic_auth_user_name ||= self.multi_factor_auth_basic_auth_user_name
154
+ multi_factor_auth_basic_auth_password ||= self.multi_factor_auth_basic_auth_password
155
+ phone_number_lookup_basic_auth_user_name ||= self.phone_number_lookup_basic_auth_user_name
156
+ phone_number_lookup_basic_auth_password ||= self.phone_number_lookup_basic_auth_password
128
157
  voice_basic_auth_user_name ||= self.voice_basic_auth_user_name
129
158
  voice_basic_auth_password ||= self.voice_basic_auth_password
130
159
  web_rtc_basic_auth_user_name ||= self.web_rtc_basic_auth_user_name
@@ -133,11 +162,14 @@ module Bandwidth
133
162
  Configuration.new(
134
163
  timeout: timeout, max_retries: max_retries,
135
164
  retry_interval: retry_interval, backoff_factor: backoff_factor,
165
+ retry_statuses: retry_statuses, retry_methods: retry_methods,
136
166
  environment: environment, base_url: base_url,
137
167
  messaging_basic_auth_user_name: messaging_basic_auth_user_name,
138
168
  messaging_basic_auth_password: messaging_basic_auth_password,
139
- two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
140
- two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
169
+ multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name,
170
+ multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password,
171
+ phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name,
172
+ phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password,
141
173
  voice_basic_auth_user_name: voice_basic_auth_user_name,
142
174
  voice_basic_auth_password: voice_basic_auth_password,
143
175
  web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
@@ -148,7 +180,9 @@ module Bandwidth
148
180
  def create_http_client
149
181
  FaradayClient.new(timeout: timeout, max_retries: max_retries,
150
182
  retry_interval: retry_interval,
151
- backoff_factor: backoff_factor)
183
+ backoff_factor: backoff_factor,
184
+ retry_statuses: retry_statuses,
185
+ retry_methods: retry_methods)
152
186
  end
153
187
 
154
188
  # All the environments the SDK can run in.
@@ -156,14 +190,16 @@ module Bandwidth
156
190
  Environment::PRODUCTION => {
157
191
  Server::DEFAULT => 'api.bandwidth.com',
158
192
  Server::MESSAGINGDEFAULT => 'https://messaging.bandwidth.com/api/v2',
159
- Server::TWOFACTORAUTHDEFAULT => 'https://mfa.bandwidth.com/api/v1/',
193
+ Server::MULTIFACTORAUTHDEFAULT => 'https://mfa.bandwidth.com/api/v1',
194
+ Server::PHONENUMBERLOOKUPDEFAULT => 'https://numbers.bandwidth.com/api/v1',
160
195
  Server::VOICEDEFAULT => 'https://voice.bandwidth.com',
161
196
  Server::WEBRTCDEFAULT => 'https://api.webrtc.bandwidth.com/v1'
162
197
  },
163
198
  Environment::CUSTOM => {
164
199
  Server::DEFAULT => '{base_url}',
165
200
  Server::MESSAGINGDEFAULT => '{base_url}',
166
- Server::TWOFACTORAUTHDEFAULT => '{base_url}',
201
+ Server::MULTIFACTORAUTHDEFAULT => '{base_url}',
202
+ Server::PHONENUMBERLOOKUPDEFAULT => '{base_url}',
167
203
  Server::VOICEDEFAULT => '{base_url}',
168
204
  Server::WEBRTCDEFAULT => '{base_url}'
169
205
  }