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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: affaa3d0724c6630a7800fe32240756396a9d58e
4
- data.tar.gz: 2a0874154bfb1960d79e645b784d9f1004a710c9
3
+ metadata.gz: 9fea18f28aaba6623d717c23a9410de624378cc2
4
+ data.tar.gz: 93a1319a33d2ad129d0f95ed8a57a3baa58abcc9
5
5
  SHA512:
6
- metadata.gz: 9c34dddca1553424d055c10fb12bc36cbd73e83a84c64b5719f6179178556e4cb0cfab85c615388fcedb6727c37724a22ae904997b4ec47201e61a7c96d8111e
7
- data.tar.gz: 87d02f42042c83b5401744d7b336703a7ba22b078ba3f15246e0e6765baa6cdcd24325ab8b56712582e9d3b3525f68d5b967db9e1ffbd4814078cd4e3052ac81
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
@@ -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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Emarsys
3
- VERSION = "0.3.10"
3
+ VERSION = "0.3.11"
4
4
  end
@@ -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(:response_string) { "{\"replyCode\":1,\"replyText\":\"Something\",\"data\":1}" }
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.10
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-06-21 00:00:00.000000000 Z
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.2
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.