Class: Anypost::Resources::Events

Inherits:
Base
  • Object
show all
Defined in:
lib/anypost/resources/events.rb

Overview

Read access to the ‘/events` stream. List-only — events are not addressable by id.

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Anypost::Resources::Base

Instance Method Details

#list(params = {}) ⇒ Object

Page through the team’s events, newest-first.

The window defaults to the last 24 hours and is clamped to the plan’s retention. Filter with ‘start`, `end`, `event_type`, `recipient`, `email_id`, `message_id`, `domain`, `topic`, `campaign`, `template_id`, and `tags` (an array, matched with hasAny).



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/anypost/resources/events.rb', line 13

def list(params = {})
  tags = params[:tags]
  paginate("/events", {
    limit: params[:limit],
    after: params[:after],
    start: params[:start],
    end: params[:end],
    event_type: params[:event_type],
    recipient: params[:recipient],
    email_id: params[:email_id],
    message_id: params[:message_id],
    domain: params[:domain],
    topic: params[:topic],
    campaign: params[:campaign],
    template_id: params[:template_id],
    # Sent comma-separated (tags=a,b); the API matches with hasAny.
    tags: (tags.is_a?(Array) && !tags.empty?) ? tags.join(",") : nil
  })
end