struct Mailjet::Statcounters

Overview

Get aggregated statistics for a specific campaign, list, API Key or sender email address. Both message-based and event-based stats can be retrieved.

https://dev.mailjet.com/email/reference/statistics#v3_get_statcounters

Defined in:

mailjet/resources/statcounters.cr

Class Method Summary

Instance methods inherited from struct Mailjet::Resource

initialize initialize

Constructor methods inherited from struct Mailjet::Resource

new new

Class Method Detail

def self.all(query : Hash | NamedTuple = Hash(String, String).new, params : Hash | NamedTuple = Hash(String, String).new, client : Client = Client.new) #

Raw statcounter endpoint, requiring a series of parameters

response = Mailjet::Statcounters.all({
  counter_source:     "apikey",
  counter_timing:     "message",
  counter_resolution: "lifetime",
})
stats = response.data.first

[View source]
def self.by_api_key(query : Hash | NamedTuple, client : Client = Client.new) #

Convenience method to retrieve statistics at current API key level

response = Mailjet::Statcounters.by_api_key({
  counter_timing:     "event",
  counter_resolution: "hour",
  from_ts:            Time.local.at_beginning_of_week.to_unix,
  to_ts:              Time.local.to_unix,
})
stats = response.data.first

[View source]
def self.by_campaign(campaign_id : Int32 | String, query : Hash | NamedTuple, client : Client = Client.new) #

Convenience method to retrieve statistics at campaign level

response = Mailjet::Statcounters.by_campaign(123456, {
  counter_timing:     "event",
  counter_resolution: "day",
  from_ts:            Time.local.at_beginning_of_day.to_unix,
  to_ts:              Time.local.to_unix,
})
stats = response.data.first

[View source]
def self.by_list(list_id : Int32 | String, client : Client = Client.new) #

Convenience method to retrieve statistics at list level

response = Mailjet::Statcounters.by_list(123456)
stats = response.data.first

[View source]
def self.by_sender(sender_id : Int32 | String, query : Hash | NamedTuple = Hash(String, String).new, client : Client = Client.new) #

Convenience method to retrieve statistics at sender level

response = Mailjet::Statcounters.by_sender(123456, {
  counter_resolution: "lifetime",
})
stats = response.data.first

[View source]