bandwidth-sdk 3.13.2 → 6.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +90 -13
  4. data/lib/bandwidth.rb +2 -0
  5. data/lib/bandwidth/api_helper.rb +5 -5
  6. data/lib/bandwidth/client.rb +15 -1
  7. data/lib/bandwidth/configuration.rb +40 -4
  8. data/lib/bandwidth/http/api_response.rb +2 -0
  9. data/lib/bandwidth/http/auth/phone_number_lookup_basic_auth.rb +22 -0
  10. data/lib/bandwidth/http/faraday_client.rb +14 -4
  11. data/lib/bandwidth/messaging_lib/messaging.rb +4 -0
  12. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +135 -20
  13. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
  14. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +23 -13
  15. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +125 -0
  16. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +60 -0
  17. data/lib/bandwidth/messaging_lib/messaging/models/media.rb +4 -4
  18. data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +21 -8
  19. data/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +62 -0
  20. data/lib/bandwidth/messaging_lib/messaging/models/priority_enum.rb +19 -0
  21. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup.rb +20 -0
  22. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/client.rb +60 -0
  23. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +1551 -0
  24. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +49 -0
  25. 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
  26. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +35 -0
  27. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +45 -0
  28. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +74 -0
  29. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +107 -0
  30. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +4 -2
  31. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +4 -4
  32. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb +1 -1
  33. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/{api_controller.rb → mfa_controller.rb} +65 -14
  34. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/error_with_request_exception.rb +34 -0
  35. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/forbidden_request_exception.rb +29 -0
  36. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/unauthorized_request_exception.rb +29 -0
  37. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb +0 -19
  38. data/lib/bandwidth/voice_lib/voice.rb +1 -1
  39. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +51 -52
  40. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
  41. data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +77 -17
  42. data/lib/bandwidth/voice_lib/voice/models/{call_engine_modify_conference_request.rb → api_modify_conference_request.rb} +14 -14
  43. data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +3 -3
  44. data/lib/bandwidth/web_rtc_lib/web_rtc.rb +1 -0
  45. data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +10 -1
  46. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +24 -24
  47. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +1 -1
  48. data/lib/bandwidth/web_rtc_lib/web_rtc/models/device_api_version_enum.rb +17 -0
  49. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +11 -2
  50. data/test/controllers/controller_test_base.rb +21 -0
  51. data/test/http_response_catcher.rb +19 -0
  52. data/test/integration/test_integration.rb +583 -0
  53. data/test/test_helper.rb +94 -0
  54. metadata +66 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7336e9d451418630a0a7114a1f5e6d7ca929a7069afe71d5a81c96d3580f6ded
4
- data.tar.gz: e4da49bb09e35ab947352c4d0b92ee6a970450ed9aec84b89bfcbf31b079791a
3
+ metadata.gz: 5539a17ccb877e0e80a53959cbbc354314c0300c3c3ce1e90de0c4b5eae9f18a
4
+ data.tar.gz: 1f0466592184f21361287991b49a596c46d5de6f34dca9b727884f077591bf72
5
5
  SHA512:
6
- metadata.gz: ea2a492118247060435f24d8d1fdc5421293b4abcb4d321495b25dc5be178eab4b5b58a22f49363f5b254719a357bbb8a2def4cb412f00ce9633ddb1be05e792
7
- data.tar.gz: 79588ec737914f87a947b957b9e5a8f06335ba82d86fbe0eff55289df3109f21b6f55f33208cfe36fa6d491c63b31885fe910e98b21b72d5b37044cbf775ab9e
6
+ metadata.gz: fd6452d48d8a62e0bce5fb173132aac42f52918632c696e4153bfedc6d3c6db9769ab2941c0031d5c70b4ed245d35f0bee4929c54a6511441ad60e59c77c1fb5
7
+ data.tar.gz: 677a0c3e526b2d0f90d4d7905f7b914ce44f8d7a8eee47760693682da200c441cd476030a5e051dc87fdb716aea287d0184584d3c91691cb636ed49ecdaa07be
data/LICENSE CHANGED
@@ -3,7 +3,7 @@ License:
3
3
  The MIT License (MIT)
4
4
  http://opensource.org/licenses/MIT
5
5
 
6
- Copyright (c) 2014 - 2016 APIMATIC Limited
6
+ Copyright (c) 2014 - 2020 APIMATIC Limited
7
7
 
8
8
  Permission is hereby granted, free of charge, to any person obtaining a copy
