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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc2e05dfded9bc3e85a484b0a100dd0bbee2c4c3
4
- data.tar.gz: c6a286becd3fb612d9e379f794430e5f8fa6740c
3
+ metadata.gz: 6ae8a2be8a9eb47480f0dfa43f730039a5fc8129
4
+ data.tar.gz: 97ac47f4b22dc3eca4146573fb714aa7c7104280
5
5
  SHA512:
6
- metadata.gz: a27a34fa7afd4d4e182dfa6e6d8948490f8d095cacca5c3fc018d1a45c699588e91ee75fe193ac395c88654f7876e23f73e9df3c0412150d2c5dce05c26556dd
7
- data.tar.gz: c344e9354da2b659f2edb4243d9b5e8a8abce6a124b4b83886bd4ac210cfe2ae564038ef62e639d549529f38ce4988342dc5e414cd0091694d163e5f1314dd4d
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
- post "contact", {'key_id' => transform_key_id(key_id), 'contacts' => params}
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
- put path, {'key_id' => transform_key_id(key_id), 'contacts' => params}
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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Emarsys
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
4
4
  end
@@ -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.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-13 00:00:00.000000000 Z
11
+ date: 2017-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client