Class: SimpleSpark::Endpoints::Metrics

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_spark/endpoints/metrics.rb

Overview

Provides access to the /metrics endpoint

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Metrics

Returns a new instance of Metrics.



8
9
10
# File 'lib/simple_spark/endpoints/metrics.rb', line 8

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



6
7
8
# File 'lib/simple_spark/endpoints/metrics.rb', line 6

def client
  @client
end

Instance Method Details

#deliverability_metrics_by_campaign(values) ⇒ Array

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

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’)

Deliverability Metrics By Campaign

Parameters:

  • values (Hash)

    the values to query with

Returns:

  • (Array)

    containg Metrics results i.e. { “count_accepted”: 66, “campaign_id”: “Summer Sale” }



62
63
64
65
# 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) ⇒ Array

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

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’)

Deliverability Metrics By Domain

Parameters:

  • values (Hash)

    the values to query with

Returns:

  • (Array)

    containg Metrics results i.e. { “count_accepted”: 66, “domain”: “gmail.com” }



38
39
40
41
# 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) ⇒ Array

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

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’)

Deliverability Metrics By Sending Domain

Parameters:

  • values (Hash)

    the values to query with

Returns:

  • (Array)

    containg Metrics results i.e. { “count_accepted”: 66, “sending_domain”: “gmail.com” }



50
51
52
53
# 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) ⇒ Array

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

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’)

Deliverability Metrics By Subaccount

Parameters:

  • values (Hash)

    the values to query with

Returns:

  • (Array)

    containg Metrics results i.e. { “count_accepted”: 66, “subaccount_id”: “acc123” }



74
75
76
77
# 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) ⇒ Array

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

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’)

Deliverability Metrics By Template

Parameters:

  • values (Hash)

    the values to query with

Returns:

  • (Array)

    containg Metrics results i.e. { “count_accepted”: 66, “template”: “My Template” }



86
87
88
89
# 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) ⇒ Hash

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

Note:

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

Deliverability Metrics Summary

Parameters:

  • values (Hash)

    the values to query with

Returns:

  • (Hash)

    containg a Metrics hash, the ‘results’ key will contain the metrics, the ‘links’ key will contain discoverability links



26
27
28
29
# 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) ⇒ Array

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

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’)

Time Series

Parameters:

  • values (Hash)

    the values to query with

Returns:

  • (Array)

    containg Metrics results with time stamps i.e. [“ts”=>“2011-06-01T00:00:00+00:00”]



98
99
100
101
# 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

The Metrics API is designed for discoverability of child links. Calling the API root displays a list of URIs that exists within the Metrics API.

Returns:

  • (Hash)

    containg a Metrics hash, the ‘links’ key will contain the links



15
16
17
# File 'lib/simple_spark/endpoints/metrics.rb', line 15

def discoverability_links
  @client.call(method: :get, path: 'metrics', extract_results: false)
end