Class: Bandwidth::Configuration
- Inherits:
-
Object
- Object
- Bandwidth::Configuration
- Defined in:
- lib/bandwidth/configuration.rb
Overview
All configuration including auth info and base URI for the API access are configured in this class.
Constant Summary collapse
- ENVIRONMENTS =
All the environments the SDK can run in.
{ Environment::PRODUCTION => { Server::DEFAULT => 'api.bandwidth.com', Server::MESSAGINGDEFAULT => 'https://messaging.bandwidth.com/api/v2', Server::MULTIFACTORAUTHDEFAULT => 'https://mfa.bandwidth.com/api/v1', Server::PHONENUMBERLOOKUPDEFAULT => 'https://numbers.bandwidth.com/api/v1', Server::VOICEDEFAULT => 'https://voice.bandwidth.com', Server::WEBRTCDEFAULT => 'https://api.webrtc.bandwidth.com/v1' }, Environment::CUSTOM => { Server::DEFAULT => '{base_url}', Server::MESSAGINGDEFAULT => '{base_url}', Server::MULTIFACTORAUTHDEFAULT => '{base_url}', Server::PHONENUMBERLOOKUPDEFAULT => '{base_url}', Server::VOICEDEFAULT => '{base_url}', Server::WEBRTCDEFAULT => '{base_url}' } }.freeze
Class Attribute Summary collapse
-
.environments ⇒ Object
readonly
Returns the value of attribute environments.
Instance Attribute Summary collapse
-
#backoff_factor ⇒ Object
readonly
The attribute readers for properties.
-
#base_url ⇒ Object
readonly
The attribute readers for properties.
-
#environment ⇒ Object
readonly
The attribute readers for properties.
-
#http_client ⇒ Object
readonly
The attribute readers for properties.
-
#max_retries ⇒ Object
readonly
The attribute readers for properties.
-
#messaging_basic_auth_password ⇒ Object
readonly
The attribute readers for properties.
-
#messaging_basic_auth_user_name ⇒ Object
readonly
The attribute readers for properties.
-
#multi_factor_auth_basic_auth_password ⇒ Object
readonly
The attribute readers for properties.
-
#multi_factor_auth_basic_auth_user_name ⇒ Object
readonly
The attribute readers for properties.
-
#phone_number_lookup_basic_auth_password ⇒ Object
readonly
The attribute readers for properties.
-
#phone_number_lookup_basic_auth_user_name ⇒ Object
readonly
The attribute readers for properties.
-
#retry_interval ⇒ Object
readonly
The attribute readers for properties.
-
#retry_methods ⇒ Object
readonly
The attribute readers for properties.
-
#retry_statuses ⇒ Object
readonly
The attribute readers for properties.
-
#timeout ⇒ Object
readonly
The attribute readers for properties.
-
#voice_basic_auth_password ⇒ Object
readonly
The attribute readers for properties.
-
#voice_basic_auth_user_name ⇒ Object
readonly
The attribute readers for properties.
-
#web_rtc_basic_auth_password ⇒ Object
readonly
The attribute readers for properties.
-
#web_rtc_basic_auth_user_name ⇒ Object
readonly
The attribute readers for properties.
Instance Method Summary collapse
- #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) ⇒ Object
- #create_http_client ⇒ Object
-
#get_base_uri(server = Server::DEFAULT) ⇒ String
Generates the appropriate base URI for the environment and the server.
-
#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') ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#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') ⇒ Configuration
Returns a new instance of Configuration.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/bandwidth/configuration.rb', line 43 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 |
Class Attribute Details
.environments ⇒ Object (readonly)
Returns the value of attribute environments.
40 41 42 |
# File 'lib/bandwidth/configuration.rb', line 40 def environments @environments end |
Instance Attribute Details
#backoff_factor ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def backoff_factor @backoff_factor end |
#base_url ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def base_url @base_url end |
#environment ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def environment @environment end |
#http_client ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def http_client @http_client end |
#max_retries ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def max_retries @max_retries end |
#messaging_basic_auth_password ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def messaging_basic_auth_password @messaging_basic_auth_password end |
#messaging_basic_auth_user_name ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def messaging_basic_auth_user_name @messaging_basic_auth_user_name end |
#multi_factor_auth_basic_auth_password ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def multi_factor_auth_basic_auth_password @multi_factor_auth_basic_auth_password end |
#multi_factor_auth_basic_auth_user_name ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def multi_factor_auth_basic_auth_user_name @multi_factor_auth_basic_auth_user_name end |
#phone_number_lookup_basic_auth_password ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def phone_number_lookup_basic_auth_password @phone_number_lookup_basic_auth_password end |
#phone_number_lookup_basic_auth_user_name ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def phone_number_lookup_basic_auth_user_name @phone_number_lookup_basic_auth_user_name end |
#retry_interval ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def retry_interval @retry_interval end |
#retry_methods ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def retry_methods @retry_methods end |
#retry_statuses ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def retry_statuses @retry_statuses end |
#timeout ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def timeout @timeout end |
#voice_basic_auth_password ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def voice_basic_auth_password @voice_basic_auth_password end |
#voice_basic_auth_user_name ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def voice_basic_auth_user_name @voice_basic_auth_user_name end |
#web_rtc_basic_auth_password ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def web_rtc_basic_auth_password @web_rtc_basic_auth_password end |
#web_rtc_basic_auth_user_name ⇒ Object (readonly)
The attribute readers for properties.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def web_rtc_basic_auth_user_name @web_rtc_basic_auth_user_name end |
Instance Method Details
#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) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/bandwidth/configuration.rb', line 118 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 ⇒ Object
168 169 170 171 172 173 174 |
# File 'lib/bandwidth/configuration.rb', line 168 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) ⇒ String
Generates the appropriate base URI for the environment and the server. required.
200 201 202 203 204 205 206 207 |
# File 'lib/bandwidth/configuration.rb', line 200 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 |