Sha256: 133861b5992ab40a236a3224baf04e8dd00d66f94d2266b13a04bbc0ac03c845

Contents?: true

Size: 808 Bytes

Versions: 2

Compression:

Stored size: 808 Bytes

Contents

require_relative 'operation/api'
require 'memoist'
module Taric
  class Client
    include Taric::Operation::API

    def initialize(api_key, region, requestor, response_handler)
      @api_key = api_key
      @region = region
      @requestor = requestor
      @response_handler = response_handler
    end

    def expand_template(operation, options = {})
      operation.expand(options.merge(self.class.operation_values(@api_key, @region)))
    end

    private
    def response_for(operation, options = {})
      RESPONSE.(expand_template(operation, options), @requestor, @response_handler)
    end

    class << self
      extend Memoist
      def operation_values(api_key, region)
        {api_key: api_key}.merge!(Taric::Operation::API::REGION_ENDPOINT_INFO[region]).freeze
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
taric-0.1.2 lib/taric/client.rb
taric-0.1.1 lib/taric/client.rb