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) ⇒ Iterable::Response

Get all events for a user by email

Parameters:

  • email (String)

    Email of user to find events for

  • limit (Integer) (defaults to: 30)

    Limit of events to return, max 200 default 30

Returns:



23
24
25
# File 'lib/iterable/events.rb', line 23

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

#track(name, email = nil, attrs = {}) ⇒ Iterable::Response

Track an event

Parameters:

  • name (String)

    Required name of event

  • email (String) (defaults to: nil)

    Email of user to track event for

  • attrs (Hash) (defaults to: {})

    Event values and fields to include

Returns:



36
37
38
39
40
# File 'lib/iterable/events.rb', line 36

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

#track_push_open(campaign_id, message_id, email, attrs = {}) ⇒ Iterable::Response

Track an event

Parameters:

  • campaign_id (String)

    Campaign ID of the push event to track

  • message_id (String)

    Message ID of the push event to track

  • email (String)

    Email of user to track push event for

  • attrs (Hash) (defaults to: {})

    Event values and fields to include

Returns:



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

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