Sha256: 1dcf967c808f27f31ee06e16773898e5d99131c32e9acadab1c7f8efd9de1858
Contents?: true
Size: 1.07 KB
Versions: 4
Compression:
Stored size: 1.07 KB
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 def post(endpoint_path, body, extra_headers = {}) headers = { 'authorization' => 'bearer ' + key, 'Content-Type' => 'application/json' }.merge(extra_headers) headers[:debug_output] = STDOUT if $DEBUG endpoint = default_path + endpoint_path self.class.post(endpoint, headers: headers, body: body.to_json) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
tracksale-0.0.7 | lib/tracksale/client.rb |
tracksale-0.0.5 | lib/tracksale/client.rb |
tracksale-0.0.4 | lib/tracksale/client.rb |
tracksale-0.0.3 | lib/tracksale/client.rb |