Class: BaTesterWithCustomParameters::Configuration
- Inherits:
-
Object
- Object
- BaTesterWithCustomParameters::Configuration
- Defined in:
- lib/ba_tester_with_custom_parameters/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 => 'http://apimatic.hopto.org:{suites}', Server::AUTH_SERVER => 'http://apimaticauth.hopto.org:3000' }, Environment::TESTING => { Server::DEFAULT => 'http://localhost:3000', Server::AUTH_SERVER => 'http://apimaticauth.xhopto.org:3000' } }.freeze
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.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#retry_interval ⇒ Object
readonly
Returns the value of attribute retry_interval.
-
#suites ⇒ Object
readonly
Returns the value of attribute suites.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #clone_with(timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, environment: nil, port: nil, suites: nil, username: nil, 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: 1, environment: Environment::TESTING, port: '80', suites: SuiteCodeEnum::HEARTS, username: 'farhan', password: 'apimatic') ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 1, environment: Environment::TESTING, port: '80', suites: SuiteCodeEnum::HEARTS, username: 'farhan', password: 'apimatic') ⇒ 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 |
# File 'lib/ba_tester_with_custom_parameters/configuration.rb', line 42 def initialize(timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 1, environment: Environment::TESTING, port: '80', suites: SuiteCodeEnum::HEARTS, username: 'farhan', password: 'apimatic') # 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 = String(environment) # port value @port = port # suites value @suites = suites # TODO: Replace @username = username # TODO: Replace @password = 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/ba_tester_with_custom_parameters/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/ba_tester_with_custom_parameters/configuration.rb', line 31 def backoff_factor @backoff_factor end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
32 33 34 |
# File 'lib/ba_tester_with_custom_parameters/configuration.rb', line 32 def environment @environment end |
#http_client ⇒ Object (readonly)
The attribute readers for properties.
27 28 29 |
# File 'lib/ba_tester_with_custom_parameters/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/ba_tester_with_custom_parameters/configuration.rb', line 29 def max_retries @max_retries end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
36 37 38 |
# File 'lib/ba_tester_with_custom_parameters/configuration.rb', line 36 def password @password end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
33 34 35 |
# File 'lib/ba_tester_with_custom_parameters/configuration.rb', line 33 def port @port end |
#retry_interval ⇒ Object (readonly)
Returns the value of attribute retry_interval.
30 31 32 |
# File 'lib/ba_tester_with_custom_parameters/configuration.rb', line 30 def retry_interval @retry_interval end |
#suites ⇒ Object (readonly)
Returns the value of attribute suites.
34 35 36 |
# File 'lib/ba_tester_with_custom_parameters/configuration.rb', line 34 def suites @suites end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
28 29 30 |
# File 'lib/ba_tester_with_custom_parameters/configuration.rb', line 28 def timeout @timeout end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
35 36 37 |
# File 'lib/ba_tester_with_custom_parameters/configuration.rb', line 35 def username @username end |
Instance Method Details
#clone_with(timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, environment: nil, port: nil, suites: nil, username: nil, password: nil) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/ba_tester_with_custom_parameters/configuration.rb', line 78 def clone_with(timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, environment: nil, port: nil, suites: nil, username: nil, password: nil) timeout ||= self.timeout max_retries ||= self.max_retries retry_interval ||= self.retry_interval backoff_factor ||= self.backoff_factor environment ||= self.environment port ||= self.port suites ||= self.suites username ||= self.username password ||= self.password Configuration.new(timeout: timeout, max_retries: max_retries, retry_interval: retry_interval, backoff_factor: backoff_factor, environment: environment, port: port, suites: suites, username: username, password: password) end |
#create_http_client ⇒ Object
98 99 100 101 102 |
# File 'lib/ba_tester_with_custom_parameters/configuration.rb', line 98 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.
120 121 122 123 124 125 126 127 128 |
# File 'lib/ba_tester_with_custom_parameters/configuration.rb', line 120 def get_base_uri(server = Server::DEFAULT) parameters = { 'port' => { 'value' => port, 'encode' => false }, 'suites' => { 'value' => suites, 'encode' => false } } APIHelper.append_url_with_template_parameters( ENVIRONMENTS[environment][server], parameters ) end |