emarsys 0.3.13 → 0.4.0

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
- SHA1:
3
- metadata.gz: 438c871d801d4782d2e87ed2fc095847b5323a64
4
- data.tar.gz: 9d01a343ecb897f827d3b0e543fb08382e73d540
2
+ SHA256:
3
+ metadata.gz: b91da527fa70b69756d7dca70b153ec103be4c52ed2fc189b6d8eb6d4036637a
4
+ data.tar.gz: 1ac969e7acf008b6cc07ae032d3c8ce42b8cdcf398b61bb3b51db0ff14c18533
5
5
  SHA512:
6
- metadata.gz: c1b1ae69f75b6d77168dee74a56166942266084119f7ba169b3eecf7726bfdd6ef1d4e810195b014bcf3564d6a97f3e1bb1e254638abf0545d54f9ee4e0d7844
7
- data.tar.gz: f846c1d9637cf3050fca1b249df4023f1ea6e2f766cec60eb3c46f8ddb9b53b41c91ca47df081d9fa2f4f0f6384c52152b8d11402c5859808d879da38b5cea52
6
+ metadata.gz: b512d98dc2a1acbb56a1e783fb00a6e3d915d58a66ea1c773b9c92ea444b4724734e004273ee72758b16179b10b304656a07ad56bd5bd406606fe0d9726c02a0
7
+ data.tar.gz: 955e9a9626883406b3e029929475dbf04971f3411b5c2112626f7faacd0796c7a0216caf9f1548587d686d4d5e54b1a3c29870fc5a376f7f94ef65673c04eb42
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  sudo: false
3
- cache:
4
- bundler: true
3
+ before_install:
4
+ - gem install bundler
5
5
  rvm:
6
- - jruby-9.0.5.0
7
- - 2.2.2
6
+ - jruby-9.2.11.0
8
7
  - 2.3.1
