simple_spark 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2d4168cfad467ad86cb254fe01f6a17dcd3df92
4
- data.tar.gz: bf14dc1293c65bdf3c7a7c4858dbf9ac4fe62acf
3
+ metadata.gz: d9d658ec10ada82c8d1923eef68a5a4063529801
4
+ data.tar.gz: 2be52f459b756448defdd33174fb16099a7a96e1
5
5
  SHA512:
6
- metadata.gz: e3e3dba8c7f136987fbf9c697f608d7a8d1a748a14b663f164390179c2aab4cad6af0c8facf2ce74505d5a0d72e574eb793d3100a1bffca50de711337947cb9c
7
- data.tar.gz: 06c246a18cdc54b6a3390b5e4fad8f54a78ff6ba7f51785c2443351bb5bb9a8feb98918045890373edabfe2567a05a1b57ab8ede7ceddd72d5367cdcddd72422
6
+ metadata.gz: 636cb92b6458d45736a125179fef0cbc66eaa82c3d4fa9d25d2a44af2dc6f6da8f974e26e464a69e220723c6f958a6ccc913bb2f2cec707a5df58b33c2b9df63
7
+ data.tar.gz: e6a60ed21f086e3d44935a20aa83962601ef4460a3af923907469b0298baacb78da2d085247192d23668760e0326944c1f62aba183410554774715af0c95905a
data/README.md CHANGED
@@ -114,6 +114,39 @@ Other response status codes raise Exceptions::UnprocessableEntity
114
114
 
115
115
  In some cases it is possible to send too fast for the API (apparently) to handle , in this case the SparkPost API returns a 504 status with an empty body. This is raised by SimpleSpark as Exceptions::GatewayTimeoutExceeded
116
116
 
117
+ ### Account
118
+
119
+ #### Retrieve account information
120
+
121
+ ```ruby
122
+ simple_spark.account.retrieve
123
+ ```
124
+
125
+ The argument can be specified in a comma separated list. The only valid value is currently usage.
126
+
127
+ ```ruby
128
+ simple_spark.account.retrieve("usage")
129
+ ```
130
+
131
+ <a href="https://developers.sparkpost.com/api/#/reference/account/retrieve-get" target="_blank">see SparkPost API Documentation</a>
132
+
133
+ #### Update account information
134
+
135
+ ```ruby
136
+ properties = {
137
+ company_name: "SparkPost",
138
+ options: {
139
+ smtp_tracking_default: true,
140
+ rest_tracking_default: true,
141
+ transactional_unsub: true,
142
+ transactional_default: true
143
+ }
144
+ }
145
+ simple_spark.account.update(properties)
146
+ ```
147
+
148
+ <a href="https://developers.sparkpost.com/api/#/reference/account/update-put" target="_blank">see SparkPost API Documentation</a>
149
+
117
150
  ### Metrics
118
151
 
119
152
  #### Discoverability Links
