emarsys 0.3.10 → 0.3.11
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 +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/emarsys/data_objects/segment.rb +12 -0
- data/lib/emarsys/error.rb +4 -0
- data/lib/emarsys/response.rb +2 -0
- data/lib/emarsys/version.rb +1 -1
- data/spec/emarsys/data_objects/segment_spec.rb +7 -0
- data/spec/emarsys/response_spec.rb +10 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fea18f28aaba6623d717c23a9410de624378cc2
|
4
|
+
data.tar.gz: 93a1319a33d2ad129d0f95ed8a57a3baa58abcc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd9d4a0c9ea098b84a0a1130d105f9e9ac307db0216d5eded78d25b0e427ee01801e781f6ae0412a23cd19a5f261e0392c37a0e47dcb906dddc54ae846f8b2c7
|
7
|
+
data.tar.gz: e9d401a543a02fbed9ea985fe41f84f8c1ee72d7125939230552fc477e509a0356ba1b0089d4b432de0b74f449768c7d69c75186e7f70532b06ebe57df7ae096
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v0.3.10
|
4
|
+
|
5
|
+
* Fix 'Invalid Password' error ([#55](https://github.com/Absolventa/emarsys-rb/pull/55))
|
6
|
+
|
7
|
+
## v0.3.9
|
8
|
+
|
9
|
+
* Add 'query' support to Contact data object ([#53](https://github.com/Absolventa/emarsys-rb/pull/53))
|
10
|
+
|
11
|
+
## v0.3.5 - v0.3.8
|
12
|
+
|
13
|
+
* Documentation TODO
|
14
|
+
|
3
15
|
## v0.3.4
|
4
16
|
|
5
17
|
* Allow accessing of error code ([#35](https://github.com/Absolventa/emarsys-rb/pull/35))
|
@@ -16,6 +16,18 @@ module Emarsys
|
|
16
16
|
get account, 'filter', {}
|
17
17
|
end
|
18
18
|
|
19
|
+
# List ids of contacts in a segment.
|
20
|
+
# Raises Emarsys::SegmentIsEvaluated if the segment is being currently evaluated.
|
21
|
+
# Reference: https://dev.emarsys.com/v2/response-codes/http-202-errors
|
22
|
+
# The `limit` param is required by this endpoint although it is marked as optional in the API v2 doc.
|
23
|
+
#
|
24
|
+
# @param id [Integer] the id of the segment
|
25
|
+
# @param limit [Integer] the maximum number of records to return
|
26
|
+
# @param offset [Integer] optional offset value for pagination
|
27
|
+
def contacts(id, limit:, offset: 0, account: nil)
|
28
|
+
path = "filter/#{id}/contacts"
|
29
|
+
get account, path, limit: limit, offset: offset
|
30
|
+
end
|
19
31
|
end
|
20
32
|
end
|
21
33
|
|
data/lib/emarsys/error.rb
CHANGED
@@ -28,6 +28,10 @@ module Emarsys
|
|
28
28
|
# Raised when Emarsys returns a 500 HTTP status code
|
29
29
|
class InternalServerError < Error; end
|
30
30
|
|
31
|
+
# Raised when Emarsys returns a 202 HTTP status code with 10001 Reply Code
|
32
|
+
# https://dev.emarsys.com/v2/response-codes/http-202-errors
|
33
|
+
class SegmentIsEvaluated < Error; end
|
34
|
+
|
31
35
|
class AccountNotConfigured < StandardError; end
|
32
36
|
|
33
37
|
class AccountRequired < StandardError; end
|
data/lib/emarsys/response.rb
CHANGED
@@ -21,6 +21,8 @@ module Emarsys
|
|
21
21
|
raise Emarsys::Unauthorized.new(code, text, status)
|
22
22
|
elsif status == 429
|
23
23
|
raise Emarsys::TooManyRequests.new(code, text, status)
|
24
|
+
elsif status == 202 && code == 10001
|
25
|
+
raise Emarsys::SegmentIsEvaluated.new(code, text, status)
|
24
26
|
else
|
25
27
|
raise Emarsys::BadRequest.new(code, text, status)
|
26
28
|
end
|
data/lib/emarsys/version.rb
CHANGED
@@ -7,5 +7,12 @@ describe Emarsys::Segment do
|
|
7
7
|
stub_get("filter") { Emarsys::Segment.collection }
|
8
8
|
).to have_been_requested.once
|
9
9
|
end
|
10
|
+
describe ".contacts" do
|
11
|
+
it "requests contact data for a given segment" do
|
12
|
+
stub = stub_request(:get, "https://api.emarsys.net/api/v2/filter/123/contacts/?limit=2000&offset=0").to_return(standard_return_body)
|
13
|
+
Emarsys::Segment.contacts(123, limit: 2000)
|
14
|
+
expect(stub).to have_been_requested.once
|
15
|
+
end
|
16
|
+
end
|
10
17
|
end
|
11
18
|
end
|
@@ -59,7 +59,8 @@ describe Emarsys::Response do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
describe 'error response' do
|
62
|
-
let(:
|
62
|
+
let(:reply_code) { 1 }
|
63
|
+
let(:response_string) { "{\"replyCode\":#{reply_code},\"replyText\":\"Something\",\"data\":1}" }
|
63
64
|
let(:fake_response) { FakeResponse.new(response_string).extend(FakeResponse::JSON) }
|
64
65
|
let(:response) { Emarsys::Response.new(fake_response) }
|
65
66
|
|
@@ -77,6 +78,14 @@ describe Emarsys::Response do
|
|
77
78
|
allow(fake_response).to receive(:code).and_return(429)
|
78
79
|
expect{response}.to raise_error(Emarsys::TooManyRequests)
|
79
80
|
end
|
81
|
+
|
82
|
+
context 'with Reply Code 10001' do
|
83
|
+
let(:reply_code) { 10001 }
|
84
|
+
it "raises SegmentIsEvaluated error if http-status i 202" do
|
85
|
+
allow(fake_response).to receive(:code).and_return(202)
|
86
|
+
expect{response}.to raise_error(Emarsys::SegmentIsEvaluated)
|
87
|
+
end
|
88
|
+
end
|
80
89
|
end
|
81
90
|
|
82
91
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emarsys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Schoppmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
version: '0'
|
186
186
|
requirements: []
|
187
187
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.5.
|
188
|
+
rubygems_version: 2.4.5.4
|
189
189
|
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: Easy to use ruby library for Emarsys Marketing Suite.
|