Class: Iterable::Email

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

Overview

Interact with /email API endpoints

Examples:

Creating email endpoint object

# With default config
templates = Iterable::Email.new
templates.get

# With custom config
conf = Iterable::Config.new(token: 'new-token')
templates = Iterable::Email.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

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

Target a user with an email given a campaign

Parameters:

  • email (String)

    Email of user who received the message to view

  • campaign_id (Integer)

    Campaign id to target user for

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

    Hash of attributes to pass like dataFields with the request

Returns:



41
42
43
44
45
# File 'lib/iterable/email.rb', line 41

def target(email, campaign_id, attrs = {})
  attrs[:recipientEmail] = email
  attrs[:campaignId] = campaign_id
  Iterable.request(conf, '/email/target').post(attrs)
end

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

View an email message sent

Parameters:

  • email (String)

    Email of user who received the message to view

  • message_id (String|Integer)

    Message id for message sent

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

    Hash of attributes to pass like dataFields with the requst

Returns:



24
25
26
27
28
29
30
# File 'lib/iterable/email.rb', line 24

def view(email, message_id, attrs = {})
  attrs['email'] = email
  attrs['messageId'] = message_id
  attrs.compact!

  Iterable.request(conf, '/email/viewInBrowser', attrs).get
end