Class: SimpleKM::Client
- Inherits:
-
Object
- Object
- SimpleKM::Client
- Defined in:
- lib/simple_km/client.rb
Constant Summary collapse
- DEFAULT_URI_PARAMS =
{ scheme: "https", host: "trk.kissmetrics.com", path: "e" }
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#user_identifier ⇒ Object
readonly
Returns the value of attribute user_identifier.
Instance Method Summary collapse
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
- #record(action, data) ⇒ Object
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 |
# File 'lib/simple_km/client.rb', line 10 def initialize @api_key = [:api_key] @user_identifier = [:user_identifier] raise ArgumentError unless api_key && user_identifier end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/simple_km/client.rb', line 8 def api_key @api_key end |
#user_identifier ⇒ Object (readonly)
Returns the value of attribute user_identifier.
8 9 10 |
# File 'lib/simple_km/client.rb', line 8 def user_identifier @user_identifier end |
Instance Method Details
#record(action, data) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/simple_km/client.rb', line 17 def record action, data data ||= {} raise ArgumentError unless data.is_a?(Hash) query_values = { _k: api_key, _p: user_identifier, _n: action, }.merge(data) uri = Addressable::URI.new(DEFAULT_URI_PARAMS.merge(query_values: query_values)) HTTParty.get(uri.to_s) end |