class SimpleSpark::Endpoints::Metrics

Provides access to the /metrics endpoint @note See: developers.sparkpost.com/api/#/reference/metrics

Attributes

client[RW]

Public Class Methods

new(client) click to toggle source
# File lib/simple_spark/endpoints/metrics.rb, line 8
def initialize(client)
  @client = client
end

Public Instance Methods

deliverability_metrics_by_campaign(values) click to toggle source

Deliverability Metrics By Campaign @param values [Hash] the values to query with @note dates from and need to be sent using strftime('%Y-%m-%dT%H:%M'), for convenience if provided as Time, Date or DateTime objects they will be automatically converted @return [Array] containg Metrics results i.e. { “count_accepted”: 66, “campaign_id”: “Summer Sale” } @note Example:

client.metrics.deliverability_metrics_by_campaign(from: '2013-04-20T07:12', to: '2018-04-20T07:12', metrics: 'count_accepted', timezone: 'America/New_York', campaigns: 'Summer Sale')

@note See: developers.sparkpost.com/api/#/reference/metrics/deliverability-metrics/deliverability-metrics-by-campaign

# File lib/simple_spark/endpoints/metrics.rb, line 62
def deliverability_metrics_by_campaign(values)
  format_date_time_values(values)
  @client.call(method: :get, path: 'metrics/deliverability/campaign', query_values: values)
end
deliverability_metrics_by_domain(values) click to toggle source

Deliverability Metrics By Domain @param values [Hash] the values to query with @note dates from and need to be sent using strftime('%Y-%m-%dT%H:%M'), for convenience if provided as Time, Date or DateTime objects they will be automatically converted @return [Array] containg Metrics results i.e. { “count_accepted”: 66, “domain”: “gmail.com” } @note Example:

client.metrics.deliverability_metrics_by_domain(from: '2013-04-20T07:12', to: '2018-04-20T07:12', metrics: 'count_accepted', timezone: 'America/New_York', domains: 'gmail.com')

@note See: developers.sparkpost.com/api/#/reference/metrics/deliverability-metrics/deliverability-metrics-by-domain

# File lib/simple_spark/endpoints/metrics.rb, line 38
def deliverability_metrics_by_domain(values)
  format_date_time_values(values)
  @client.call(method: :get, path: 'metrics/deliverability/domain', query_values: values)
end
deliverability_metrics_by_sending_domain(values) click to toggle source

Deliverability Metrics By Sending Domain @param values [Hash] the values to query with @note dates from and need to be sent using strftime('%Y-%m-%dT%H:%M'), for convenience if provided as Time, Date or DateTime objects they will be automatically converted @return [Array] containg Metrics results i.e. { “count_accepted”: 66, “sending_domain”: “gmail.com” } @note Example:

client.metrics.deliverability_metrics_by_sending_domain(from: '2013-04-20T07:12', to: '2018-04-20T07:12', metrics: 'count_accepted', timezone: 'America/New_York', sending_domains: 'mydomain.com')

@note See: developers.sparkpost.com/api/#/reference/metrics/deliverability-metrics/deliverability-metrics-by-sending-domain

# File lib/simple_spark/endpoints/metrics.rb, line 50
def deliverability_metrics_by_sending_domain(values)
  format_date_time_values(values)
  @client.call(method: :get, path: 'metrics/deliverability/sending-domain', query_values: values)
end
deliverability_metrics_by_subaccount(values) click to toggle source

Deliverability Metrics By Subaccount @param values [Hash] the values to query with @note dates from and need to be sent using strftime('%Y-%m-%dT%H:%M'), for convenience if provided as Time, Date or DateTime objects they will be automatically converted @return [Array] containg Metrics results i.e. { “count_accepted”: 66, “subaccount_id”: “acc123” } @note Example:

client.metrics.deliverability_metrics_by_subaccount(from: '2013-04-20T07:12', to: '2018-04-20T07:12', metrics: 'count_accepted', timezone: 'America/New_York', subaccounts: 'acc123')

@note See: developers.sparkpost.com/api/#/reference/metrics/deliverability-metrics/deliverability-metrics-by-subaccount

# File lib/simple_spark/endpoints/metrics.rb, line 74
def deliverability_metrics_by_subaccount(values)
  format_date_time_values(values)
  @client.call(method: :get, path: 'metrics/deliverability/subaccount', query_values: values)
end
deliverability_metrics_by_template(values) click to toggle source

Deliverability Metrics By Template @param values [Hash] the values to query with @note dates from and need to be sent using strftime('%Y-%m-%dT%H:%M'), for convenience if provided as Time, Date or DateTime objects they will be automatically converted @return [Array] containg Metrics results i.e. { “count_accepted”: 66, “template”: “My Template” } @note Example:

client.metrics.deliverability_metrics_by_template(from: '2013-04-20T07:12', to: '2018-04-20T07:12', metrics: 'count_accepted', timezone: 'America/New_York', subaccounts: 'acc123')

@note See: developers.sparkpost.com/api/#/reference/metrics/deliverability-metrics/deliverability-metrics-by-template

# File lib/simple_spark/endpoints/metrics.rb, line 86
def deliverability_metrics_by_template(values)
  format_date_time_values(values)
  @client.call(method: :get, path: 'metrics/deliverability/template', query_values: values)
end
deliverability_metrics_summary(values) click to toggle source

Deliverability Metrics Summary @param values [Hash] the values to query with @note dates from and need to be sent using strftime('%Y-%m-%dT%H:%M'), for convenience if provided as Time, Date or DateTime objects they will be automatically converted @return [Hash] containg a Metrics hash, the 'results' key will contain the metrics, the 'links' key will contain discoverability links @note Example:

client.metrics.deliverability_metrics_summary(from: '2013-04-20T07:12', to: '2018-04-20T07:12', metrics: 'count_accepted', timezone: 'America/New_York')

@note See: developers.sparkpost.com/api/#/reference/metrics/discoverability-links/deliverability-metrics-summary

# File lib/simple_spark/endpoints/metrics.rb, line 26
def deliverability_metrics_summary(values)
  format_date_time_values(values)
  @client.call(method: :get, path: 'metrics/deliverability', query_values: values, extract_results: false)
end
deliverability_time_series(values) click to toggle source

Time Series @param values [Hash] the values to query with @note dates from and need to be sent using strftime('%Y-%m-%dT%H:%M'), for convenience if provided as Time, Date or DateTime objects they will be automatically converted @return [Array] containg Metrics results with time stamps i.e. [{“count_targeted”=>0, “ts”=>“2011-06-01T00:00:00+00:00”}] @note Example:

client.metrics.deliverability_time_series(from: '2013-04-20T07:12', to: '2018-04-20T07:12', metrics: 'count_accepted', timezone: 'America/New_York', precision: 'day')

@note See: developers.sparkpost.com/api/#/reference/metrics/time-series/time-series-metrics

# File lib/simple_spark/endpoints/metrics.rb, line 98
def deliverability_time_series(values)
  format_date_time_values(values)
  @client.call(method: :get, path: 'metrics/deliverability/time-series', query_values: values)
end

Private Instance Methods

format_date_time_values(values) click to toggle source
# File lib/simple_spark/endpoints/metrics.rb, line 105
def format_date_time_values(values)
  values.keys.each { |k| values[k] = values[k].strftime('%Y-%m-%dT%H:%M') if values[k].respond_to?(:strftime) }
end