Class: Lifecycle::Client
- Inherits:
-
Object
- Object
- Lifecycle::Client
- Defined in:
- lib/lifecycle_api/lifecycle.rb
Instance Method Summary collapse
- #identify(params) ⇒ Object
-
#initialize(api_key = :api_key) ⇒ Client
constructor
A new instance of Client.
- #track(event_id, unique_id) ⇒ Object
Constructor Details
#initialize(api_key = :api_key) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/lifecycle_api/lifecycle.rb', line 10 def initialize(api_key = :api_key) # Merge the config values from the module and those passed # to the client. = Lifecycle..merge(:api_key => api_key) # Copy the merged values to this client and ignore those # not part of our configuration Configuration::VALID_CONFIG_KEYS.each do |key| send("#{key}=", [key]) end end |
Instance Method Details
#identify(params) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/lifecycle_api/lifecycle.rb', line 21 def identify(params) # response = Unirest.post "http://lifecycle.io/v1/identify", response = Unirest.post "https://api.lifecycle.io/v1/identify", headers:{ "Content-Type" => "application/json", "lifecycle-api-key" => self.api_key }, parameters: params response.code # Status code response.headers # Response headers response.body # Parsed body response.raw_body # Unparsed body return response #dealing with this return is not in the documentation end |
#track(event_id, unique_id) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/lifecycle_api/lifecycle.rb', line 32 def track(event_id, unique_id) # response = Unirest.post "http://lifecycle.io/v1/track", response = Unirest.post "https://api.lifecycle.io/v1/track", headers:{ "Content-Type" => "application/json", "lifecycle-api-key" => self.api_key }, parameters: { :event_id => event_id, :unique_id => unique_id }.to_json response.code # Status code response.headers # Response headers response.body # Parsed body response.raw_body # Unparsed body return response #dealing with this return is not in the documentation end |