@@ -308,6 +341,12 @@ properties[:content][:attachments] = [{ name: "attachment.txt", type: "text/plai
308
341
  simple_spark.transmissions.create(properties)
309
342
  ```
310
343
 
344
+ #### Delete by campaign
345
+
346
+ ```ruby
347
+ simple_spark.transmissions.delete_campaign("white-christmas")
348
+ ```
349
+
311
350
  <a href="https://developers.sparkpost.com/api/#/reference/transmissions/create" target="_blank">see SparkPost API Documentation</a>
312
351
 
313
352
 
@@ -599,17 +638,17 @@ simple_spark.suppression_list.create_or_update(params)
599
638
  Bulk update supression list entries
600
639
 
601
640
  ```ruby
602
- recipients = {
641
+ recipients = [
603
642
  {
604
643
  recipient: "rcpt_1@example.com",
605
- transactional: true,
644
+ type: "transactional",
606
645
  description: "User requested to not receive any transactional emails."
607
646
  },
608
647
  {
609
648
  recipient: "rcpt_2@example.com",
610
- non_transactional: true
649
+ type: "non_transactional"
611
650
  }
612
- }
651
+ ]
613
652
  simple_spark.suppression_list.create_or_update(recipients)
614
653
  ```
615
654
 
@@ -768,6 +807,12 @@ simple_spark.templates.delete(yourtemplateid)
768
807
 
769
808
  ## Changelog
770
809
 
810
+ ### 1.0.5
811
+
812
+ - Add Account API Endpoint
813
+ - Add Delete Campaign
814
+ - Bug fixes
815
+
771
816
  ### 1.0.4
772
817
 
773
818
  - Add Supression List Endpoint
@@ -104,6 +104,10 @@ module SimpleSpark
104
104
  logger
105
105
  end
106
106
 
107
+ def account
108
+ Endpoints::Account.new(self)
109
+ end
110
+
107
111
  def metrics
108
112
  Endpoints::Metrics.new(self)
109
113
  end
@@ -0,0 +1,45 @@
1
+ module SimpleSpark
2
+ module Endpoints
3
+ # Provides access to the /account endpoint
4
+ # @note See: https://developers.sparkpost.com/api/#/reference/account
5
+ class Account
6
+ attr_accessor :client
7
+
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ # Get your SparkPost account information, including subscription status and quota usage.
13
+ # @param include_values [String] Additional parts of account details to include.
14
+ # Multiple parts can be specified in a comma separated list.
15
+ # The only valid value is currently usage and by default the usage details are not included.
16
+ # @return [Hash] an account information hash object
17
+ # @note See: https://developers.sparkpost.com/api/#/reference/account/retrieve-get
18
+ def retrieve(include_values = nil)
19
+ query_params = include_values.nil? ? {} : { include: include_values }
20
+ @client.call(method: :get, path: 'account', query_values: query_params)
21
+ end
22
+
23
+ # Update your SparkPost account information and account-level options.
24
+ # @param values [Hash] Request Body Attributes
25
+ # company_name [String] company name
26
+ # options [Hash] account-level options
27
+ # smtp_tracking_default [Boolean] set to true to turn on SMTP engagement tracking by default
28
+ # rest_tracking_default [Boolean] set to false to turn off REST API engagement tracking by default
29
+ # transactional_unsub [Boolean] set to true to include List-Unsubscribe header for all transactional messages by default
30
+ # transactional_default [Boolean] set to true to send messages as transactional by default
31
+ # @return { results: { message: "Account has been updated" } }
32
+ # @note See: https://developers.sparkpost.com/api/#/reference/account/update-put
33
+ # @note Example:
34
+ # values = {
35
+ # company_name: "SparkPost",
36
+ # options: {
37
+ # smtp_tracking_default: true
38
+ # }
39
+ # }
40
+ def update(values = {})
41
+ @client.call(method: :put, path: 'account', body_values: values)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -52,6 +52,14 @@ module SimpleSpark
52
52
  query_params[:template_id] = template_id if template_id
53
53
  @client.call(method: :get, path: 'transmissions', query_values: query_params)
54
54
  end
55
+
56
+ # Deletes all transmissions for a given campaign
57
+ # @param campaign_id [String] specifies the campaign to delete transmissions for
58
+ # @returns empty string
59
+ # @note Endpoint returns empty response body with 204 status code
60
+ def delete_campaign(campaign_id)
61
+ @client.call(method: :delete, path: 'transmissions', query_values: { campaign_id: campaign_id })
62
+ end
55
63
 
56
64
  # send_message to be reserved as a 'quick' helper method to avoid using hash for Create
57
65
  # alias_method :send_message, :create
@@ -1,3 +1,3 @@
1
1
  module SimpleSpark
2
- VERSION = '1.0.4'
2
+ VERSION = '1.0.5'
3
3
  end
data/lib/simple_spark.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'simple_spark/version'
2
2
  require 'simple_spark/client'
3
3
  require 'simple_spark/exceptions'
4
+ require 'simple_spark/endpoints/account'
4
5
  require 'simple_spark/endpoints/metrics'
5
6
  require 'simple_spark/endpoints/transmissions'
6
7
  require 'simple_spark/endpoints/templates'
@@ -56,6 +56,10 @@ describe SimpleSpark::Client do
56
56
  context 'endpoints' do
57
57
  let(:client) { SimpleSpark::Client.new(api_key: 'mykey') }
58
58
 
59
+ context 'account' do
60
+ specify { expect(client.account.class).to eq(SimpleSpark::Endpoints::Account) }
61
+ end
62
+
59
63
  context 'metrics' do
60
64
  specify { expect(client.metrics.class).to eq(SimpleSpark::Endpoints::Metrics) }
61
65
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_spark
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jak Charlton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-02 00:00:00.000000000 Z
11
+ date: 2017-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -67,6 +67,7 @@ files:
67
67
  - Rakefile
68
68
  - lib/simple_spark.rb
69
69
  - lib/simple_spark/client.rb
70
+ - lib/simple_spark/endpoints/account.rb
70
71
  - lib/simple_spark/endpoints/inbound_domains.rb
71
72
  - lib/simple_spark/endpoints/message_events.rb
72
73
  - lib/simple_spark/endpoints/metrics.rb
@@ -103,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
104
  version: '0'
104
105
  requirements: []
105
106
  rubyforge_project:
106
- rubygems_version: 2.2.2
107
+ rubygems_version: 2.6.7
107
108
  signing_key:
108
109
  specification_version: 4
109
110
  summary: A library for accessing the SparkPost REST API http://www.sparkpost.com