simple_spark 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48f67a4d104d2173d2e603bf2408f0e487c5a7fa
4
- data.tar.gz: 558790542ce8eaa9de855a100551687cc6cd5d69
3
+ metadata.gz: 9fbe341a22eda0d04e959f2c63bdb11aaed0c063
4
+ data.tar.gz: 9c051cede4440b5e40de0e249e213f48d12d0651
5
5
  SHA512:
6
- metadata.gz: e9cdf1aeddc939693f6cd34be0712a890ef0810301cdb69b7ed910d9ce2d5c8c1f5e8e4461620e057ec0dd1c805ad8426491cb787d6c7a3e4ebc99aaabd4524c
7
- data.tar.gz: 9dc6f8b0cb0e29cf1a1b7fbf1aede1cbb30d9a7f812e454cced9eef79ecb63255649e981af413a65da5e96e303164eaba9c3ac1632005b0de737c348189aa879
6
+ metadata.gz: 2f0264a5ee16bae3a0ea08b3af30627672dd6eaeb448b1820b3799c0589828a29a4a26bbe4fdd47661eab9b7106060c5b510fa80f7e18334348404d69125fb57
7
+ data.tar.gz: 6cdd94b5f13ce42d1467e614712e9d9fc7daa0325b12c9405ec208bcfe275c3fc35ba067b48cbddf3c50bf4989314893cd035986ee1f36553248843d46b99084
data/README.md CHANGED
@@ -193,6 +193,28 @@ simple_spark.metrics.deliverability_metrics_by_template(properties)
193
193
 
194
194
  <a href="https://developers.sparkpost.com/api/#/reference/metrics/deliverability-metrics/deliverability-metrics-by-template" target="_blank">see SparkPost API Documentation</a>
195
195
 
196
+ #### Deliverability Metrics as Time Series
197
+
198
+ Metrics across a Time Series
199
+
200
+ ```ruby
201
+ properties = {
202
+ from: '2013-04-20T07:12',
203
+ to: '2018-04-20T07:12',
204
+ metrics: 'count_accepted',
205
+ timezone: 'America/New_York',
206
+ precision: 'day'
207
+ }
208
+ simple_spark.metrics.deliverability_time_series(properties)
209
+ ```
210
+
211
+ Returns an array of metrics with time stamps:
212
+
213
+ ```ruby
214
+ [{ "count_targeted"=>2, "ts"=>"2011-06-01T00:00:00+00:00" }, { "count_targeted"=>3, "ts"=>"2011-06-02T00:00:00+00:00" }]
215
+ ```
216
+
217
+ <a href="https://developers.sparkpost.com/api/#/reference/metrics/time-series/time-series-metrics" target="_blank">see SparkPost API Documentation</a>
196
218
 
197
219
  ### Transmissions
198
220
 
@@ -666,6 +688,10 @@ simple_spark.templates.delete(yourtemplateid)
666
688
 
667
689
  ## Changelog
668
690
 
691
+ ### 0.0.7
692
+
693
+ Added Time Series to Metrics
694
+
669
695
  ### 0.0.6
670
696
 
671
697
  Fixed accidental bug
@@ -18,69 +18,93 @@ module SimpleSpark
18
18
 
19
19
  # Deliverability Metrics Summary
20
20
  # @param values [Hash] the values to query with
21
- # @note dates from and to should be converted using strftime('%Y-%m-%dT%H:%M')
21
+ # @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
22
22
  # @return [Hash] containg a Metrics hash, the 'results' key will contain the metrics, the 'links' key will contain discoverability links
23
23
  # @note Example:
24
24
  # client.metrics.deliverability_metrics_summary(from: '2013-04-20T07:12', to: '2018-04-20T07:12', metrics: 'count_accepted', timezone: 'America/New_York')
25
25
  # @note See: https://developers.sparkpost.com/api/#/reference/metrics/discoverability-links/deliverability-metrics-summary
26
26
  def deliverability_metrics_summary(values)
27
+ format_date_time_values(values)
27
28
  @client.call(method: :get, path: 'metrics/deliverability', query_values: values, extract_results: false)
28
29
  end
29
30
 
30
31
  # Deliverability Metrics By Domain
31
32
  # @param values [Hash] the values to query with
32
- # @note dates from and to should be converted using strftime('%Y-%m-%dT%H:%M')
33
+ # @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
33
34
  # @return [Array] containg Metrics results i.e. { "count_accepted": 66, "domain": "gmail.com" }
34
35
  # @note Example:
35
36
  # 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')
