mailjet 1.7.0 → 1.7.2

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
  SHA256:
3
- metadata.gz: bfee84cc597efea5f25e0a7698c37491da287b01283a45719e6d53a7650714db
4
- data.tar.gz: bdc076e42432663e56783b4caef82eb558921f993f12ee681cad59740f217954
3
+ metadata.gz: 8f379dc1214f713aaaa97f3b4f6530655f86905f8a80ad4bccc877793efcaaf8
4
+ data.tar.gz: a8edcae65cef3ab95b3508fd309383e0eb82f83d20c0eacd8eb79bb838aab60a
5
5
  SHA512:
6
- metadata.gz: 7c10c72fd4adf737b4e80c73b1c2c18daf7a0e0490426041abfbcaf3c918c29d72098a1114941d027e2befdcb77297691941a2f11c16e1372dd9037f9a163eab
7
- data.tar.gz: ac4d539fcb23e3496d232fc51cfdf24170142b48b87ee0c448bd6457cda985e6f8635c38b6252aea87782fdb93363363030e247c9c24eb2d14a8caf7d64caff0
6
+ metadata.gz: d090d495b8dc5bfed6011ea7365aec9c357b28a9f03b5d5d199002078d476375cedc6ac289277db1a3d7be57f887b3fdf358d6d8dc294d568e273f37480eec25
7
+ data.tar.gz: 85f44a31d32daea2b4cb3f98f28a2f3fe62f4698c9143561f3f77d85bad7c9c50f87bbb588a0601eb39cbe988999cdd0ee18487e73ab3013772095b5ad0a0508
@@ -96,13 +96,26 @@ module Mailjet
96
96
  formatted_payload = (additional_headers[:content_type] == :json) ? JSON.parse(payload) : payload
97
97
  params = params.merge(formatted_payload)
98
98
 
99
- http_body = if e.http_headers[:content_type] == "application/json"
99
+ http_body = if e.http_headers[:content_type].include?("application/json")
100
100
  e.http_body
101
101
  else
102
102
  "{}"
103
103
  end
104
104
 
105
- raise Mailjet::ApiError.new(e.http_code, http_body, @adapter, @adapter.url, params)
105
+ if sent_invalid_email?(e.http_body, @adapter.url)
106
+ return e.http_body
107
+ else
108
+ raise Mailjet::ApiError.new(e.http_code, http_body, @adapter, @adapter.url, params)
109
+ end
110
+ end
111
+
112
+ def sent_invalid_email?(error_http_body, url)
113
+ return false unless url.include?('v3.1/send')
114
+ return unless error_http_body
115
+
116
+ parsed_body = JSON.parse(error_http_body)
117
+ error_message = parsed_body['Messages']&.first&.dig('Errors')&.first&.dig('ErrorMessage')
118
+ error_message.include?('is an invalid email address.')
106
119
  end
107
120
 
108
121
  end
@@ -1,8 +1,10 @@
1
1
  require 'mailjet/connection'
2
2
  require 'active_support/core_ext/string'
3
3
  require 'active_support/core_ext/module/delegation'
4
- require 'active_support/hash_with_indifferent_access'
5
4
  #require 'mail'
5
+ require 'active_support/hash_with_indifferent_access'
6
+ require 'active_support/core_ext/hash'
7
+ require 'active_support/json/decoding'
6
8
  require 'json'
7
9
 
8
10
 
@@ -23,9 +25,11 @@ module Mailjet
23
25
  def self.included(base)
24
26
  base.extend ClassMethods
25
27
  base.class_eval do
26
- cattr_accessor :resource_path, :public_operations, :read_only, :filters, :resourceprop, :action, :non_json_urls, :version
28
+ cattr_accessor :resource_path, :public_operations, :read_only, :filters, :resourceprop, :read_only_attributes, :action, :non_json_urls, :version
27
29
  cattr_writer :connection
28
30
 
31
+ self.read_only_attributes = []
32
+
29
33
  def self.connection(options = {})
30
34
  class_variable_get(:@@connection) || default_connection(options)
31
35
  end
@@ -316,6 +320,7 @@ module Mailjet
316
320
  payload = attributes.reject { |k,v| v.blank? }
317
321
  if persisted?
318
322
  payload = payload.slice(*resourceprop.map(&:to_s))
323
+ .except(*read_only_attributes.map(&:to_s))
319
324
  end
320
325
  payload = camelcase_keys(payload)
321
326
  payload.tap { |hs| hs.delete("Persisted") }
@@ -4,7 +4,21 @@ module Mailjet
4
4
  self.resource_path = 'REST/contact'
5
5
  self.public_operations = [:get, :put, :post]
6
6
  self.filters = [:campaign, :contacts_list, :is_unsubscribed, :last_activity_at, :recipient, :status]
7
- self.resourceprop = [:created_at, :delivered_count, :email, :id, :is_opt_in_pending, :is_spam_complaining, :last_activity_at, :last_update_at, :name, :unsubscribed_at, :unsubscribed_by]
7
+ self.resourceprop = [
8
+ :created_at,
9
+ :delivered_count,
10
+ :email,
11
+ :id,
12
+ :is_opt_in_pending,
13
+ :is_spam_complaining,
14
+ :last_activity_at,
15
+ :last_update_at,
16
+ :name,
17
+ :unsubscribed_at,
18
+ :unsubscribed_by,
19
+ :is_excluded_from_campaigns
20
+ ]
21
+ self.read_only_attributes = [:created_at, :last_activity_at, :last_update_at, :unsubscribed_at]
8
22
 
9
23
  end
10
24
  end
@@ -0,0 +1,12 @@
1
+ module Mailjet
2
+ class Statistics_linkclick
3
+ include Mailjet::Resource
4
+ self.resource_path = 'REST/statistics/link-click'
5
+ self.public_operations = [:get]
6
+ self.filters = [:campaign_id]
7
+ self.resourceprop = [:url, :position_index, :clicked_messages_count, :clicked_events_count]
8
+
9
+ self.read_only = true
10
+
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module Mailjet
2
- VERSION = "1.7.0"
2
+ VERSION = "1.7.2"
3
3
  end
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.7.0
4
+ version: 1.7.2
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: 2022-04-22 00:00:00.000000000 Z
14
+ date: 2022-12-18 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
@@ -253,6 +253,7 @@ files:
253
253
  - lib/mailjet/resources/sender_validate.rb
254
254
  - lib/mailjet/resources/senderstatistics.rb
255
255
  - lib/mailjet/resources/statcounters.rb
256
+ - lib/mailjet/resources/statistics_linkclick.rb
256
257
  - lib/mailjet/resources/template.rb
257
258
  - lib/mailjet/resources/template_detailcontent.rb
258
259
  - lib/mailjet/resources/toplinkclicked.rb