9
9
  of this software and associated documentation files (the "Software"), to deal
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
@@ -37,6 +37,8 @@ require_relative 'bandwidth/messaging_lib/messaging'
37
37
  require_relative 'bandwidth/http/auth/messaging_basic_auth.rb'
38
38
  require_relative 'bandwidth/two_factor_auth_lib/two_factor_auth'
39
39
  require_relative 'bandwidth/http/auth/two_factor_auth_basic_auth.rb'
40
+ require_relative 'bandwidth/phone_number_lookup_lib/phone_number_lookup'
41
+ require_relative 'bandwidth/http/auth/phone_number_lookup_basic_auth.rb'
40
42
  require_relative 'bandwidth/voice_lib/voice'
41
43
  require_relative 'bandwidth/http/auth/voice_basic_auth.rb'
42
44
  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:
@@ -17,6 +17,11 @@ module Bandwidth
17
17
  def two_factor_auth_client
18
18
  @two_factor_auth_client ||= TwoFactorAuth::Client.new(config: config)
19
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)
24
+ end
20
25
  # Access to voice_client controller.
21
26
  # @return [Voice::Client] Returns the client instance.
22
27
  def voice_client
@@ -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
44
  two_factor_auth_basic_auth_user_name: 'TODO: Replace',
37
45
  two_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
62
  two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
51
63
  two_factor_auth_basic_auth_password: two_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,
@@ -18,6 +18,7 @@ module Bandwidth
18
18
  DEFAULT = 'default'.freeze,
19
19
  MESSAGINGDEFAULT = 'MessagingDefault'.freeze,
20
20
  TWOFACTORAUTHDEFAULT = 'TwoFactorAuthDefault'.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
42
  attr_reader :two_factor_auth_basic_auth_user_name
40
43
  attr_reader :two_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
63
  two_factor_auth_basic_auth_user_name: 'TODO: Replace',
56
64
  two_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
 
@@ -89,6 +105,12 @@ module Bandwidth
89
105
  # The password to use with basic authentication
90
106
  @two_factor_auth_basic_auth_password = two_factor_auth_basic_auth_password
91
107
 
108
+ # The username to use with basic authentication
109
+ @phone_number_lookup_basic_auth_user_name = phone_number_lookup_basic_auth_user_name
110
+
111
+ # The password to use with basic authentication
112
+ @phone_number_lookup_basic_auth_password = phone_number_lookup_basic_auth_password
113
+
92
114
  # The username to use with basic authentication
93
115
  @voice_basic_auth_user_name = voice_basic_auth_user_name
94
116
 
@@ -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
135
  two_factor_auth_basic_auth_user_name: nil,
113
136
  two_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
153
  two_factor_auth_basic_auth_user_name ||= self.two_factor_auth_basic_auth_user_name
127
154
  two_factor_auth_basic_auth_password ||= self.two_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
169
  two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
140
170
  two_factor_auth_basic_auth_password: two_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,7 +190,8 @@ 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::TWOFACTORAUTHDEFAULT => '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
  },
@@ -164,6 +199,7 @@ module Bandwidth
164
199
  Server::DEFAULT => '{base_url}',
165
200
  Server::MESSAGINGDEFAULT => '{base_url}',
166
201
  Server::TWOFACTORAUTHDEFAULT => '{base_url}',
202
+ Server::PHONENUMBERLOOKUPDEFAULT => '{base_url}',
167
203
  Server::VOICEDEFAULT => '{base_url}',
168
204
  Server::WEBRTCDEFAULT => '{base_url}'
169
205
  }
@@ -25,10 +25,12 @@ module Bandwidth
25
25
  @errors = errors
26
26
  end
27
27
 
28
+ # returns true if status_code is between 200-300
28
29
  def success?
29
30
  status_code >= 200 && status_code < 300
30
31
  end
31
32
 
33
+ # returns true if status_code is between 400-600
32
34
  def error?
33
35
  status_code >= 400 && status_code < 600
34
36
  end
@@ -0,0 +1,22 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require 'base64'
7
+
8
+ module Bandwidth
9
+ # Utility class for basic authorization.
10
+ class PhoneNumberLookupBasicAuth
11
+ # Add basic authentication to the request.
12
+ # @param [HttpRequest] The HttpRequest object to which authentication will
13
+ # be added.
14
+ def self.apply(config, http_request)
15
+ username = config.phone_number_lookup_basic_auth_user_name
16
+ password = config.phone_number_lookup_basic_auth_password
17
+ value = Base64.strict_encode64("#{username}:#{password}")
18
+ header_value = "Basic #{value}"
19
+ http_request.headers['Authorization'] = header_value
20
+ end
21
+ end
22
+ end