emarsys 0.3.12 → 0.3.13

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: c1de1c48fb3545c89c9fdb3fc80ebfa2c19682b6
4
- data.tar.gz: 6cf4f2051c2682ef2142b1dc7ce0975bc5f7fb93
3
+ metadata.gz: 438c871d801d4782d2e87ed2fc095847b5323a64
4
+ data.tar.gz: 9d01a343ecb897f827d3b0e543fb08382e73d540
5
5
  SHA512:
6
- metadata.gz: f4380603561017185eb9d64ac71dbd34e59a77248c764bf0912c8613c48e76817e701e7ac73236aa9fcb2021b144d7250fb2aab1aa28670b8f0c498c605d6518
7
- data.tar.gz: 86b1102c8b9e66dbbaeddfe35464516e9100c77f32f505637ab76023ed2ec6a512397746837060be2abdb4c514abc07bed01f253427d51021f53c218b1fd5524
6
+ metadata.gz: c1b1ae69f75b6d77168dee74a56166942266084119f7ba169b3eecf7726bfdd6ef1d4e810195b014bcf3564d6a97f3e1bb1e254638abf0545d54f9ee4e0d7844
7
+ data.tar.gz: f846c1d9637cf3050fca1b249df4023f1ea6e2f766cec60eb3c46f8ddb9b53b41c91ca47df081d9fa2f4f0f6384c52152b8d11402c5859808d879da38b5cea52
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.3.13
4
+
5
+ * Add method to delete ContactList by ID ([#63](https://github.com/Absolventa/emarsys-rb/pull/63))
6
+ * Use correct endpoint in ContactList.remove_contacts ([#62](https://github.com/Absolventa/emarsys-rb/pull/62))
7
+ * Improved Contact.query method ([#61](https://github.com/Absolventa/emarsys-rb/pull/61))
8
+
9
+ ## v0.3.12
10
+
11
+ * Documentation update for Segments (change to README only)
12
+
13
+ ## v0.3.11
14
+
15
+ * Add support for Segments API ([#58](https://github.com/Absolventa/emarsys-rb/pull/58))
16
+
3
17
  ## v0.3.10
4
18
 
5
19
  * Fix 'Invalid Password' error ([#55](https://github.com/Absolventa/emarsys-rb/pull/55))
data/README.md CHANGED
@@ -158,6 +158,9 @@ Emarsys::ContactList.collection
158
158
 
159
159
  # Create a contact list
160
160
  Emarsys::ContactList.create
161
+
162
+ # Delete a contact list
163
+ Emarsys::ContactList.delete(123)
161
164
  ```
162
165
 
163
166
  #### Emails
@@ -121,15 +121,27 @@ module Emarsys
121
121
 
122
122
  # Query contacts by custom
123
123
  #
124
- # @param key_id [Integer, String] The key used to query
125
- # @param key_value [String] Value of internal id field
126
124
  # @param return_value [Integer, String] Value of internal id field
125
+ # @param account [String] The account to use
126
+ # @param opts [Mixed] Further symbols to pass down to the request
127
127
  # @return [Hash] result data
128
128
  # @example
129
- # Emarsys::Contact.query('3', 'john.doe@example.com', 'uid')
130
- #
131
- def query(key_id:, key_value:, return_value: , account: nil)
132
- get account, "contact/query", { key_id => key_value, 'return' => return_value}
129
+ # # Get all emails from the emarsys account
130
+ # Emarsys::Contact.query(return_value: 'email')
131
+ # # Get the ID of the account with a specific email
132
+ # Emarsys::Contact.query(key_id: '_email', key_value: 'john.doe@example.com', return_value: 'email')
133
+ # Emarsys::Contact.query(key_id: 3, key_value: 'jane.doe@example.com', return_value: 'email')
134
+ def query(return_value:, account: nil, **opts)
135
+ if opts.key?(:key_id) && opts.key?(:key_value)
136
+ id, value = [opts.delete(:key_id), opts.delete(:key_value)]
137
+ opts["#{transform_key_id(id).to_s}"] = value
138
+ end
139
+
140
+ opts = opts.each_with_object({}) do |(key, val), memo|
141
+ memo[key.to_s] = val
142
+ end
143
+
144
+ get account, 'contact/query', opts.merge('return' => return_value)
133
145
  end
134
146
 
135
147
  # Exports the selected fields of contacts whoch registered in the specified time range
@@ -29,6 +29,16 @@ module Emarsys
29
29
  post account, "contactlist", params
30
30
  end
31
31
 
32
+ # Delete a contact list
33
+ #
34
+ # @param id [Integer] Internal contact list id
35
+
36
+ # @example
37
+ # Emarsys::ContactList.delete(751283429)
38
+ def delete(id, account: nil)
39
+ post account, "contactlist/#{id}/deletelist", {}
40
+ end
41
+
32
42
  # Add a contacts to a specific contact list
33
43
  #
34
44
  # This cannot be an instance method, because the API does not allow to retrieve a single resource. How crappy is that?
@@ -40,7 +50,7 @@ module Emarsys
40
50
  #
41
51
  # This cannot be an instance method, because the API does not allow to retrieve a single resource. How crappy is that?
42
52
  def remove_contacts(id, key_id:, external_ids: [], account: nil)
43
- post account, "contactlist/#{id}/remove", {'key_id' => key_id, 'external_ids' => external_ids}
53
+ post account, "contactlist/#{id}/delete", {'key_id' => key_id, 'external_ids' => external_ids}
44
54
  end
45
55
 
46
56
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Emarsys
3
- VERSION = "0.3.12"
3
+ VERSION = "0.3.13"
4
4
  end
@@ -102,6 +102,18 @@ describe Emarsys::Contact do
102
102
  Emarsys::Contact.query(key_id: 3, key_value: 'jane.doe@example.com', return_value: 'email')
103
103
  expect(stub).to have_been_requested.once
104
104
  end
105
+
106
+ it "transforms the key_id correctly to its id" do
107
+ stub = stub_request(:get, "https://api.emarsys.net/api/v2/contact/query/?3=jane.doe@example.com&return=email").to_return(standard_return_body)
108
+ Emarsys::Contact.query(key_id: '_email', key_value: 'jane.doe@example.com', return_value: 'email')
109
+ expect(stub).to have_been_requested.once
110
+ end
111
+
112
+ it "allows to get all contacts" do
113
+ stub = stub_request(:get, "https://api.emarsys.net/api/v2/contact/query/?return=email").to_return(standard_return_body)
114
+ Emarsys::Contact.query(return_value: 'email')
115
+ expect(stub).to have_been_requested.once
116
+ end
105
117
  end
106
118
 
107
119
  describe ".export_registrations" do
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.12
4
+ version: 0.3.13
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-08-24 00:00:00.000000000 Z
11
+ date: 2019-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client