Class: KlaviyoAPI::Event

Inherits:
Base
  • Object
show all
Defined in:
lib/klaviyo_api/resources/event.rb

Overview

Klaviyo has the concept of “timelines” on Metrics. A single entry in that timeline is an Event.

Constant Summary collapse

ORIGINAL_PREFIX =
'/api/v1/metric/:metric_id/'

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

activate_session, element_path, headers, reset_session, #to_h

Class Method Details

.collection_path(prefix_options = {}, query_options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/klaviyo_api/resources/event.rb', line 19

def collection_path(prefix_options = {}, query_options = {})
  # This needs to support both `metrics/timeline` and `metric/<id>/timeline,
  # through `Event.all` and `Event.all params {metric_id: <id>}`. It gets a
  # little messy.
  if prefix_options.empty?
    self.prefix = '/api/v1/metrics/'
  end

  check_prefix_options(prefix_options)

  prefix_options, query_options = split_options(prefix_options) if query_options.nil?
  query_options = query_options.deep_merge({ api_key: headers['api-key'] })

  path = "#{prefix(prefix_options)}#{collection_name}#{format_extension}#{query_string(query_options)}"

  self.prefix = ORIGINAL_PREFIX

  path
end

.find_single(scope, options) ⇒ Object



15
16
17
# File 'lib/klaviyo_api/resources/event.rb', line 15

def find_single(scope, options)
  raise KlaviyoAPI::InvalidOperation, 'Cannot get single Event via API. Please use KlaviyoAPI::Event#all.'
end

Instance Method Details

#createObject



44
45
46
# File 'lib/klaviyo_api/resources/event.rb', line 44

def create
  raise KlaviyoAPI::InvalidOperation, 'Cannot create Events via API.'
end

#destroyObject



40
41
42
# File 'lib/klaviyo_api/resources/event.rb', line 40

def destroy
  raise KlaviyoAPI::InvalidOperation, 'Cannot delete Events via API.'
end

#updateObject



48
49
50
# File 'lib/klaviyo_api/resources/event.rb', line 48

def update
  raise KlaviyoAPI::InvalidOperation, 'Cannot update Events via API.'
end