Sha256: 27e15a9c70dc4b9598b8db635fa6022b4500ce525d9f41f0f93282b7d66eb235

Contents?: true

Size: 733 Bytes

Versions: 1

Compression:

Stored size: 733 Bytes

Contents

module Tracksale
  class Client
    attr_accessor :key
    attr_accessor :default_path
    include HTTParty
    # api.tracksale.co/v2/login
    base_uri 'http://api.tracksale.co'

    def initialize
      if Tracksale.configuration.key.nil?
        raise 'API Key not found , please configure as explained in the readme.'
      end

      @key = Tracksale.configuration.key
      @default_path = '/v2/'
    end

    def get(endpoint_path, extra_headers = {})
      headers = { 'authorization' => 'bearer ' + key }.merge(extra_headers)
      request_params = {
        headers: headers
      }
      request_params[:debug_output] = STDOUT if $DEBUG
      self.class.get(default_path + endpoint_path, request_params)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tracksale-0.0.1 lib/tracksale/client.rb