simple_spark 0.0.7 → 0.0.8

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: 9fbe341a22eda0d04e959f2c63bdb11aaed0c063
4
- data.tar.gz: 9c051cede4440b5e40de0e249e213f48d12d0651
3
+ metadata.gz: 457e131ec0356d12efdfe669b4d9f13d506d5c5a
4
+ data.tar.gz: 8e2207f534f08403e3ac93e379287226f54c9a9b
5
5
  SHA512:
6
- metadata.gz: 2f0264a5ee16bae3a0ea08b3af30627672dd6eaeb448b1820b3799c0589828a29a4a26bbe4fdd47661eab9b7106060c5b510fa80f7e18334348404d69125fb57
7
- data.tar.gz: 6cdd94b5f13ce42d1467e614712e9d9fc7daa0325b12c9405ec208bcfe275c3fc35ba067b48cbddf3c50bf4989314893cd035986ee1f36553248843d46b99084
6
+ metadata.gz: d19571e8b20e55511ce369c92661a20857a72a54781ec1edfd7f9c27201c8f0786f545c960c131008479f2f7763e39981cc545e11655ef09d5615003dc7e5c12
7
+ data.tar.gz: b975189f61b03f0757443bc200d65a8f8eba71ee3e11e76bff0539a8665a9266d20b06f33b19652c0e68fe13e3f389539b717db02e7cc2ee482a7133f3e3e987
data/.travis.yml CHANGED
@@ -7,6 +7,8 @@ rvm:
7
7
 
8
8
  script: 'bundle exec rake'
9
9
 
10
+ bundler_args: --without development debug
11
+
10
12
  notifications:
11
13
  email:
12
14
  recipients:
data/Gemfile CHANGED
@@ -3,4 +3,18 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in sparkpost-snap.gemspec
4
4
  gemspec
5
5
 
6
- gem 'pry'
6
+ group :development, :test do
7
+ gem 'bundler', '~> 1.6'
8
+ gem 'rake', '~> 0.9.6'
9
+ gem 'rspec', '~> 3.4.0'
10
+ gem 'rspec-nc', '~> 0'
11
+ gem 'climate_control', '~> 0'
12
+ end
13
+
14
+ group :development do
15
+ gem 'guard', '~> 2.13'
16
+ gem 'guard-rspec', '~> 4.6.4'
17
+ gem 'pry', '~> 0'
18
+ gem 'pry-remote', '~> 0'
19
+ gem 'pry-nav', '~> 0'
20
+ end
data/README.md CHANGED
@@ -86,6 +86,21 @@ Should you have any need to override the headers that are sent by default, then
86
86
  simple_spark = SimpleSpark::Client.new(api_key: 'your_api_key', headers: { 'NewSparkpostHeader' => 'hello'})
87
87
  ```
88
88
 
89
+ ### Exceptions
90
+
91
+ SimpleSpark wraps all the common errors from the SparkPost API
92
+
93
+ If the API is unresponsive a GatewayTimeoutExceeded will be raised
94
+
95
+ Status 400 raises Exceptions::BadRequest
96
+
97
+ Status 404 raises Exceptions::NotFound
98
+
99
+ Status 422 raises Exceptions::UnprocessableEntity
100
+
101
+ Status 420 raises Exceptions::ThrottleLimitExceeded
102
+
103
+ Other response status codes raise Exceptions::UnprocessableEntity
89
104
 
90
105
  ### Metrics
91
106
 
@@ -39,10 +39,13 @@ module SimpleSpark
39
39
  response = @session.send(method.to_s, params)
40
40
 
41
41
  process_response(response, extract_results)
42
+
43
+ rescue Excon::Errors::Timeout
44
+ raise Exceptions::GatewayTimeoutExceeded
42
45
  end
43
46
 
44
47
  def process_response(response, extract_results)
45
- return true if response.status == 204
48
+ return true if response.status == 204 || response.body.nil? || response.body == ''
46
49
 
47
50
  response_body = JSON.parse(response.body)
48
51
  if response_body['errors']
@@ -35,5 +35,6 @@ module SimpleSpark
35
35
  class NotFound < Error; end
36
36
  class UnprocessableEntity < Error; end
37
37
  class ThrottleLimitExceeded < Error; end
38
+ class GatewayTimeoutExceeded < Error; end
38
39
  end
39
40
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleSpark
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
data/simple_spark.gemspec CHANGED
@@ -18,17 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency 'bundler', '~> 1.6'
22
- spec.add_development_dependency 'rake', '~> 0.9.6'
23
-
24
- spec.add_development_dependency 'rspec', '~> 3.4.0'
25
- spec.add_development_dependency 'rspec-nc', '~> 0'
26
- spec.add_development_dependency 'guard', '~> 2.13'
27
- spec.add_development_dependency 'guard-rspec', '~> 4.6.4'
28
- spec.add_development_dependency 'pry', '~> 0'
29
- spec.add_development_dependency 'pry-remote', '~> 0'
30
- spec.add_development_dependency 'pry-nav', '~> 0'
31
- spec.add_development_dependency 'climate_control', '~> 0'
32
21
 
33
22
  spec.add_dependency 'json', '>= 1.7.7', '< 2.0'
34
23
  spec.add_dependency 'excon', '>= 0.16.0', '< 1.0'
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'pry'
2
1
  require 'simple_spark'
3
2
  require 'climate_control'
4
3
 
metadata CHANGED
@@ -1,155 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_spark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
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-04-21 00:00:00.000000000 Z
11
+ date: 2016-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.6'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.6'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 0.9.6
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 0.9.6
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 3.4.0
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 3.4.0
55
- - !ruby/object:Gem::Dependency
56
- name: rspec-nc
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: guard
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '2.13'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '2.13'
83
- - !ruby/object:Gem::Dependency
84
- name: guard-rspec
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 4.6.4
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 4.6.4
97
- - !ruby/object:Gem::Dependency
98
- name: pry
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: pry-remote
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: pry-nav
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: climate_control
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
13
  - !ruby/object:Gem::Dependency
154
14
  name: json
155
15
  requirement: !ruby/object:Gem::Requirement