class BaTesterWithCustomParameters::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]
environment[R]
http_client[R]

The attribute readers for properties.

max_retries[R]
password[R]
port[R]
retry_interval[R]
suites[R]
timeout[R]
username[R]

Public Class Methods

new(timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 1, environment: Environment::TESTING, port: '80', suites: SuiteCodeEnum::HEARTS, username: 'farhan', password: 'apimatic') click to toggle source
# 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

Public Instance Methods

clone_with(timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, environment: nil, port: nil, suites: nil, username: nil, password: nil) click to toggle source
# 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() click to toggle source
# 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) 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/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