8
+ - 2.5.8
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.4.0
4
+
5
+ * Add supported segment endpoints and remove the deprecated one ([#64]https://github.com/Absolventa/emarsys-rb/pull/64)
6
+
3
7
  ## v0.3.13
4
8
 
5
9
  * Add method to delete ContactList by ID ([#63](https://github.com/Absolventa/emarsys-rb/pull/63))
data/README.md CHANGED
@@ -161,6 +161,9 @@ Emarsys::ContactList.create
161
161
 
162
162
  # Delete a contact list
163
163
  Emarsys::ContactList.delete(123)
164
+
165
+ # List all contacts in a contact list
166
+ Emarsys::ContactList.contacts(123)
164
167
  ```
165
168
 
166
169
  #### Emails
@@ -235,8 +238,13 @@ Emarsys::Segment.collection
235
238
  ```
236
239
 
237
240
  ```ruby
238
- # List contacts in a segment
239
- Emarsys::Segment.contacts(123, limit: 2000)
241
+ # Run a segment for multiple contacts
242
+ Emarsys::Segment.run(123)
243
+ ```
244
+
245
+ ```ruby
246
+ # Check the status of a segment run
247
+ Emarsys::Segment.status('foo123')
240
248
  ```
241
249
 
242
250
  #### Source
@@ -17,12 +17,13 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
+ spec.required_ruby_version = '>= 2.3'
20
21
 
21
22
  spec.add_dependency "rest-client"
22
23
 
23
- spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "bundler", "~> 2.1.4"
24
25
  spec.add_development_dependency "rake"
25
26
  spec.add_development_dependency "rspec", ">= 3.5.0"
26
- spec.add_development_dependency "webmock", "< 2.0"
27
+ spec.add_development_dependency "webmock", "~> 2.3.2"
27
28
  spec.add_development_dependency "timecop"
28
29
  end
@@ -16,6 +16,14 @@ module Emarsys
16
16
  get account, 'contactlist', {}
17
17
  end
18
18
 
19
+ # List contacts in a contact list
20
+ # Reference: https://dev.emarsys.com/v2/contact-lists/list-contacts-in-a-contact-list
21
+ #
22
+ # @param id [Integer] The contact list id
23
+ def contacts(id, account: nil)
24
+ get account, "contactlist/#{id}/", {}
25
+ end
26
+
19
27
  # Create a new contact list
20
28
  #
21
29
  # @param params [Hash] Contact list information to create
@@ -16,17 +16,22 @@ 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.
19
+ # Run a Segment for Multiple Contacts
20
+ # Reference: https://dev.emarsys.com/v2/segments/run-a-contact-segment-batch
23
21
  #
24
22
  # @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
23
+ def run(id, account: nil)
24
+ path = "filter/#{id}/runs"
25
+ post account, path, {}
26
+ end
27
+
28
+ # Poll the Status of a Segment Run for Multiple Contacts
29
+ # Reference: https://dev.emarsys.com/v2/segments/poll-the-status-of-a-segment-run-for-multiple-contacts
30
+ #
31
+ # @param run_id [String] the id of the segment run, @see #run
32
+ def status(run_id, account: nil)
33
+ path = "filter/runs/#{run_id}"
34
+ get account, path, {}
30
35
  end
31
36
  end
32
37
  end
@@ -28,10 +28,6 @@ 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
-
35
31
  class AccountNotConfigured < StandardError; end
36
32
 
37
33
  class AccountRequired < StandardError; end
@@ -21,8 +21,6 @@ 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)
26
24
  else
27
25
  raise Emarsys::BadRequest.new(code, text, status)
28
26
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Emarsys
3
- VERSION = "0.3.13"
3
+ VERSION = "0.4.0"
4
4
  end
@@ -8,4 +8,11 @@ describe Emarsys::ContactList do
8
8
  ).to have_been_requested.once
9
9
  end
10
10
  end
11
+ describe ".contacts" do
12
+ it "requests all contacts in the given contact list" do
13
+ expect(
14
+ stub_get("contactlist/123/") { Emarsys::ContactList.contacts(123) }
15
+ ).to have_been_requested.once
16
+ end
17
+ end
11
18
  end
@@ -7,11 +7,18 @@ 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
10
+ describe ".run" do
11
+ it "requests a run for a segment for multiple contacts" do
12
+ expect(
13
+ stub_post("filter/123/runs") { Emarsys::Segment.run(123) }
14
+ ).to have_been_requested.once
15
+ end
16
+ end
17
+ describe ".status" do
18
+ it "requests the status of the given segment run" do
19
+ expect(
20
+ stub_get("filter/runs/foo-333-bar") { Emarsys::Segment.status('foo-333-bar') }
21
+ ).to have_been_requested.once
15
22
  end
16
23
  end
17
24
  end
@@ -78,14 +78,6 @@ describe Emarsys::Response do
78
78
  allow(fake_response).to receive(:code).and_return(429)
79
79
  expect{response}.to raise_error(Emarsys::TooManyRequests)
80
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
89
81
  end
90
82
 
91
83
  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.13
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Schoppmann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-23 00:00:00.000000000 Z
11
+ date: 2020-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.3'
33
+ version: 2.1.4
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
- version: '1.3'
40
+ version: 2.1.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: webmock
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "<"
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '2.0'
75
+ version: 2.3.2
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
- version: '2.0'
82
+ version: 2.3.2
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: timecop
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -177,15 +177,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
- version: '0'
180
+ version: '2.3'
181
181
  required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  requirements:
183
183
  - - ">="
184
184
  - !ruby/object:Gem::Version
185
185
  version: '0'
186
186
  requirements: []
187
- rubyforge_project:
188
- rubygems_version: 2.4.5.4
187
+ rubygems_version: 3.0.3
189
188
  signing_key:
190
189
  specification_version: 4
191
190
  summary: Easy to use ruby library for Emarsys Marketing Suite.