simple_spark 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 676d80d0849c4c6c5afda568f14191eade9233f1
4
+ data.tar.gz: 4997b6feca164a87ecc49d31919c14c96f91c8d0
5
+ SHA512:
6
+ metadata.gz: 6ce14c7ad7ef085b1b5b4e3d4f7dba76d80ac5a081175f967a4dbc0efb8fc01e18d4ca366243d9485961ab3a74f46d6a70d2314d7a33c7807893dc575166aa8f
7
+ data.tar.gz: 982fc09009aceb4fcdafb2938afc5e784d5bb0a38c78806fbebe76619372202cbe8a6a098782f2440f11f289b6718959567297a6b73b633cb4cd91eebc5dcd75
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rubocop.yml ADDED
@@ -0,0 +1,19 @@
1
+ Metrics/LineLength:
2
+ Max: 250
3
+
4
+ Metrics/MethodLength:
5
+ Max: 20
6
+
7
+ Metrics/AbcSize:
8
+ # The ABC size is a calculated magnitude, so this number can be a Fixnum or
9
+ # a Float.
10
+ Max: 25
11
+
12
+ AllCops:
13
+ Exclude:
14
+ - 'db/**/*'
15
+ - 'config/**/*'
16
+ - 'tmp/**/*'
17
+ - 'log/**/*'
18
+ - 'bin/**/*'
19
+
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ cache: bundler
3
+
4
+ rvm:
5
+ - jruby
6
+ - 2.2.0
7
+
8
+ script: 'bundle exec rake'
9
+
10
+ notifications:
11
+ email:
12
+ recipients:
13
+ - jakcharlton@gmail.com
14
+ on_failure: change
15
+ on_success: never
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sparkpost-snap.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,11 @@
1
+ guard :rspec, cmd: 'rspec' do
2
+ # watch /lib/ files
3
+ watch(%r{^lib/(.+).rb$}) do |m|
4
+ "spec/#{m[1]}_spec.rb"
5
+ end
6
+
7
+ # watch /spec/ files
8
+ watch(%r{^spec/(.+).rb$}) do |m|
9
+ "spec/#{m[1]}.rb"
10
+ end
11
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Jak Charlton
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,444 @@
1
+ # SimpleSpark
2
+
3
+ [![Build Status](https://travis-ci.org/leadmachineapp/simple_spark.png?branch=master)](https://travis-ci.org/leadmachineapp/simple_spark)
4
+
5
+ This gem is an alternative to the [official Ruby gem](https://github.com/SparkPost/ruby-sparkpost) provided by [SparkPost](http://www.sparkpost.com)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'simple_spark'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ ```
18
+ $ bundle
19
+ ```
20
+
21
+ Or install it yourself as:
22
+
23
+ ```
24
+ $ gem install simple_spark
25
+ ```
26
+ ## Usage
27
+
28
+ ### Why?
29
+
30
+ The official gem is somewhat lacking in functionality, though with the demise of Mandrill it seems SparkPost may have decided to restart development on it.
31
+
32
+ But, not being in a mood to wait, and as we would have to write wrappers around all the functions we would need anyway, it seemed much easier to write the wrapper as a gem and allow others to use it too.
33
+
34
+ The official gem currently only supports the send_message (create) method of /transmissions and it does it with a limited argument set. As it uses method parameters for each of the arguments it supports, it is not possible to use all the functionality the SparkPost API has. This gem will allow passing the parameters as hashes, allowing you to directly copy an API example into code and take full advantage of all the API functions.
35
+
36
+ ### Status
37
+
38
+ It's day one, and it's a day one project.
39
+
40
+
41
+ ## Endpoints
42
+
43
+ ### Creating a Client
44
+
45
+ First you need to ensure you are requiring the library
46
+
47
+ ```ruby
48
+ require 'simple_spark'
49
+ ```
50
+
51
+ The simplest version of the client is to just provide your [API key from SparkPost](https://app.sparkpost.com/account/credentials)
52
+
53
+ ```ruby
54
+ simple_spark = SimpleSpark::Client.new('your_api_key')
55
+ ```
56
+
57
+ You can also use ENV vars to configure the key, setting ENV['SPARKPOST_API_KEY'] will allow you to just use
58
+
59
+ ```ruby
60
+ simple_spark = SimpleSpark::Client.new
61
+ ```
62
+
63
+ You can also override the other options if you need to in advanced scenarios, the full signature is (api_key, api_host, base_path, debug), i.e.
64
+
65
+ ```ruby
66
+ simple_spark = SimpleSpark::Client.new('your_api_key', 'https://api.sparkpost.com', '/api/v1/', false)
67
+ ```
68
+
69
+ Setting debug to true will cause [Excon](https://github.com/excon/excon) to output full debug information to the log, to default the other values and just set debug, send nil values
70
+
71
+ This will default to true if you are running under Rails and are in a development environment, otherwise it will default to false (setting other values to nil will cause them to use their defaults)
72
+
73
+ ```ruby
74
+ simple_spark = SimpleSpark::Client.new(nil, nil, nil, true)
75
+ ```
76
+
77
+ ### Transmissions
78
+
79
+ #### List
80
+
81
+ List all Transmissions
82
+
83
+ When messages are sent the Transmission will be deleted, so this will only return transmissions that are about to be sent or are scheduled for the future
84
+
85
+ ```ruby
86
+ simple_spark.transmissions.list
87
+ ```
88
+
89
+ <a href="https://developers.sparkpost.com/api/#/reference/transmissions/list" target="_blank">see SparkPost API Documentation</a>
90
+
91
+ #### Create
92
+
93
+ Create a new Transmission
94
+
95
+ ```ruby
96
+ properties = {
97
+ options: { open_tracking: true, click_tracking: true },
98
+ campaign_id: 'christmas_campaign',
99
+ return_path: 'bounces-christmas-campaign@sp.neekme.com',
100
+ metadata: {user_type: 'students'},
101
+ substitution_data: { sender: 'Big Store Team' },
102
+ recipients: [
103
+ { address: { email: 'yourcustomer@theirdomain.com', name: 'Your Customer' },
104
+ tags: ['greeting', 'sales'],
105
+ metadata: { place: 'Earth' }, substitution_data: { address: '123 Their Road' } }
106
+ ],
107
+ content:
108
+ { from: { name: 'Your Name', email: 'you@yourdomain.com' },
109
+ subject: 'I am a test email',
110
+ reply_to: 'Sales <sales@yourdomain.com>',
111
+ headers: { 'X-Customer-CampaignID' => 'christmas_campaign' },
112
+ text: 'Hi from {{sender}} ... this is a test, and here is your address {{address}}',
113
+ html: '<p>Hi from {{sender}}</p<p>This is a test</p>'
114
+ }
115
+ }
116
+
117
+ simple_spark.transmissions.create(properties)
118
+ ```
119
+
120
+ To send attachments, they need to be Base64 encoded
121
+
122
+ ```ruby
123
+ require 'base64'
124
+
125
+ properties = {
126
+ recipients: [{ address: { email: 'yourcustomer@theirdomain.com', name: 'Your Customer' }],
127
+ content:
128
+ { from: { name: 'Your Name', email: 'you@yourdomain.com' },
129
+ subject: 'I am a test email',
130
+ html: '<p>Hi from {{sender}}</p<p>This is a test</p>',
131
+ attachments: [{ name: "attachment.txt", type: "text/plain", data: attachment }]
132
+ }
133
+ }
134
+
135
+ # load your file contents first, then use Base64 to encode them
136
+ encoded_attachment = Base64.encode64('My file contents')
137
+ properties[:content][:attachments] = [{ name: "attachment.txt", type: "text/plain", data: encoded_attachment }]
138
+
139
+ simple_spark.transmissions.create(properties)
140
+ ```
141
+
142
+ <a href="https://developers.sparkpost.com/api/#/reference/transmissions/create" target="_blank">see SparkPost API Documentation</a>
143
+
144
+ ### Messsage Events
145
+
146
+ #### Samples
147
+
148
+ List an example of the event data that will be included in a response from the Message Events search endpoint
149
+
150
+ ```ruby
151
+ simple_spark.message_events.samples
152
+ ```
153
+
154
+ To limit to just some events
155
+
156
+ ```ruby
157
+ simple_spark.message_events.samples('bounce')
158
+ ```
159
+
160
+ <a href="https://developers.sparkpost.com/api/#/reference/message-events/events-samples" target="_blank">see SparkPost API Documentation</a>
161
+
162
+ #### Search
163
+
164
+ Perform a filtered search for message event data. The response is sorted by descending timestamp. For full options you should consult the SparkPost API documentation
165
+
166
+ ```ruby
167
+ simple_spark.message_events.search(campaign_ids: 'christmas-campaign, summer-campaign')
168
+ ```
169
+
170
+ <a href="https://developers.sparkpost.com/api/#/reference/message-events/events-samples" target="_blank">see SparkPost API Documentation</a>
171
+
172
+ ### Webhooks
173
+
174
+ #### List
175
+
176
+ List all Webhooks, optionally providing a timezone property
177
+
178
+ ```ruby
179
+ simple_spark.webhooks.list('America/New_York')
180
+ ```
181
+
182
+ <a href="https://developers.sparkpost.com/api/#/reference/webhooks/list" target="_blank">see SparkPost API Documentation</a>
183
+
184
+ #### Create
185
+
186
+ Create a new Webhook
187
+
188
+ ```ruby
189
+ simple_spark.webhooks.create(values)
190
+ ```
191
+
192
+ <a href="https://developers.sparkpost.com/api/#/reference/webhooks/create" target="_blank">see SparkPost API Documentation</a>
193
+
194
+ #### Retrieve
195
+
196
+ Retrieves a Webhook
197
+
198
+ ```ruby
199
+ simple_spark.webhooks.retrieve(webhook_id)
200
+ ```
201
+
202
+ <a href="https://developers.sparkpost.com/api/#/reference/webhooks/retrieve" target="_blank">see SparkPost API Documentation</a>
203
+
204
+ #### Update
205
+
206
+ Updates a Webhook with new values
207
+
208
+ ```ruby
209
+ properties = { "name" => "New name" }
210
+ simple_spark.webhooks.update(webhook_id, properties)
211
+ ```
212
+
213
+ <a href="https://developers.sparkpost.com/api/#/reference/webhooks/update-and-delete" target="_blank">see SparkPost API Documentation</a>
214
+
215
+ #### Validate
216
+
217
+ Validates a Webhook by sending an example message event batch from the Webhooks API to the target URL
218
+
219
+ ```ruby
220
+ simple_spark.webhooks.validate(webhook_id)
221
+ ```
222
+
223
+ <a href="https://developers.sparkpost.com/api/#/reference/webhooks/validate" target="_blank">see SparkPost API Documentation</a>
224
+
225
+ #### Batch Status
226
+
227
+ Retrieve the Batch Status Information for a Webhook
228
+
229
+ ```ruby
230
+ simple_spark.webhooks.batch_status(webhook_id)
231
+ ```
232
+
233
+ <a href="https://developers.sparkpost.com/api/#/reference/webhooks/batch-status" target="_blank">see SparkPost API Documentation</a>
234
+
235
+ #### Samples
236
+
237
+ List an example of the event data that will be sent from a webhook
238
+
239
+ ```ruby
240
+ simple_spark.webhooks.samples
241
+ ```
242
+
243
+ To limit to just some events
244
+
245
+ ```ruby
246
+ simple_spark.webhooks.samples('bounce')
247
+ ```
248
+
249
+ <a href="https://developers.sparkpost.com/api/#/reference/message-events/events-samples" target="_blank">see SparkPost API Documentation</a>
250
+
251
+ ### Sending Domains
252
+
253
+ #### List
254
+
255
+ List all Sending Domains
256
+
257
+ ```ruby
258
+ simple_spark.sending_domains.list
259
+ ```
260
+
261
+ <a href="https://developers.sparkpost.com/api/#/reference/sending-domains/create-and-list" target="_blank">see SparkPost API Documentation</a>
262
+
263
+ #### Create
264
+
265
+ Create a new Sending Domain
266
+
267
+ ```ruby
268
+ simple_spark.sending_domains.create('mail.mydomain.com')
269
+ ```
270
+
271
+ <a href="https://developers.sparkpost.com/api/#/reference/sending-domains/create-and-list" target="_blank">see SparkPost API Documentation</a>
272
+
273
+ #### Retrieve
274
+
275
+ Retrieves a Sending Template by its domain name
276
+
277
+ ```ruby
278
+ simple_spark.sending_domains.retrieve('mail.mydomain.com')
279
+ ```
280
+
281
+ <a href="https://developers.sparkpost.com/api/#/reference/sending-domains/retrieve-update-and-delete" target="_blank">see SparkPost API Documentation</a>
282
+
283
+ #### Update
284
+
285
+ Updates a Sending Domain with new values
286
+
287
+ ```ruby
288
+ properties = { "tracking_domain" => "new.tracking.domain" }
289
+ simple_spark.sending_domains.update('mail.mydomain.com', properties)
290
+ ```
291
+
292
+ <a href="https://developers.sparkpost.com/api/#/reference/sending-domains/retrieve-update-and-delete" target="_blank">see SparkPost API Documentation</a>
293
+
294
+ #### Verify
295
+
296
+ Forces verification of a Sending Domain.
297
+
298
+ Including the fields "dkim_verify" and/or "spf_verify" in the request initiates a check against the associated DNS record
299
+ type for the specified sending domain.Including the fields "postmaster_at_verify" and/or "abuse_at_verify" in the request
300
+ results in an email sent to the specified sending domain's postmaster@ and/or abuse@ mailbox where a verification link can
301
+ be clicked. Including the fields "postmaster_at_token" and/or "abuse_at_token" in the request initiates a check of the provided
302
+ token(s) against the stored token(s) for the specified sending domain.
303
+
304
+ ```ruby
305
+ properties = { "dkim_verify": true, "spf_verify": true }
306
+ simple_spark.sending_domains.retrieve('mail.mydomain.com', properties)
307
+ ```
308
+
309
+ <a href="https://developers.sparkpost.com/api/#/reference/sending-domains/verify" target="_blank">see SparkPost API Documentation</a>
310
+
311
+ #### Delete
312
+
313
+ Deletes a Sending Domain permanently
314
+
315
+ ```ruby
316
+ simple_spark.sending_domains.delete('mail.mydomain.com')
317
+ ```
318
+
319
+ <a href="https://developers.sparkpost.com/api/#/reference/sending-domains/retrieve-update-and-delete" target="_blank">see SparkPost API Documentation</a>
320
+
321
+ ### Inbound Domains
322
+
323
+ #### List
324
+
325
+ List all Inbound Domains
326
+
327
+ ```ruby
328
+ simple_spark.inbound_domains.list
329
+ ```
330
+
331
+ <a href="https://developers.sparkpost.com/api/#/reference/inbound-domains/create-and-list" target="_blank">see SparkPost API Documentation</a>
332
+
333
+ #### Create
334
+
335
+ Create a new Inbound Domain
336
+
337
+ ```ruby
338
+ simple_spark.inbound_domains.create('mail.mydomain.com')
339
+ ```
340
+
341
+ <a href="https://developers.sparkpost.com/api/#/reference/inbound-domains/create-and-list" target="_blank">see SparkPost API Documentation</a>
342
+
343
+ #### Retrieve
344
+
345
+ Retrieves an Inbound Template by its domain name
346
+
347
+ ```ruby
348
+ simple_spark.inbound_domains.retrieve('mail.mydomain.com')
349
+ ```
350
+
351
+ <a href="https://developers.sparkpost.com/api/#/reference/inbound-domains/retrieve-and-delete" target="_blank">see SparkPost API Documentation</a>
352
+
353
+ #### Delete
354
+
355
+ Deletes an Inbound Domain permanently
356
+
357
+ ```ruby
358
+ simple_spark.inbound_domains.delete('mail.mydomain.com')
359
+ ```
360
+
361
+ <a href="https://developers.sparkpost.com/api/#/reference/inbound-domains/retrieve-and-delete" target="_blank">see SparkPost API Documentation</a>
362
+
363
+ ### Templates
364
+
365
+ #### List
366
+
367
+ List all templates
368
+
369
+ ```ruby
370
+ simple_spark.templates.list
371
+ ```
372
+
373
+ <a href="https://developers.sparkpost.com/api/#/reference/templates/create-and-list" target="_blank">see SparkPost API Documentation</a>
374
+
375
+ #### Create
376
+
377
+ Create a new Template
378
+
379
+ ```ruby
380
+ properties = { "name" => "Summer Sale!",
381
+ "content"=> { "from" => "marketing@yourdomain.com",
382
+ "subject"=> "Summer deals",
383
+ "html"=> "<b>Check out these deals!</b>"
384
+ }
385
+ }
386
+ simple_spark.templates.create(properties)
387
+ ```
388
+
389
+ <a href="https://developers.sparkpost.com/api/#/reference/templates/create-and-list" target="_blank">see SparkPost API Documentation</a>
390
+
391
+ #### Retrieve
392
+
393
+ Retrieves a Template by its ID
394
+
395
+ ```ruby
396
+ draft = nil
397
+ simple_spark.templates.retrieve(yourtemplateid, draft)
398
+ ```
399
+
400
+ <a href="https://developers.sparkpost.com/api/#/reference/templates/retrieve" target="_blank">see SparkPost API Documentation</a>
401
+
402
+ #### Update
403
+
404
+ Updates a Template with new values
405
+
406
+ ```ruby
407
+ properties = { "name" => "Sorry, the Winter Sale!" }}
408
+ update_published = false
409
+ simple_spark.templates.update(yourtemplateid, properties, update_published)
410
+ ```
411
+
412
+ <a href="https://developers.sparkpost.com/api/#/reference/templates/update" target="_blank">see SparkPost API Documentation</a>
413
+
414
+ #### Preview
415
+
416
+ Merges the template with the Substitution data and returns the result
417
+
418
+ ```ruby
419
+ properties = { substitution_data: { name: 'Mr test User' } }
420
+ draft = nil
421
+ simple_spark.templates.preview(yourtemplateid, properties, draft)
422
+ ```
423
+
424
+ <a href="https://developers.sparkpost.com/api/#/reference/templates/preview" target="_blank">see SparkPost API Documentation</a>
425
+
426
+ #### Delete
427
+
428
+ Deletes a template permanently
429
+
430
+ ```ruby
431
+ simple_spark.templates.delete(yourtemplateid)
432
+ ```
433
+
434
+ <a href="https://developers.sparkpost.com/api/#/reference/templates/delete" target="_blank">see SparkPost API Documentation</a>
435
+
436
+ ## Contributing
437
+
438
+ Not right now, but in time ...
439
+
440
+ 1. Fork it ( https://github.com/leadmachineapp/simple_spark/fork )
441
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
442
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
443
+ 4. Push to the branch (`git push origin my-new-feature`)
444
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'bundler/gem_tasks'
3
+
4
+ # Default directory to look in is `/specs`
5
+ # Run with `rake spec`
6
+ RSpec::Core::RakeTask.new(:spec) do |task|
7
+ task.rspec_opts = ['--color', '--format', 'progress']
8
+ end
9
+
10
+ task :default => :spec
@@ -0,0 +1,82 @@
1
+ require 'rubygems'
2
+ require 'excon'
3
+ require 'json'
4
+
5
+ module SimpleSpark
6
+ class Client
7
+ def initialize(api_key = nil, api_host = 'https://api.sparkpost.com', base_path = '/api/v1/', debug = nil)
8
+ @api_key = api_key || ENV['SPARKPOST_API_KEY']
9
+ @api_host = api_host || 'https://api.sparkpost.com'
10
+ @base_path = base_path || '/api/v1/'
11
+
12
+ fail Exceptions::InvalidConfiguration.new, 'You must provide a SparkPost API key' unless @api_key
13
+ fail Exceptions::InvalidConfiguration.new, 'You must provide a SparkPost API host' unless @api_host # this should never occur unless the default above is changed
14
+ fail Exceptions::InvalidConfiguration.new, 'You must provide a SparkPost base path' unless @base_path # this should never occur unless the default above is changed
15
+
16
+ rails_development = !(defined?(Rails) && Rails.env.development?).nil?
17
+
18
+ @debug = debug.nil? ? rails_development : debug
19
+ @session = Excon.new(@api_host, debug: @debug)
20
+ end
21
+
22
+ def call(method, path, body_values = {}, query_params = {})
23
+ fail Exceptions::InvalidConfiguration.new({ method: method }), 'Only GET, POST, PUT and DELETE are supported' unless [:get, :post, :put, :delete].include?(method)
24
+
25
+ path = "#{@base_path}#{path}"
26
+ params = { path: path, headers: default_headers }
27
+ params[:body] = body_values.to_json unless body_values.empty?
28
+ params[:query] = query_params unless query_params.empty?
29
+ response = @session.send(method.to_s, params)
30
+
31
+ process_response(response)
32
+ end
33
+
34
+ def process_response(response)
35
+ return true if response.status == 204
36
+
37
+ response_body = JSON.parse(response.body)
38
+ if response_body['errors']
39
+ Exceptions::Error.fail_with_exception_for_status(response.status, response_body['errors'])
40
+ else
41
+ response_body['results'] ? response_body['results'] : true
42
+ end
43
+ end
44
+
45
+ # Copied from http://apidock.com/ruby/ERB/Util/url_encode
46
+ def url_encode(s)
47
+ s.to_s.dup.force_encoding("ASCII-8BIT").gsub(/[^a-zA-Z0-9_\-.]/) { sprintf("%%%02X", $&.unpack("C")[0]) }
48
+ end
49
+
50
+ def default_headers
51
+ {
52
+ 'User-Agent' => 'simple_spark/' + VERSION,
53
+ 'Content-Type' => 'application/json',
54
+ 'Authorization' => @api_key
55
+ }
56
+ end
57
+
58
+ def inbound_domains
59
+ Endpoints::InboundDomains.new(self)
60
+ end
61
+
62
+ def sending_domains
63
+ Endpoints::SendingDomains.new(self)
64
+ end
65
+
66
+ def templates
67
+ Endpoints::Templates.new(self)
68
+ end
69
+
70
+ def transmissions
71
+ Endpoints::Transmissions.new(self)
72
+ end
73
+
74
+ def message_events
75
+ Endpoints::MessageEvents.new(self)
76
+ end
77
+
78
+ def webhooks
79
+ Endpoints::Webhooks.new(self)
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,44 @@
1
+ module SimpleSpark
2
+ module Endpoints
3
+ # Provides access to the /inbound-domains endpoint
4
+ # See: https://developers.sparkpost.com/api/#/reference/inbound-domains
5
+ class InboundDomains
6
+ attr_accessor :client
7
+
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ # Lists your inbound domains
13
+ # @return [Array] a list of Inbound Domain hash objects
14
+ # @note See: https://developers.sparkpost.com/api/#/reference/inbound-domains/create-and-list
15
+ def list
16
+ @client.call(:get, 'inbound-domains')
17
+ end
18
+
19
+ # Create an inbound domain
20
+ # @param domain_name [String] the domain name to create
21
+ # @note See: https://developers.sparkpost.com/api/#/reference/inbound-domains/create-and-list
22
+ def create(domain_name)
23
+ @client.call(:post, 'inbound-domains', domain: domain_name)
24
+ end
25
+
26
+ # Retrieve an inbound domain
27
+ # @param domain_name [String] the domain name to retrieve
28
+ # @return [Hash] an Inbound Domain hash object
29
+ # @note See: https://developers.sparkpost.com/api/#/reference/inbound-domains/retrieve-and-delete
30
+ def retrieve(domain_name)
31
+ domain_name = @client.url_encode(domain_name)
32
+ @client.call(:get, "inbound-domains/#{domain_name}")
33
+ end
34
+
35
+ # Delete an inbound domain
36
+ # @param domain_name [String] the domain name to delete
37
+ # @note See: https://developers.sparkpost.com/api/#/reference/inbound-domains/retrieve-and-delete
38
+ def delete(domain_name)
39
+ domain_name = @client.url_encode(domain_name)
40
+ @client.call(:delete, "inbound-domains/#{domain_name}")
41
+ end
42
+ end
43
+ end
44
+ end