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.
Class Attribute Summary collapse
-
.environments ⇒ Object
readonly
Returns the value of attribute environments.
Instance Attribute Summary collapse
-
#backoff_factor ⇒ Object
readonly
Returns the value of attribute backoff_factor.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#http_client ⇒ Object
readonly
The attribute readers for properties.
-
#max_retries ⇒ Object
readonly
Returns the value of attribute max_retries.
-
#messaging_basic_auth_password ⇒ Object
readonly
Returns the value of attribute messaging_basic_auth_password.
-
#messaging_basic_auth_user_name ⇒ Object
readonly
Returns the value of attribute messaging_basic_auth_user_name.
-
#retry_interval ⇒ Object
readonly
Returns the value of attribute retry_interval.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#voice_basic_auth_password ⇒ Object
readonly
Returns the value of attribute voice_basic_auth_password.
-
#voice_basic_auth_user_name ⇒ Object
readonly
Returns the value of attribute voice_basic_auth_user_name.
Instance Method Summary collapse
- #clone_with(timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, environment: nil, messaging_basic_auth_user_name: nil, messaging_basic_auth_password: nil, voice_basic_auth_user_name: nil, voice_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: 0, max_retries: 0, retry_interval: 1, backoff_factor: 1, environment: Environment::PRODUCTION, messaging_basic_auth_user_name: 'TODO: Replace', messaging_basic_auth_password: 'TODO: Replace', voice_basic_auth_user_name: 'TODO: Replace', voice_basic_auth_password: 'TODO: Replace') ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(timeout: 0, max_retries: 0, retry_interval: 1, backoff_factor: 1, environment: Environment::PRODUCTION, messaging_basic_auth_user_name: 'TODO: Replace', messaging_basic_auth_password: 'TODO: Replace', voice_basic_auth_user_name: 'TODO: Replace', voice_basic_auth_password: 'TODO: Replace') ⇒ Configuration
Returns a new instance of Configuration.
42 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 |
# File 'lib/bandwidth/configuration.rb', line 42 def initialize(timeout: 0, max_retries: 0, retry_interval: 1, backoff_factor: 1, environment: Environment::PRODUCTION, messaging_basic_auth_user_name: 'TODO: Replace', messaging_basic_auth_password: 'TODO: Replace', voice_basic_auth_user_name: 'TODO: Replace', voice_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 # Current API environment @environment = environment # 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 @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 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.
39 40 41 |
# File 'lib/bandwidth/configuration.rb', line 39 def environments @environments end |
Instance Attribute Details
#backoff_factor ⇒ Object (readonly)
Returns the value of attribute backoff_factor.
31 32 33 |
# File 'lib/bandwidth/configuration.rb', line 31 def backoff_factor @backoff_factor end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
32 33 34 |
# File 'lib/bandwidth/configuration.rb', line 32 def environment @environment end |
#http_client ⇒ Object (readonly)
The attribute readers for properties.
27 28 29 |
# File 'lib/bandwidth/configuration.rb', line 27 def http_client @http_client end |
#max_retries ⇒ Object (readonly)
Returns the value of attribute max_retries.
29 30 31 |
# File 'lib/bandwidth/configuration.rb', line 29 def max_retries @max_retries end |
#messaging_basic_auth_password ⇒ Object (readonly)
Returns the value of attribute messaging_basic_auth_password.
34 35 36 |
# File 'lib/bandwidth/configuration.rb', line 34 def messaging_basic_auth_password @messaging_basic_auth_password end |
#messaging_basic_auth_user_name ⇒ Object (readonly)
Returns the value of attribute messaging_basic_auth_user_name.
33 34 35 |
# File 'lib/bandwidth/configuration.rb', line 33 def messaging_basic_auth_user_name @messaging_basic_auth_user_name end |
#retry_interval ⇒ Object (readonly)
Returns the value of attribute retry_interval.
30 31 32 |
# File 'lib/bandwidth/configuration.rb', line 30 def retry_interval @retry_interval end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
28 29 30 |
# File 'lib/bandwidth/configuration.rb', line 28 def timeout @timeout end |
#voice_basic_auth_password ⇒ Object (readonly)
Returns the value of attribute voice_basic_auth_password.
36 37 38 |
# File 'lib/bandwidth/configuration.rb', line 36 def voice_basic_auth_password @voice_basic_auth_password end |
#voice_basic_auth_user_name ⇒ Object (readonly)
Returns the value of attribute voice_basic_auth_user_name.
35 36 37 |
# File 'lib/bandwidth/configuration.rb', line 35 def voice_basic_auth_user_name @voice_basic_auth_user_name end |
Instance Method Details
#clone_with(timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, environment: nil, messaging_basic_auth_user_name: nil, messaging_basic_auth_password: nil, voice_basic_auth_user_name: nil, voice_basic_auth_password: nil) ⇒ Object
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 |
# File 'lib/bandwidth/configuration.rb', line 80 def clone_with(timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, environment: nil, messaging_basic_auth_user_name: nil, messaging_basic_auth_password: nil, voice_basic_auth_user_name: nil, voice_basic_auth_password: nil) timeout ||= self.timeout max_retries ||= self.max_retries retry_interval ||= self.retry_interval backoff_factor ||= self.backoff_factor environment ||= self.environment messaging_basic_auth_user_name ||= self.messaging_basic_auth_user_name messaging_basic_auth_password ||= self.messaging_basic_auth_password voice_basic_auth_user_name ||= self.voice_basic_auth_user_name voice_basic_auth_password ||= self.voice_basic_auth_password Configuration.new( timeout: timeout, max_retries: max_retries, retry_interval: retry_interval, backoff_factor: backoff_factor, environment: environment, messaging_basic_auth_user_name: messaging_basic_auth_user_name, messaging_basic_auth_password: messaging_basic_auth_password, voice_basic_auth_user_name: voice_basic_auth_user_name, voice_basic_auth_password: voice_basic_auth_password ) end |
#create_http_client ⇒ Object
107 108 109 110 111 |
# File 'lib/bandwidth/configuration.rb', line 107 def create_http_client FaradayClient.new(timeout: timeout, max_retries: max_retries, retry_interval: retry_interval, backoff_factor: backoff_factor) end |
#get_base_uri(server = Server::DEFAULT) ⇒ String
Generates the appropriate base URI for the environment and the server. required.
126 127 128 |
# File 'lib/bandwidth/configuration.rb', line 126 def get_base_uri(server = Server::DEFAULT) self.class.environments[environment][server].clone end |