Class: Iterable::Push

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

Overview

Interact with /push API endpoints

Examples:

Creating push endpoint object

# With default config
templates = Iterable::Push.new
templates.target campaign_id: '12345'

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

#cancel(email: nil, campaign_id: nil, attrs: {}) ⇒ Iterable::Response

Note:

An email or UserId is required

Cancel a push notification to a specific user Must include either an email address AND campaignId, or just a scheduledMessageId provided in the attrs

Parameters:

  • email (String) (defaults to: nil)

    User email to cancel push

  • campaignId (Integer)

    campaignID used to cancel push

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

    Additional data to update or add

Returns:

[View source]

40
41
42
43
44
# File 'lib/iterable/push.rb', line 40

def cancel(email: nil, campaign_id: nil, attrs: {})
  attrs['email'] = email if email
  attrs['campaignId'] = campaign_id if campaign_id
  Iterable.request(conf, '/push/cancel').post(attrs)
end

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

Send a push notification to a specific user

Parameters:

  • email (String) (defaults to: nil)

    (optional) User email used to identify user

  • campaign_id (Integer)

    Campaign ID

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

    Additional data to update or add

Returns:

[View source]

21
22
23
24
25
# File 'lib/iterable/push.rb', line 21

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