class Bandwidth::Configuration
All configuration including auth info and base URI for the API access are configured in this class.
Constants
- ENVIRONMENTS
All the environments the SDK can run in.
Attributes
environments[R]
backoff_factor[R]
base_url[R]
environment[R]
http_client[R]
The attribute readers for properties.
max_retries[R]
messaging_basic_auth_password[R]
messaging_basic_auth_user_name[R]
multi_factor_auth_basic_auth_password[R]
multi_factor_auth_basic_auth_user_name[R]
phone_number_lookup_basic_auth_password[R]
phone_number_lookup_basic_auth_user_name[R]
retry_interval[R]
retry_methods[R]
retry_statuses[R]
timeout[R]
voice_basic_auth_password[R]
voice_basic_auth_user_name[R]
web_rtc_basic_auth_password[R]
web_rtc_basic_auth_user_name[R]
Public Class Methods
new(timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put get put], environment: Environment::PRODUCTION, base_url: 'https://www.example.com', messaging_basic_auth_user_name: 'TODO: Replace', messaging_basic_auth_password: 'TODO: Replace', multi_factor_auth_basic_auth_user_name: 'TODO: Replace', multi_factor_auth_basic_auth_password: 'TODO: Replace', phone_number_lookup_basic_auth_user_name: 'TODO: Replace', phone_number_lookup_basic_auth_password: 'TODO: Replace', voice_basic_auth_user_name: 'TODO: Replace', voice_basic_auth_password: 'TODO: Replace', web_rtc_basic_auth_user_name: 'TODO: Replace', web_rtc_basic_auth_password: 'TODO: Replace')
click to toggle source
# File lib/bandwidth/configuration.rb, line 55 def initialize(timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put get put], environment: Environment::PRODUCTION, base_url: 'https://www.example.com', messaging_basic_auth_user_name: 'TODO: Replace', messaging_basic_auth_password: 'TODO: Replace', multi_factor_auth_basic_auth_user_name: 'TODO: Replace', multi_factor_auth_basic_auth_password: 'TODO: Replace', phone_number_lookup_basic_auth_user_name: 'TODO: Replace', phone_number_lookup_basic_auth_password: 'TODO: Replace', voice_basic_auth_user_name: 'TODO: Replace', voice_basic_auth_password: 'TODO: Replace', web_rtc_basic_auth_user_name: 'TODO: Replace', web_rtc_basic_auth_password: 'TODO: Replace') # The value to use for connection timeout @timeout = timeout # The number of times to retry an endpoint call if it fails @max_retries = max_retries # Pause in seconds between retries @retry_interval = retry_interval # The amount to multiply each successive retry's interval amount # by in order to provide backoff @backoff_factor = backoff_factor # A list of HTTP statuses to retry @retry_statuses = retry_statuses # A list of HTTP methods to retry @retry_methods = retry_methods # Current API environment @environment = String(environment) # baseUrl value @base_url = base_url # The username to use with basic authentication @messaging_basic_auth_user_name = messaging_basic_auth_user_name # The password to use with basic authentication @messaging_basic_auth_password = messaging_basic_auth_password # The username to use with basic authentication @multi_factor_auth_basic_auth_user_name = multi_factor_auth_basic_auth_user_name # The password to use with basic authentication @multi_factor_auth_basic_auth_password = multi_factor_auth_basic_auth_password # The username to use with basic authentication @phone_number_lookup_basic_auth_user_name = phone_number_lookup_basic_auth_user_name # The password to use with basic authentication @phone_number_lookup_basic_auth_password = phone_number_lookup_basic_auth_password # The username to use with basic authentication @voice_basic_auth_user_name = voice_basic_auth_user_name # The password to use with basic authentication @voice_basic_auth_password = voice_basic_auth_password # The username to use with basic authentication @web_rtc_basic_auth_user_name = web_rtc_basic_auth_user_name # The password to use with basic authentication @web_rtc_basic_auth_password = web_rtc_basic_auth_password # The Http Client to use for making requests. @http_client = create_http_client end
Public Instance Methods
clone_with(timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, retry_statuses: nil, retry_methods: nil, environment: nil, base_url: nil, messaging_basic_auth_user_name: nil, messaging_basic_auth_password: nil, multi_factor_auth_basic_auth_user_name: nil, multi_factor_auth_basic_auth_password: nil, phone_number_lookup_basic_auth_user_name: nil, phone_number_lookup_basic_auth_password: nil, voice_basic_auth_user_name: nil, voice_basic_auth_password: nil, web_rtc_basic_auth_user_name: nil, web_rtc_basic_auth_password: nil)
click to toggle source
# File lib/bandwidth/configuration.rb, line 130 def clone_with(timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, retry_statuses: nil, retry_methods: nil, environment: nil, base_url: nil, messaging_basic_auth_user_name: nil, messaging_basic_auth_password: nil, multi_factor_auth_basic_auth_user_name: nil, multi_factor_auth_basic_auth_password: nil, phone_number_lookup_basic_auth_user_name: nil, phone_number_lookup_basic_auth_password: nil, voice_basic_auth_user_name: nil, voice_basic_auth_password: nil, web_rtc_basic_auth_user_name: nil, web_rtc_basic_auth_password: nil) timeout ||= self.timeout max_retries ||= self.max_retries retry_interval ||= self.retry_interval backoff_factor ||= self.backoff_factor retry_statuses ||= self.retry_statuses retry_methods ||= self.retry_methods environment ||= self.environment base_url ||= self.base_url messaging_basic_auth_user_name ||= self.messaging_basic_auth_user_name messaging_basic_auth_password ||= self.messaging_basic_auth_password multi_factor_auth_basic_auth_user_name ||= self.multi_factor_auth_basic_auth_user_name multi_factor_auth_basic_auth_password ||= self.multi_factor_auth_basic_auth_password phone_number_lookup_basic_auth_user_name ||= self.phone_number_lookup_basic_auth_user_name phone_number_lookup_basic_auth_password ||= self.phone_number_lookup_basic_auth_password voice_basic_auth_user_name ||= self.voice_basic_auth_user_name voice_basic_auth_password ||= self.voice_basic_auth_password web_rtc_basic_auth_user_name ||= self.web_rtc_basic_auth_user_name web_rtc_basic_auth_password ||= self.web_rtc_basic_auth_password Configuration.new( timeout: timeout, max_retries: max_retries, retry_interval: retry_interval, backoff_factor: backoff_factor, retry_statuses: retry_statuses, retry_methods: retry_methods, environment: environment, base_url: base_url, messaging_basic_auth_user_name: messaging_basic_auth_user_name, messaging_basic_auth_password: messaging_basic_auth_password, multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name, multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password, phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name, phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password, voice_basic_auth_user_name: voice_basic_auth_user_name, voice_basic_auth_password: voice_basic_auth_password, web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name, web_rtc_basic_auth_password: web_rtc_basic_auth_password ) end
create_http_client()
click to toggle source
# File lib/bandwidth/configuration.rb, line 180 def create_http_client FaradayClient.new(timeout: timeout, max_retries: max_retries, retry_interval: retry_interval, backoff_factor: backoff_factor, retry_statuses: retry_statuses, retry_methods: retry_methods) end
get_base_uri(server = Server::DEFAULT)
click to toggle source
Generates the appropriate base URI for the environment and the server. @param [Configuration::Server] The server enum for which the base URI is required. @return [String] The base URI.
# File lib/bandwidth/configuration.rb, line 212 def get_base_uri(server = Server::DEFAULT) parameters = { 'base_url' => { 'value' => base_url, 'encode' => false } } APIHelper.append_url_with_template_parameters( ENVIRONMENTS[environment][server], parameters ) end