class Taric::Client

Constants

REGION_ENDPOINT_INFO
REGION_ENDPOINT_STRING_KEYS

Attributes

api_key[R]
config[R]
conn[R]
region[R]

Public Class Methods

expand_template(region:, operation:, options: {}) click to toggle source

Expands operation template with api_key, region, and option values.

@param api_key [String] rito api key @param region [Symbol] key for region @param operation [Addressable::Template] URI template for operation @param options [Hash] optional, values for template @return [String] of expanded template

@example

Taric::Client.expand_template(api_key: 'ritokey', region: :na, operation: Taric::Operation::Champion::CHAMPIONS)
# File lib/taric/client.rb, line 75
def expand_template(region:, operation:, options: {})
  operation.expand(options.merge(operation_values(region: region)))
end
new(api_key:, region:, config:) click to toggle source

New instance of Taric::Client.

@param api_key [String] rito api key @param region [Symbol] region code @param config [Configuration] configuration

# File lib/taric/client.rb, line 32
def initialize(api_key:, region:, config:) #requestor:, response_handler:)
  raise ArgumentError, 'api_key cannot be nil' if api_key.nil?
  raise ArgumentError, 'region cannot be nil' if region.nil?
  raise ArgumentError, "#{region} is not a valid region, #{REGION_ENDPOINT_STRING_KEYS}" if REGION_ENDPOINT_INFO[region].nil?
  @api_key = api_key
  @region = region
  @config = config
  @conn = connection(config)
  # @requestor = requestor
  # @response_handler = response_handler
end
operation_values(region:) click to toggle source

@note Memoized

Sets up and returns hash of api key and region values.

@param api_key [String] rito api key @param region [Symbol] key for region @return [Hash] of api_key and region info

# File lib/taric/client.rb, line 60
def operation_values(region:)
  REGION_ENDPOINT_INFO[region]
end

Public Instance Methods

in_parallel() click to toggle source

Returns a ParallelClient that will execute operations in parallel. @return [ParallelClient]

# File lib/taric/client.rb, line 46
def in_parallel
  ParallelClient.new(self)
end

Private Instance Methods

response_for(operation, options = {}) click to toggle source
# File lib/taric/client.rb, line 81
def response_for(operation, options = {})
  -> (method, url, body, headers) {
    API_CALL.(method, url, body, headers, @config.requestor.(@conn), @config.response_handler)
  }.(
      operation.method,
      self.class.expand_template(
          region: @region,
          operation: operation.template_url,
          options: options
      ),
      operation.body,
      operation.headers.merge('X-Riot-Token' => @api_key))
end