emarsys 0.2.0 → 0.2.1

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: 2f8428e2c40d3634ec723d6344c78b04ecc42ef4
4
- data.tar.gz: 1e68cfc41427960d604cc562ceb05a7a30b2cdf5
3
+ metadata.gz: cbb69af7c3e5a8574c609396438fb0c8bd98669a
4
+ data.tar.gz: 7624b2f1909182375b5373462240b4947a02f6a1
5
5
  SHA512:
6
- metadata.gz: 683eba0ca8b1166136a8943e8a9381c6d58f563899f020cc60fb063bc0febcc62919e7b2c61e5ca48f2f9e604a9abc08d179c85ec0bc236e97cbf4fced9fad07
7
- data.tar.gz: c680377e2abe42b2e03f70c46bbe5446669825438db4776a5f1d4ce8c496aa951a5dffa74b09a83909eee8abca251e4bdcf98c739a05133d2776f214bbf4f165
6
+ metadata.gz: 859b05d96793b5fec1071afbb5a6fae628ab0829c9e1739e6a7c98185301b3bfa4dca0749b40bc4b93c0e8b92ebdfce450c4221461e0e6b6b04195a4e48c45d3
7
+ data.tar.gz: defafe1ddfa3e4ff987bd271e415276ce280d60206d0fbbd3b9bd4bf3831b9440de42cd75f89e50d2df0e99a87eaf64d6a4d14eb48389d6c317084b416c912ea
data/README.md CHANGED
@@ -76,6 +76,14 @@ A utility method is provided to map to Emarsys internal country IDs from ISO 316
76
76
  => {:id=>185, :name=>"United States of America"}
77
77
  ```
78
78
 
79
+ ### Rate Limiting
80
+
81
+ The Emarsys API documentation states you can make "at least 200 requests per minute", which is reasonably slow - in practice, the Emarsys API seems to handle rates of up to about 60-70 req/sec before complaining.
82
+
83
+ If you exceed the limit, the Emarsys API returns an HTTP 429 'Too Many Requests' response. The client library will raise an error in this case.
84
+
85
+
86
+
79
87
  ## Interacting with the API
80
88
 
81
89
  You can interact with the API on the provided data objects:
data/lib/emarsys/error.rb CHANGED
@@ -20,6 +20,9 @@ module Emarsys
20
20
  # Raised when Emarsys returns a 401 HTTP status code
21
21
  class Unauthorized < Error; end
22
22
 
23
+ # Raised when Emarsys returns a 429 HTTP status code
24
+ class TooManyRequests < Error; end
25
+
23
26
  # Raised when Emarsys returns a 500 HTTP status code
24
27
  class InternalServerError < Error; end
25
28
  end
@@ -16,6 +16,8 @@ module Emarsys
16
16
  data
17
17
  elsif !status.nil? && status == 401
18
18
  raise Emarsys::Unauthorized.new(code, text, status)
19
+ elsif !status.nil? && status == 429
20
+ raise Emarsys::TooManyRequests.new(code, text, status)
19
21
  else
20
22
  raise Emarsys::BadRequest.new(code, text, status)
21
23
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Emarsys
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
@@ -30,6 +30,12 @@ describe Emarsys::Response do
30
30
  allow(response).to receive(:status).and_return(401)
31
31
  expect{response.result}.to raise_error(Emarsys::Unauthorized)
32
32
  end
33
+
34
+ it "raises TooManyRequests error if http-status is 429" do
35
+ allow(response).to receive(:code).and_return(1)
36
+ allow(response).to receive(:status).and_return(429)
37
+ expect{response.result}.to raise_error(Emarsys::TooManyRequests)
38
+ end
33
39
  end
34
40
 
35
41
  end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emarsys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Schoppmann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-12 00:00:00.000000000 Z
11
+ date: 2017-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: 3.5.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 3.5.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "<"
73
+ - - <
74
74
  - !ruby/object:Gem::Version
75
75
  version: '2.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "<"
80
+ - - <
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.0'
83
83
  description: A Ruby library for interacting with the Emarsys API.
@@ -87,9 +87,9 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - ".gitignore"
91
- - ".rspec"
92
- - ".travis.yml"
90
+ - .gitignore
91
+ - .rspec
92
+ - .travis.yml
93
93
  - Gemfile
94
94
  - LICENSE.txt
95
95
  - README.md
@@ -158,17 +158,17 @@ require_paths:
158
158
  - lib
159
159
  required_ruby_version: !ruby/object:Gem::Requirement
160
160
  requirements:
161
- - - ">="
161
+ - - '>='
162
162
  - !ruby/object:Gem::Version
163
163
  version: '0'
164
164
  required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  requirements:
166
- - - ">="
166
+ - - '>='
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
169
  requirements: []
170
170
  rubyforge_project:
171
- rubygems_version: 2.6.3
171
+ rubygems_version: 2.0.14.1
172
172
  signing_key:
173
173
  specification_version: 4
174
174
  summary: Easy to use ruby library for Emarsys Marketing Suite.