lib/casino_hub.rb in casino_hub-0.1.1 vs lib/casino_hub.rb in casino_hub-0.1.2
- old
+ new
@@ -1,6 +1,7 @@
require "rest-client"
+require "byebug"
require 'json'
require 'active_support/inflector'
require "casino_hub/version"
@@ -13,13 +14,14 @@
module CasinoHub
@api_version = nil
@api_base = 'https://casino.openfan.net'
@api_key = nil
+ @source = nil
class << self
- attr_accessor :api_version, :api_base, :company_token
+ attr_accessor :api_version, :api_base, :company_token, :source
def api_version=(version=1.0)
@api_version = version
end
@@ -28,10 +30,14 @@
@environment = env
if env != 'production'
@api_base = 'https://casino.openfan.net/api'
end
end
+
+ def source
+ @source ||= File.basename(Dir.getwd)
+ end
end
def self.api_url(url='', api_base_url=nil)
(api_base_url || @api_base) + url
end
@@ -44,9 +50,10 @@
headers = {
'Access-Token' => params.fetch(:company_token, company_token)
}
params.delete(:company_token)
+ params.merge!(source: @source.parameterize.underscore)
case method.to_s.downcase.to_sym
when :get, :head, :delete
# Make params into GET parameters
url += "#{URI.parse(url).query ? '&' : '?'}#{Util.encode_parameters(params)}" if params && params.any?