Class: Iterable::InApp

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

Overview

Interact with /inApp API endpoints

Examples:

Creating in app endpoint object

# With default config
in_app = Iterable::InApp.new

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

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

Note:

An email or UserId is required

Cancel an In App notification sent 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:


74
75
76
77
78
# File 'lib/iterable/in_app.rb', line 74

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

#messages_for_email(email, count: 1, **attrs) ⇒ Iterable::Response

Get in-app messages for a user by email

Parameters:

  • email (String)

    required Email of user who received the message to view. Required if no user_id present.

  • count (Integer) (defaults to: 1)

    Number of messages to return, defaults to 1

  • attrs (Hash)

    Hash of query attributes like platform, SDKVersion, etc.

Returns:


23
24
25
26
27
# File 'lib/iterable/in_app.rb', line 23

def messages_for_email(email, count: 1, **attrs)
  attrs[:email] = email
  attrs[:count] = count
  messages(attrs)
end

#messages_for_user_id(user_id, count: 1, **attrs) ⇒ Iterable::Response

Get in-app messages for a user by user_id

Parameters:

  • email (String)

    required Email of user who received the message to view. Required if no user_id present.

  • count (Integer) (defaults to: 1)

    Number of messages to return, defaults to 1

  • attrs (Hash)

    Hash of query attributes like platform, SDKVersion, etc.

Returns:


38
39
40
41
42
# File 'lib/iterable/in_app.rb', line 38

def messages_for_user_id(user_id, count: 1, **attrs)
  attrs[:userId] = user_id
  attrs[:count] = count
  messages(attrs)
end

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

Send an In-App notification to a specific user. User Email or ID along with campaign ID must be provided

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:


55
56
57
58
59
# File 'lib/iterable/in_app.rb', line 55

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