Class: Iterable::Events

Inherits:
ApiResource show all
Defined in:
lib/iterable/events.rb

Overview

Interact with /events API endpoints

Examples:

Creating events endpoint object

# With default config
campaigns = Iterable::Events.new
campaigns.all

# With custom config
conf = Iterable::Config.new(token: 'new-token')
campaigns = Iterable::Events.new(config)

Instance Attribute Summary

Attributes inherited from ApiResource

#conf

Instance Method Summary collapse

Methods inherited from ApiResource

#default_config, default_config, #initialize

Constructor Details

This class inherits a constructor from Iterable::ApiResource

Instance Method Details

#for_email(email, limit = 30) ⇒ Object



31
32
33
# File 'lib/iterable/events.rb', line 31

def for_email(email, limit = 30)
  Iterable.request(conf, "/events/#{email}", limit: limit).get
end

#track(name, email = nil, attrs = {}) ⇒ Object



51
52
53
54
55
# File 'lib/iterable/events.rb', line 51

def track(name, email = nil, attrs = {})
  attrs[:eventName] = name
  attrs[:email] = email
  Iterable.request(conf, '/events/track').post(attrs)
end

#track_bulk(events = []) ⇒ Object



67
68
69
# File 'lib/iterable/events.rb', line 67

def track_bulk(events = [])
  Iterable.request(conf, '/events/trackBulk').post(events: events)
end

#track_push_open(campaign_id, message_id, email, attrs = {}) ⇒ Object



89
90
91
92
93
94
# File 'lib/iterable/events.rb', line 89

def track_push_open(campaign_id, message_id, email, attrs = {})
  attrs[:campaignId] = campaign_id
  attrs[:messageId] = message_id
  attrs[:email] = email
  Iterable.request(conf, '/events/trackPushOpen').post(attrs)
end