mailjet 1.7.0 → 1.7.1

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: bc1910e3eb07e5791f26146c52c3dd87740cf3cb49dc3a9689294377dd6c511c
4
+ data.tar.gz: df6a8b03c02ff54e62489fd41803d738dfbbee3daeb3899b173be17bbc3c64fb
5
5
  SHA512:
6
- metadata.gz: 7c10c72fd4adf737b4e80c73b1c2c18daf7a0e0490426041abfbcaf3c918c29d72098a1114941d027e2befdcb77297691941a2f11c16e1372dd9037f9a163eab
7
- data.tar.gz: ac4d539fcb23e3496d232fc51cfdf24170142b48b87ee0c448bd6457cda985e6f8635c38b6252aea87782fdb93363363030e247c9c24eb2d14a8caf7d64caff0
6
+ metadata.gz: a041287e3f47313fb2b433ecbf2431c48a58bc45b59e6bf91ac0ac83d69ff0568ec3480bc98deff2c62fa15ef7ca5e18722171574717852db51df941c25db820
7
+ data.tar.gz: 7ccac7db9d9f6f5f6d83d3c28fdcfefbfee174055d5e9e9916274b5cfba9f5df0766e94c67c9207938e070d1fde1b21d6252d67de041f9f86ccb65f7b14cecda
@@ -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,7 +25,7 @@ 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
 
29
31
  def self.connection(options = {})
@@ -316,6 +318,7 @@ module Mailjet
316
318
  payload = attributes.reject { |k,v| v.blank? }
317
319
  if persisted?
318
320
  payload = payload.slice(*resourceprop.map(&:to_s))
321
+ .except(*read_only_attributes.map(&:to_s))
319
322
  end
320
323
  payload = camelcase_keys(payload)
321
324
  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.1"
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.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: 2022-04-22 00:00:00.000000000 Z
14
+ date: 2022-08-28 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