simple_spark 1.0.5 → 1.0.6

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: d9d658ec10ada82c8d1923eef68a5a4063529801
4
- data.tar.gz: 2be52f459b756448defdd33174fb16099a7a96e1
3
+ metadata.gz: 4fa620f08807116bdbc70379d8700292ff0814c1
4
+ data.tar.gz: d354432057364db7e46b8501c29d88482745bc42
5
5
  SHA512:
6
- metadata.gz: 636cb92b6458d45736a125179fef0cbc66eaa82c3d4fa9d25d2a44af2dc6f6da8f974e26e464a69e220723c6f958a6ccc913bb2f2cec707a5df58b33c2b9df63
7
- data.tar.gz: e6a60ed21f086e3d44935a20aa83962601ef4460a3af923907469b0298baacb78da2d085247192d23668760e0326944c1f62aba183410554774715af0c95905a
6
+ metadata.gz: 53d945762da13ff21a69372454fafe0bb40c75b43b2754bbab4c3f15a37e9e8378bba06aac91a33175f7ea51508603877342de6fbf35f03b7f8dfeaa8c433750
7
+ data.tar.gz: 1dcb853059b6ea5ac9409cbd6d8b1a970c6cbe68560a263905a502e38c4a64c4127837a24bab26024cee4df119fc0a4fef2fd8baead48d4edf74736899170c4e
data/README.md CHANGED
@@ -522,7 +522,7 @@ simple_spark.sending_domains.list
522
522
  Create a new Sending Domain
523
523
 
524
524
  ```ruby
525
- simple_spark.sending_domains.create('mail.mydomain.com')
525
+ simple_spark.sending_domains.create({domain: 'mail.mydomain.com'})
526
526
  ```
527
527
 
528
528
  <a href="https://developers.sparkpost.com/api/#/reference/sending-domains/create-and-list" target="_blank">see SparkPost API Documentation</a>
@@ -560,7 +560,7 @@ token(s) against the stored token(s) for the specified sending domain.
560
560
 
561
561
  ```ruby
562
562
  properties = { "dkim_verify": true, "spf_verify": true }
563
- simple_spark.sending_domains.retrieve('mail.mydomain.com', properties)
563
+ simple_spark.sending_domains.verify('mail.mydomain.com', properties)
564
564
  ```
565
565
 
566
566
  <a href="https://developers.sparkpost.com/api/#/reference/sending-domains/verify" target="_blank">see SparkPost API Documentation</a>
@@ -628,7 +628,7 @@ params = {
628
628
  from: '2013-04-20T07:12',
629
629
  to: '2018-04-20T07:12'
630
630
  }
631
- simple_spark.suppression_list.create_or_update(params)
631
+ simple_spark.suppression_list.search(params)
632
632
  ```
633
633
 
634
634
  <a href="https://developers.sparkpost.com/api/suppression-list#suppression-list-search-get" target="_blank">see SparkPost API Documentation</a>
@@ -807,6 +807,10 @@ simple_spark.templates.delete(yourtemplateid)
807
807
 
808
808
  ## Changelog
809
809
 
810
+ ### 1.0.6
811
+
812
+ - Exceptions now return SparkPost results object too
813
+
810
814
  ### 1.0.5
811
815
 
812
816
  - Add Account API Endpoint
@@ -71,7 +71,7 @@ module SimpleSpark
71
71
 
72
72
  response_body = JSON.parse(response.body)
73
73
  if response_body['errors']
74
- Exceptions::Error.fail_with_exception_for_status(response.status, response_body['errors'])
74
+ Exceptions::Error.fail_with_exception_for_status(response.status, response_body['errors'], response_body['results'])
75
75
  else
76
76
  if extract_results
77
77
  response_body['results'] ? response_body['results'] : {}
@@ -8,15 +8,20 @@ module SimpleSpark
8
8
  # puts e.object # => { id: '1' }
9
9
  # end
10
10
  class Error < StandardError
11
- attr_reader :object
11
+ attr_reader :object, :results
12
12
 
13
- def initialize(object = nil)
13
+ def initialize(object = nil, results = {})
14
14
  @object = object
15
+ @results = results
16
+ end
17
+
18
+ def transmission_id
19
+ results['id']
15
20
  end
16
21
 
17
- def self.fail_with_exception_for_status(status, errors)
22
+ def self.fail_with_exception_for_status(status, errors, results)
18
23
  exception = status_codes[status.to_s] || status_codes['default']
19
- fail exception.new(errors), errors.map { |e| "#{e['message']} #{status} (Error Code: #{e['code']})" + (e['description'] ? ": #{e['description']}" : '') }.join(', ')
24
+ fail exception.new(errors, results), errors.map { |e| "#{e['message']} #{status} (Error Code: #{e['code']})" + (e['description'] ? ": #{e['description']}" : '') }.join(', ')
20
25
  end
21
26
 
22
27
  def self.status_codes
@@ -1,3 +1,3 @@
1
1
  module SimpleSpark
2
- VERSION = '1.0.5'
2
+ VERSION = '1.0.6'
3
3
  end
@@ -4,7 +4,8 @@ describe SimpleSpark::Exceptions::Error do
4
4
  describe :fail_with_exception_for_status do
5
5
  it 'will respond with the SparkPost error code' do
6
6
  errors = [{'message' => "Test Error Message", 'code' => 3005}]
7
- expect{SimpleSpark::Exceptions::Error.fail_with_exception_for_status(400, errors)}.to raise_error(SimpleSpark::Exceptions::BadRequest, "Test Error Message 400 (Error Code: 3005)")
7
+ results = [{"total_rejected_recipients": 1, "total_accepted_recipients": 0, "id": "123" }]
8
+ expect{SimpleSpark::Exceptions::Error.fail_with_exception_for_status(400, errors, results)}.to raise_error(SimpleSpark::Exceptions::BadRequest, "Test Error Message 400 (Error Code: 3005)")
8
9
  end
9
10
  end
10
11
  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.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jak Charlton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-12 00:00:00.000000000 Z
11
+ date: 2017-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json