simple_spark 1.0.8 → 1.0.9

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
  SHA256:
3
- metadata.gz: cbdf85242494fe095cb7ce40c9e6c2ef485c079c2ff6dd306e0446c3f5b4f7a5
4
- data.tar.gz: 43e97d881ece27eded5f6166ed8b9cdf5c716c0d23dfff99291e39149eed41d2
3
+ metadata.gz: ff21cc319280b3aa91e376df4209c374f097f8ce3a60bf4535b88de8dc58ba66
4
+ data.tar.gz: a73d02452feeebf2be58c31a4a4b459203dd008cb1c60febfe9549235e1dc78e
5
5
  SHA512:
6
- metadata.gz: bce5c2d519fe46bb10aca0eabb8043a4888ab946d74c4334a987efadca0de08b1a12fa9744c435213dbed40057c4c2993d352fc8c7b9f3837afbfb458a2bc8d5
7
- data.tar.gz: 801c0d5bfb2958a555ae45bd4de93f0941a548ae025ebe6d7b01a2214632694b6c4c1cf395c24361746b17e34a53431dd323700367e1decde23973302d43501f
6
+ metadata.gz: a08557569f6794eabe52b57ce37063192aedc2ea84604dcdcf5e7032ed0ea50b2030092cd173675d647e146eac5ea9b3406e98ab3202405888dba0dc2f11c6cf
7
+ data.tar.gz: d8a533270b9fcc2c01768a60a27260ecf11bb5a079607df40d4cd96ebf1f663851cc5265da6ef929552f118e1b09ac8574c8810821bafbd32c063f95257e1cea
data/README.md CHANGED
@@ -833,9 +833,78 @@ simple_spark.templates.delete(yourtemplateid)
833
833
 
834
834
  <a href="https://developers.sparkpost.com/api/#/reference/templates/delete" target="_blank">see SparkPost API Documentation</a>
835
835
 
836
+ ### Recipient Lists
837
+
838
+ #### List
839
+
840
+ List all recipient lists
841
+
842
+ ```ruby
843
+ simple_spark.recipient_lists.list
844
+ ```
845
+
846
+ <a href="https://developers.sparkpost.com/api/recipient-lists/#recipient-lists-get-list-all-recipient-lists" target="_blank">see SparkPost API Documentation</a>
847
+
848
+ #### Create
849
+
850
+ Create a new Recipient list
851
+
852
+ ```ruby
853
+ properties = { "name" => "Small List",
854
+ "recipients"=> [
855
+ {
856
+ "address" => {
857
+ "email" => "somemail@somedomain.com"
858
+ }
859
+ }
860
+ ]
861
+ }
862
+ num_rcpt_errors = 1
863
+ simple_spark.recipient_lists.create(properties, num_rcpt_errors)
864
+ ```
865
+
866
+ <a href="https://developers.sparkpost.com/api/recipient-lists/#recipient-lists-post-create-a-recipient-list" target="_blank">see SparkPost API Documentation</a>
867
+
868
+ #### Retrieve
869
+
870
+ Retrieves a Recipient list by its ID
871
+
872
+ ```ruby
873
+ show_recipients = true
874
+ simple_spark.recipient_lists.retrieve(your_list_id, show_recipients)
875
+ ```
876
+
877
+ <a href="https://developers.sparkpost.com/api/recipient-lists/#recipient-lists-get-retrieve-a-recipient-list" target="_blank">see SparkPost API Documentation</a>
878
+
879
+ #### Update
880
+
881
+ Updates a Recipient list with new values
882
+
883
+ ```ruby
884
+ properties = { "name" => "New List Name" }
885
+ simple_spark.recipient_lists.update(your_list_id, properties)
886
+ ```
887
+
888
+ <a href="https://developers.sparkpost.com/api/recipient-lists/#recipient-lists-put-update-a-recipient-list" target="_blank">see SparkPost API Documentation</a>
889
+
890
+ #### Delete
891
+
892
+ Deletes a Recipient list permanently
893
+
894
+ ```ruby
895
+ simple_spark.recipient_lists.delete(your_list_id)
896
+ ```
897
+
898
+ <a href="https://developers.sparkpost.com/api/recipient-lists/#recipient-lists-delete-delete-a-recipient-list" target="_blank">see SparkPost API Documentation</a>
899
+
900
+
836
901
  ## Changelog
837
902
 
838
903
 
904
+ ### 1.0.9
905
+
906
+ - Add Recipients List Endpoint
907
+
839
908
  ### 1.0.8
840
909
 
841
910
  - Add Events Endpoint
data/lib/simple_spark.rb CHANGED
@@ -10,6 +10,7 @@ require 'simple_spark/endpoints/sending_domains'
10
10
  require 'simple_spark/endpoints/message_events'
