mailjet 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mailjet/resource.rb +24 -11
- data/lib/mailjet/version.rb +1 -1
- 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: 0caf5b8f84f19dcfddd140a77d3912e0e6ee1672
|
4
|
+
data.tar.gz: a5cd66471eb7a399882b33ac4fd347c2f16698a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38c9e20e47f52baf3746f61e898c579692801d05a13c1dc69c8991bae21573c6f2a4c07da87eb580bec8beab52eb044cda671e108b605fcbc7aae130f4215309
|
7
|
+
data.tar.gz: 2d96779dee5a705fd311fa3a9502f9fa1c502b67348d0fd85c45211c45553d9cb81a04d30ab8f297248cdff78a74f64ab6cf135f7d85ab119fa1ebb6f7269dde
|
data/lib/mailjet/resource.rb
CHANGED
@@ -245,22 +245,24 @@ module Mailjet
|
|
245
245
|
|
246
246
|
def save(options)
|
247
247
|
if persisted?
|
248
|
+
# case where the entity is updated
|
248
249
|
response = connection(options)[attributes[:id]].put(formatted_payload, default_headers, options[:perform_api_call])
|
249
250
|
else
|
251
|
+
# case where the entity is created
|
250
252
|
response = connection(options).post(formatted_payload, default_headers, options[:perform_api_call])
|
251
253
|
end
|
252
254
|
|
253
|
-
if options[:perform_api_call]
|
254
|
-
|
255
|
-
|
256
|
-
|
255
|
+
if options[:perform_api_call] && !persisted?
|
256
|
+
# get attributes only for entity creation
|
257
|
+
self.attributes = if self.resource_path == 'send'
|
258
|
+
ActiveSupport::JSON.decode(response)
|
259
|
+
else
|
260
|
+
parse_api_json(response).first
|
257
261
|
end
|
258
|
-
|
259
|
-
self.attributes = parse_api_json(response).first
|
260
|
-
return true
|
261
|
-
else
|
262
|
-
return true
|
263
262
|
end
|
263
|
+
|
264
|
+
return true
|
265
|
+
|
264
266
|
rescue Mailjet::ApiError => e
|
265
267
|
if e.code.to_s == "304"
|
266
268
|
return true # When you save a record twice it should not raise error
|
@@ -280,8 +282,19 @@ module Mailjet
|
|
280
282
|
end
|
281
283
|
|
282
284
|
def update_attributes(attribute_hash = {}, options = {})
|
283
|
-
self.attributes
|
284
|
-
|
285
|
+
self.attributes.deep_merge!(attribute_hash) do |key, old, new|
|
286
|
+
if old.is_a?(Array) && new.is_a?(Array)
|
287
|
+
# uniqueness of hashes based on their value of "Name"
|
288
|
+
(new + old).uniq do |data|
|
289
|
+
data["Name"]
|
290
|
+
end
|
291
|
+
else
|
292
|
+
new
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
opts = self.class.change_resource_path(options)
|
297
|
+
save(opts)
|
285
298
|
end
|
286
299
|
|
287
300
|
def delete(call)
|
data/lib/mailjet/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailjet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Nappy
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2017-05-
|
14
|
+
date: 2017-05-26 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|