@@ -18,6 +18,7 @@ class Server
1818 DEFAULT = 'default' . freeze ,
1919 MESSAGINGDEFAULT = 'MessagingDefault' . freeze ,
2020 TWOFACTORAUTHDEFAULT = 'TwoFactorAuthDefault' . freeze ,
21+ PHONENUMBERLOOKUPDEFAULT = 'PhoneNumberLookupDefault' . freeze ,
2122 VOICEDEFAULT = 'VoiceDefault' . freeze ,
2223 WEBRTCDEFAULT = 'WebRtcDefault' . freeze
2324 ] . freeze
@@ -32,12 +33,16 @@ class Configuration
3233 attr_reader :max_retries
3334 attr_reader :retry_interval
3435 attr_reader :backoff_factor
36+ attr_reader :retry_statuses
37+ attr_reader :retry_methods
3538 attr_reader :environment
3639 attr_reader :base_url
3740 attr_reader :messaging_basic_auth_user_name
3841 attr_reader :messaging_basic_auth_password
3942 attr_reader :two_factor_auth_basic_auth_user_name
4043 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
4146 attr_reader :voice_basic_auth_user_name
4247 attr_reader :voice_basic_auth_password
4348 attr_reader :web_rtc_basic_auth_user_name
@@ -48,12 +53,17 @@ class << self
4853 end
4954
5055 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 ,
5260 base_url : 'https://www.example.com' ,
5361 messaging_basic_auth_user_name : 'TODO: Replace' ,
5462 messaging_basic_auth_password : 'TODO: Replace' ,
5563 two_factor_auth_basic_auth_user_name : 'TODO: Replace' ,
5664 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' ,
5767 voice_basic_auth_user_name : 'TODO: Replace' ,
5868 voice_basic_auth_password : 'TODO: Replace' ,
5969 web_rtc_basic_auth_user_name : 'TODO: Replace' ,
@@ -71,6 +81,12 @@ def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
7181 # by in order to provide backoff
7282 @backoff_factor = backoff_factor
7383
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+
7490 # Current API environment
7591 @environment = String ( environment )
7692
@@ -89,6 +105,12 @@ def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
89105 # The password to use with basic authentication
90106 @two_factor_auth_basic_auth_password = two_factor_auth_basic_auth_password
91107
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+
92114 # The username to use with basic authentication
93115 @voice_basic_auth_user_name = voice_basic_auth_user_name
94116
@@ -106,11 +128,14 @@ def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
106128 end
107129
108130 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 ,
110133 messaging_basic_auth_user_name : nil ,
111134 messaging_basic_auth_password : nil ,
112135 two_factor_auth_basic_auth_user_name : nil ,
113136 two_factor_auth_basic_auth_password : nil ,
137+ phone_number_lookup_basic_auth_user_name : nil ,
138+ phone_number_lookup_basic_auth_password : nil ,
114139 voice_basic_auth_user_name : nil ,
115140 voice_basic_auth_password : nil ,
116141 web_rtc_basic_auth_user_name : nil ,
@@ -119,12 +144,16 @@ def clone_with(timeout: nil, max_retries: nil, retry_interval: nil,
119144 max_retries ||= self . max_retries
120145 retry_interval ||= self . retry_interval
121146 backoff_factor ||= self . backoff_factor
147+ retry_statuses ||= self . retry_statuses
148+ retry_methods ||= self . retry_methods
122149 environment ||= self . environment
123150 base_url ||= self . base_url
124151 messaging_basic_auth_user_name ||= self . messaging_basic_auth_user_name
125152 messaging_basic_auth_password ||= self . messaging_basic_auth_password
126153 two_factor_auth_basic_auth_user_name ||= self . two_factor_auth_basic_auth_user_name
127154 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
128157 voice_basic_auth_user_name ||= self . voice_basic_auth_user_name
129158 voice_basic_auth_password ||= self . voice_basic_auth_password
130159 web_rtc_basic_auth_user_name ||= self . web_rtc_basic_auth_user_name
@@ -133,11 +162,14 @@ def clone_with(timeout: nil, max_retries: nil, retry_interval: nil,
133162 Configuration . new (
134163 timeout : timeout , max_retries : max_retries ,
135164 retry_interval : retry_interval , backoff_factor : backoff_factor ,
165+ retry_statuses : retry_statuses , retry_methods : retry_methods ,
136166 environment : environment , base_url : base_url ,
137167 messaging_basic_auth_user_name : messaging_basic_auth_user_name ,
138168 messaging_basic_auth_password : messaging_basic_auth_password ,
139169 two_factor_auth_basic_auth_user_name : two_factor_auth_basic_auth_user_name ,
140170 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 ,
141173 voice_basic_auth_user_name : voice_basic_auth_user_name ,
142174 voice_basic_auth_password : voice_basic_auth_password ,
143175 web_rtc_basic_auth_user_name : web_rtc_basic_auth_user_name ,
@@ -148,7 +180,9 @@ def clone_with(timeout: nil, max_retries: nil, retry_interval: nil,
148180 def create_http_client
149181 FaradayClient . new ( timeout : timeout , max_retries : max_retries ,
150182 retry_interval : retry_interval ,
151- backoff_factor : backoff_factor )
183+ backoff_factor : backoff_factor ,
184+ retry_statuses : retry_statuses ,
185+ retry_methods : retry_methods )
152186 end
153187
154188 # All the environments the SDK can run in.
@@ -157,13 +191,15 @@ def create_http_client
157191 Server ::DEFAULT => 'api.bandwidth.com' ,
158192 Server ::MESSAGINGDEFAULT => 'https://messaging.bandwidth.com/api/v2' ,
159193 Server ::TWOFACTORAUTHDEFAULT => 'https://mfa.bandwidth.com/api/v1' ,
194+ Server ::PHONENUMBERLOOKUPDEFAULT => 'https://numbers.bandwidth.com/api/v1' ,
160195 Server ::VOICEDEFAULT => 'https://voice.bandwidth.com' ,
161196 Server ::WEBRTCDEFAULT => 'https://api.webrtc.bandwidth.com/v1'
162197 } ,
163198 Environment ::CUSTOM => {
164199 Server ::DEFAULT => '{base_url}' ,
165200 Server ::MESSAGINGDEFAULT => '{base_url}' ,
166201 Server ::TWOFACTORAUTHDEFAULT => '{base_url}' ,
202+ Server ::PHONENUMBERLOOKUPDEFAULT => '{base_url}' ,
167203 Server ::VOICEDEFAULT => '{base_url}' ,
168204 Server ::WEBRTCDEFAULT => '{base_url}'
169205 }
0 commit comments