11
11
  require 'simple_spark/endpoints/events'
12
12
  require 'simple_spark/endpoints/webhooks'
13
+ require 'simple_spark/endpoints/recipient_lists'
13
14
  require 'simple_spark/endpoints/relay_webhooks'
14
15
  require 'simple_spark/endpoints/subaccounts'
15
16
  require 'simple_spark/endpoints/suppression_list'
@@ -151,5 +151,9 @@ module SimpleSpark
151
151
  def suppression_list
152
152
  Endpoints::SuppressionList.new(self)
153
153
  end
154
+
155
+ def recipient_lists
156
+ Endpoints::RecipientLists.new(self)
157
+ end
154
158
  end
155
159
  end
@@ -0,0 +1,56 @@
1
+ module SimpleSpark
2
+ module Endpoints
3
+ # Provides access to the /recipient-lists endpoint
4
+ # @note See: https://developers.sparkpost.com/api/recipient-lists
5
+ class RecipientLists
6
+ attr_accessor :client
7
+
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ # List all recipient lists
13
+ # @return [Array] an array of abbreviated recipient list objects
14
+ # @note See: https://developers.sparkpost.com/api/recipient-lists/#recipient-lists-get-list-all-recipient-lists
15
+ def list
16
+ @client.call(method: :get, path: 'recipient-lists')
17
+ end
18
+
19
+ # Create a recipient list
20
+ # @param values [Hash] the values to create the recipient list with, valid keys: [:id, :name, :description, :attributes, :recipients]
21
+ # @param num_rcpt_errors [Integer] max number of recipient errors that this call can return
22
+ # @return [Hash] details about created list
23
+ # @note See: https://developers.sparkpost.com/api/recipient-lists#recipient-lists-post-create-a-recipient-list
24
+ def create(values, num_rcpt_errors = nil)
25
+ query_params = num_rcpt_errors.nil? ? '' : "?num_rcpt_errors=#{num_rcpt_errors.to_i}"
26
+ @client.call(method: :post, path: "recipient-lists#{query_params}", body_values: values)
27
+ end
28
+
29
+ # Retrieve recipient list details
30
+ # @param id [Integer] the recipient list ID to retrieve
31
+ # @param show_recipients [Boolean] if true, return all the recipients contained in the list
32
+ # @return [Hash] details about a specified recipient list
33
+ # @note See: https://developers.sparkpost.com/api/recipient-lists/#recipient-lists-get-retrieve-a-recipient-list
34
+ def retrieve(id, show_recipients = false)
35
+ params = { show_recipients: show_recipients }.compact
36
+ @client.call(method: :get, path: "recipient-lists/#{id}", query_values: params)
37
+ end
38
+
39
+ # Update a recipient list
40
+ # @param id [Integer] the recipient list ID to update
41
+ # @param values [Hash] hash of values to update, valid keys: [:name, :description, :attributes, :recipients]
42
+ # @return [Hash] details on update operation
43
+ # @note See: https://developers.sparkpost.com/api/recipient-lists/#recipient-lists-put-update-a-recipient-list
44
+ def update(id, values)
45
+ @client.call(method: :put, path: "recipient-lists/#{id}", body_values: values)
46
+ end
47
+
48
+ # Delete a recipient list
49
+ # @param id [String] the ID
50
+ # @note See: https://developers.sparkpost.com/api/recipient-lists#recipient-lists-delete-delete-a-recipient-list
51
+ def delete(id)
52
+ @client.call(method: :delete, path: "recipient-lists/#{id}")
53
+ end
54
+ end
55
+ end
56
+ end
@@ -1,3 +1,3 @@
1
1
  module SimpleSpark
2
- VERSION = '1.0.8'
2
+ VERSION = '1.0.9'
3
3
  end
@@ -100,6 +100,10 @@ describe SimpleSpark::Client do
100
100
  specify { expect(client.webhooks.class).to eq(SimpleSpark::Endpoints::Webhooks) }
101
101
  end
102
102
 
103
+ context 'recipient_lists' do
104
+ specify { expect(client.recipient_lists.class).to eq(SimpleSpark::Endpoints::RecipientLists) }
105
+ end
106
+
103
107
  end
104
108
  end
105
109
  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: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jak Charlton
@@ -72,6 +72,7 @@ files:
72
72
  - lib/simple_spark/endpoints/inbound_domains.rb
73
73
  - lib/simple_spark/endpoints/message_events.rb
74
74
  - lib/simple_spark/endpoints/metrics.rb
75
+ - lib/simple_spark/endpoints/recipient_lists.rb
75
76
  - lib/simple_spark/endpoints/relay_webhooks.rb
76
77
  - lib/simple_spark/endpoints/sending_domains.rb
77
78
  - lib/simple_spark/endpoints/subaccounts.rb