36
37
  # @note See: https://developers.sparkpost.com/api/#/reference/metrics/deliverability-metrics/deliverability-metrics-by-domain
37
38
  def deliverability_metrics_by_domain(values)
39
+ format_date_time_values(values)
38
40
  @client.call(method: :get, path: 'metrics/deliverability/domain', query_values: values)
39
41
  end
40
42
 
41
43
  # Deliverability Metrics By Sending Domain
42
44
  # @param values [Hash] the values to query with
43
- # @note dates from and to should be converted using strftime('%Y-%m-%dT%H:%M')
45
+ # @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
44
46
  # @return [Array] containg Metrics results i.e. { "count_accepted": 66, "sending_domain": "gmail.com" }
45
47
  # @note Example:
46
48
  # 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')
47
49
  # @note See: https://developers.sparkpost.com/api/#/reference/metrics/deliverability-metrics/deliverability-metrics-by-sending-domain
48
50
  def deliverability_metrics_by_sending_domain(values)
51
+ format_date_time_values(values)
49
52
  @client.call(method: :get, path: 'metrics/deliverability/sending-domain', query_values: values)
50
53
  end
51
54
 
52
55
  # Deliverability Metrics By Campaign
53
56
  # @param values [Hash] the values to query with
54
- # @note dates from and to should be converted using strftime('%Y-%m-%dT%H:%M')
57
+ # @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
55
58
  # @return [Array] containg Metrics results i.e. { "count_accepted": 66, "campaign_id": "Summer Sale" }
56
59
  # @note Example:
57
60
  # 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')
58
61
  # @note See: https://developers.sparkpost.com/api/#/reference/metrics/deliverability-metrics/deliverability-metrics-by-campaign
59
62
  def deliverability_metrics_by_campaign(values)
63
+ format_date_time_values(values)
60
64
  @client.call(method: :get, path: 'metrics/deliverability/campaign', query_values: values)
61
65
  end
62
66
 
63
67
  # Deliverability Metrics By Subaccount
64
68
  # @param values [Hash] the values to query with
65
- # @note dates from and to should be converted using strftime('%Y-%m-%dT%H:%M')
69
+ # @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
66
70
  # @return [Array] containg Metrics results i.e. { "count_accepted": 66, "subaccount_id": "acc123" }
67
71
  # @note Example:
68
72
  # 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')
69
73
  # @note See: https://developers.sparkpost.com/api/#/reference/metrics/deliverability-metrics/deliverability-metrics-by-subaccount
70
74
  def deliverability_metrics_by_subaccount(values)
75
+ format_date_time_values(values)
71
76
  @client.call(method: :get, path: 'metrics/deliverability/subaccount', query_values: values)
72
77
  end
73
78
 
74
79
  # Deliverability Metrics By Template
75
80
  # @param values [Hash] the values to query with
76
- # @note dates from and to should be converted using strftime('%Y-%m-%dT%H:%M')
81
+ # @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
77
82
  # @return [Array] containg Metrics results i.e. { "count_accepted": 66, "template": "My Template" }
78
83
  # @note Example:
79
84
  # 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')
80
85
  # @note See: https://developers.sparkpost.com/api/#/reference/metrics/deliverability-metrics/deliverability-metrics-by-template
81
86
  def deliverability_metrics_by_template(values)
87
+ format_date_time_values(values)
82
88
  @client.call(method: :get, path: 'metrics/deliverability/template', query_values: values)
83
89
  end
90
+
91
+ # Time Series
92
+ # @param values [Hash] the values to query with
93
+ # @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
94
+ # @return [Array] containg Metrics results with time stamps i.e. [{"count_targeted"=>0, "ts"=>"2011-06-01T00:00:00+00:00"}]
95
+ # @note Example:
96
+ # client.metrics.deliverability_time_series(from: '2013-04-20T07:12', to: '2018-04-20T07:12', metrics: 'count_accepted', timezone: 'America/New_York', precision: 'day')
97
+ # @note See: https://developers.sparkpost.com/api/#/reference/metrics/time-series/time-series-metrics
98
+ def deliverability_time_series(values)
99
+ format_date_time_values(values)
100
+ @client.call(method: :get, path: 'metrics/deliverability/time-series', query_values: values)
101
+ end
102
+
103
+ private
104
+
105
+ def format_date_time_values(values)
106
+ values.keys.each { |k| values[k] = values[k].strftime('%Y-%m-%dT%H:%M') if values[k].respond_to?(:strftime) }
107
+ end
84
108
  end
85
109
  end
86
110
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleSpark
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_spark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jak Charlton