emarsys 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/emarsys/data_objects/contact.rb +8 -3
- data/lib/emarsys/version.rb +1 -1
- data/spec/emarsys/data_objects/contact_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ae8a2be8a9eb47480f0dfa43f730039a5fc8129
|
4
|
+
data.tar.gz: 97ac47f4b22dc3eca4146573fb714aa7c7104280
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: deb3b4aa58dad053e9bf7fb61e87146d118a83e9eee652f1d6076195a29935138b147982fb3a128bb65d7f3d03f59efee3acddb981fc337a31005d4a3c4c6545
|
7
|
+
data.tar.gz: 7022cdbe34e40380b0c17ff50860055acdd036a037435debb72d89c95b09eb2542a2ca93e691a7964629cc5d43dd8d75d8020d602739b95af2953d9253e4d866
|
data/README.md
CHANGED
@@ -208,6 +208,10 @@ Please refer to the code for detailed instructions of each method.
|
|
208
208
|
|
209
209
|
### HEAD (not yet released)
|
210
210
|
|
211
|
+
### v0.2.3
|
212
|
+
|
213
|
+
* Convert params when using the batch APIs ([#25](https://github.com/Absolventa/emarsys-rb/pull/25))
|
214
|
+
|
211
215
|
### v0.2.2
|
212
216
|
|
213
217
|
* Allow batch updates to create missing contacts ([#22](https://github.com/Absolventa/emarsys-rb/pull/22))
|
@@ -61,7 +61,10 @@ module Emarsys
|
|
61
61
|
#
|
62
62
|
# TODO params should be parameterized with field mappings
|
63
63
|
def create_batch(key_id, params = [])
|
64
|
-
|
64
|
+
converted_params = params.map do |p|
|
65
|
+
Emarsys::ParamsConverter.new(p).convert_to_ids
|
66
|
+
end
|
67
|
+
post "contact", {'key_id' => transform_key_id(key_id), 'contacts' => converted_params}
|
65
68
|
end
|
66
69
|
|
67
70
|
# Batch update of contacts.
|
@@ -77,10 +80,12 @@ module Emarsys
|
|
77
80
|
# true
|
78
81
|
# )
|
79
82
|
#
|
80
|
-
# TODO params should be parameterized with field mappings
|
81
83
|
def update_batch(key_id, params = [], create_if_not_exists = false)
|
82
84
|
path = "contact#{create_if_not_exists ? '/?create_if_not_exists=1' : ''}"
|
83
|
-
|
85
|
+
converted_params = params.map do |p|
|
86
|
+
Emarsys::ParamsConverter.new(p).convert_to_ids
|
87
|
+
end
|
88
|
+
put path, {'key_id' => transform_key_id(key_id), 'contacts' => converted_params}
|
84
89
|
end
|
85
90
|
|
86
91
|
# Get list of emails send to a contact
|
data/lib/emarsys/version.rb
CHANGED
@@ -40,6 +40,13 @@ describe Emarsys::Contact do
|
|
40
40
|
Emarsys::Contact.create_batch(3, stub_params)
|
41
41
|
expect(stub).to have_been_requested.once
|
42
42
|
end
|
43
|
+
it "transforms identifiers to IDs for each contact parameter set" do
|
44
|
+
given_params = [{'_firstname' => 'Jane', '_lastname' => "Doe"}, {'_firstname' => 'Paul', '_lastname' => 'Tester'}]
|
45
|
+
expected_params = [{1 => 'Jane', 2 => "Doe"}, {1 => 'Paul', 2 => 'Tester'}]
|
46
|
+
stub = stub_request(:post, "https://api.emarsys.net/api/v2/contact").with(:body => {'key_id' => 3, 'contacts' => expected_params}.to_json).to_return(standard_return_body)
|
47
|
+
Emarsys::Contact.create_batch('_email', given_params)
|
48
|
+
expect(stub).to have_been_requested.once
|
49
|
+
end
|
43
50
|
end
|
44
51
|
|
45
52
|
describe ".update_batch" do
|
@@ -49,6 +56,13 @@ describe Emarsys::Contact do
|
|
49
56
|
Emarsys::Contact.update_batch(3, stub_params)
|
50
57
|
expect(stub).to have_been_requested.once
|
51
58
|
end
|
59
|
+
it "transforms identifiers to IDs for each contact parameter set" do
|
60
|
+
given_params = [{'_firstname' => 'Jane', '_lastname' => "Doe"}, {'_firstname' => 'Paul', '_lastname' => 'Tester'}]
|
61
|
+
expected_params = [{1 => 'Jane', 2 => "Doe"}, {1 => 'Paul', 2 => 'Tester'}]
|
62
|
+
stub = stub_request(:put, "https://api.emarsys.net/api/v2/contact").with(:body => {'key_id' => 3, 'contacts' => expected_params}.to_json).to_return(standard_return_body)
|
63
|
+
Emarsys::Contact.update_batch('_email', given_params)
|
64
|
+
expect(stub).to have_been_requested.once
|
65
|
+
end
|
52
66
|
it "may create non-existing contacts" do
|
53
67
|
stub_params = [{1 => 'Jane', 2 => "Doe"}, {1 => 'Paul', 2 => 'Tester'}]
|
54
68
|
stub = stub_request(:put, "https://api.emarsys.net/api/v2/contact/?create_if_not_exists=1").with(:body => {'key_id' => 3, 'contacts' => stub_params}.to_json).to_return(standard_return_body)
|
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.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Schoppmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|