mailjet 1.7.3 → 1.7.8

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: 8196f5f49e3b7aa6766ad97b0e8a2346c4591f56f30a37e124a346ba46e06f3b
4
- data.tar.gz: b7264d284ac5267785d26c0d8a14810f714ea74893f52eb8d82dc049347b1883
3
+ metadata.gz: aa7ab8289156e4e9277f016b2e75195de319fcdfc772e3f3de7c1b227ab52a48
4
+ data.tar.gz: 30de5a68c95d2dbfe3474fa3cb9d01e1b897dcea43cba3ea02acdf5c7741cfc4
5
5
  SHA512:
6
- metadata.gz: e2c289c1757e6cbc7980296b2de8b9bf7052dbea80265e93d4131a8b8de720c11daa07e83d1ca0d42f4acbc8e637ed387130ca6cf12efbf896e089fb460cc4f8
7
- data.tar.gz: 7502fade84d6f8690394c3a911dfdb48786d21a3414a79416436a04da69aba2f0450b35ea1912b586c69126d6b3052573c3b29a8f3929c969b3d97c3bb0d76ad
6
+ metadata.gz: f9b4217fd1bccc44eb887e14532f5f1c8036bafc98d714743d22deac6e25fa3213d9dd8164e34a4fa3165a6b42a0503790d7d04cb3eafc0862788e2392c6ef27
7
+ data.tar.gz: '08ac1f8b54f6b5e34bbd6b1bd45af8a8bcb10714a1e488ce7a9b648b309d468aaba3dd9ac6a101994e6fc5ae65d8a97957603156848c0eba12c12a1b352e2d0e'
data/README.md CHANGED
@@ -76,7 +76,7 @@ Check out all the resources and Ruby code examples in the [Offical Documentation
76
76
 
77
77
  This library requires **Ruby v2.2.X**.
78
78
 
79
- The Rails ActionMailer integration is designed for Rails 3.X and 4.X.
79
+ The Rails ActionMailer integration is designed for Rails >= 5.
80
80
 
81
81
  ## Installation
82
82
 
@@ -139,7 +139,7 @@ Here's an example on how to send an email:
139
139
  require 'mailjet'
140
140
  Mailjet.configure do |config|
141
141
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
142
- config.secret_key = ENV['MJ_APIKEY_PRIVATE']
142
+ config.secret_key = ENV['MJ_APIKEY_PRIVATE']
143
143
  config.api_version = "v3.1"
144
144
  end
145
145
  variable = Mailjet::Send.create(messages: [{
@@ -177,7 +177,7 @@ Since most Email API endpoints are located under `v3`, it is set as the default
177
177
  require 'mailjet'
178
178
  Mailjet.configure do |config|
179
179
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
180
- config.secret_key = ENV['MJ_APIKEY_PRIVATE']
180
+ config.secret_key = ENV['MJ_APIKEY_PRIVATE']
181
181
  config.api_version = "v3.1"
182
182
  end
183
183
  ```
@@ -189,7 +189,7 @@ The default base domain name for the Mailjet API is `https://api.mailjet.com`. Y
189
189
  ```ruby
190
190
  Mailjet.configure do |config|
191
191
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
192
- config.secret_key = ENV['MJ_APIKEY_PRIVATE']
192
+ config.secret_key = ENV['MJ_APIKEY_PRIVATE']
193
193
  config.api_version = "v3.1"
194
194
  config.end_point = "https://api.us.mailjet.com"
195
195
  end
@@ -221,7 +221,7 @@ Use the `create` method of the Mailjet CLient (i.e. `variable = Mailjet::$resour
221
221
  require 'mailjet'
222
222
  Mailjet.configure do |config|
223
223
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
224
- config.secret_key = ENV['MJ_APIKEY_PRIVATE']
224
+ config.secret_key = ENV['MJ_APIKEY_PRIVATE']
225
225
  end
226
226
  variable = Mailjet::Contact.create(email: "Mister@mailjet.com"
227
227
  )
@@ -239,7 +239,7 @@ Use `id` to specify the ID you want to apply a POST request to (used in case of
239
239
  require 'mailjet'
240
240
  Mailjet.configure do |config|
241
241
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
242
- config.secret_key = ENV['MJ_APIKEY_PRIVATE']
242
+ config.secret_key = ENV['MJ_APIKEY_PRIVATE']
243
243
  end
244
244
  variable = Mailjet::Contact_managecontactslists.create(id: $ID, contacts_lists: [{
245
245
  'ListID'=> '$ListID_1',
@@ -285,7 +285,7 @@ Use the `.find` method to retrieve a specific object. Specify the ID of the obje
285
285
  require 'mailjet'
286
286
  Mailjet.configure do |config|
287
287
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
288
- config.secret_key = ENV['MJ_APIKEY_PRIVATE']
288
+ config.secret_key = ENV['MJ_APIKEY_PRIVATE']
289
289
  end
290
290
  variable = Mailjet::Contact.find($CONTACT_EMAIL)
291
291
  p variable.attributes['Data']
@@ -483,6 +483,17 @@ UserMailer.welcome_email.deliver_now!
483
483
 
484
484
  For more information on `ActionMailer::MessageDelivery`, see the documentation [HERE](http://edgeapi.rubyonrails.org/classes/ActionMailer/MessageDelivery.html)
485
485
 
486
+ #### Manage contacts via CSV Upload
487
+ Create the CSV content in a format compatible with the Mailjet API, see the documentation [HERE](https://dev.mailjet.com/email/guides/contact-management/#manage-contacts-via-csv-upload)
488
+ ```ruby
489
+ Mailjet::ContactslistCsv.send_data(ID_CONTACTLIST, File.open('some_csvdata.csv', 'r'))
490
+ ```
491
+
492
+ #### [Delete the Contact](https://dev.mailjet.com/email/guides/contact-management/#gdpr-delete-contacts)
493
+ ```ruby
494
+ Mailjet::ContactPii.delete(contact_ID)
495
+ ```
496
+
486
497
  ## Track email delivery
487
498
 
488
499
  You can setup your Rack application in order to receive feedback on emails you sent (clicks, etc.)
@@ -1,6 +1,5 @@
1
1
  require 'rest_client'
2
- require 'mailjet/gem_extensions/rest_client'
3
- require 'json'
2
+ require 'yajl/json_gem'
4
3
 
5
4
  module Mailjet
6
5
  class Connection
@@ -92,9 +91,11 @@ module Mailjet
92
91
  end
93
92
 
94
93
  def handle_exception(e, additional_headers, payload = {})
94
+ return e.http_body if e.http_headers[:content_type].include?("text/plain")
95
+
95
96
  params = additional_headers[:params] || {}
96
97
  formatted_payload = (additional_headers[:content_type] == :json) ? JSON.parse(payload) : payload
97
- params = params.merge(formatted_payload)
98
+ params = params.merge!(formatted_payload) if formatted_payload.is_a?(Hash)
98
99
 
99
100
  http_body = if e.http_headers[:content_type].include?("application/json")
100
101
  e.http_body
@@ -105,8 +106,22 @@ module Mailjet
105
106
  if sent_invalid_email?(e.http_body, @adapter.url)
106
107
  return e.http_body
107
108
  else
108
- raise Mailjet::ApiError.new(e.http_code, http_body, @adapter, @adapter.url, params)
109
+ raise communication_error(e)
110
+ end
111
+ end
112
+
113
+ def communication_error(e)
114
+ if e.respond_to?(:response) && e.response
115
+ return case e.response.code
116
+ when Unauthorized::CODE
117
+ Unauthorized.new(e.message, e.response)
118
+ when BadRequest::CODE
119
+ BadRequest.new(e.message, e.response)
120
+ else
121
+ CommunicationError.new(e.message, e.response)
122
+ end
109
123
  end
124
+ CommunicationError.new(e.message)
110
125
  end
111
126
 
112
127
  def sent_invalid_email?(error_http_body, url)
@@ -0,0 +1,93 @@
1
+ require 'yajl/json_gem'
2
+
3
+ module Mailjet
4
+ class Error < StandardError
5
+ attr_reader :object
6
+
7
+ def initialize(message = nil, object = nil)
8
+ super(message)
9
+ @object = object
10
+ end
11
+ end
12
+
13
+ class ApiError < StandardError
14
+ attr_reader :code, :reason
15
+
16
+ # @param code [Integer] HTTP response status code
17
+ # @param body [String] JSON response body
18
+ # @param request [Object] any request object
19
+ # @param url [String] request URL
20
+ # @param params [Hash] request headers and parameters
21
+ def initialize(code, body, request, url, params)
22
+ @code = code
23
+ @reason = begin
24
+ resdec = JSON.parse(body)
25
+ resdec['ErrorMessage']
26
+ rescue JSON::ParserError
27
+ body
28
+ end
29
+
30
+ if request.respond_to?(:options)
31
+ request.options[:user] = '***'
32
+ request.options[:password] = '***'
33
+ end
34
+
35
+ message = "error #{code} while sending #{request.inspect} to #{url} with #{params.inspect}"
36
+ error_details = body.inspect
37
+ hint = "Please see https://dev.mailjet.com/email/reference/overview/errors/ for more informations on error numbers."
38
+
39
+ super("#{message}\n\n#{error_details}\n\n#{hint}\n\n")
40
+ end
41
+ end
42
+
43
+ class CommunicationError < Error
44
+ attr_reader :code
45
+
46
+ NOCODE = 000
47
+
48
+ def initialize(message = nil, response = nil)
49
+ @response = response
50
+ @code = if response.nil?
51
+ NOCODE
52
+ else
53
+ response.code
54
+ end
55
+
56
+ api_message = begin
57
+ JSON.parse(response.body)['ErrorMessage']
58
+ rescue Yajl::ParseError
59
+ response.body
60
+ rescue NoMethodError
61
+ "Unknown API error"
62
+ rescue
63
+ 'Unknown API error'
64
+ end
65
+
66
+ message ||= ''
67
+ api_message ||= ''
68
+ message = message + ': ' + api_message
69
+
70
+ super(message, response)
71
+ rescue NoMethodError, JSON::ParserError
72
+ @code = NOCODE
73
+ super(message, response)
74
+ end
75
+ end
76
+
77
+ class Unauthorized < CommunicationError
78
+ CODE = 401
79
+
80
+ def initialize(error_message, response)
81
+ error_message = error_message + ' - Invalid Domain or API key'
82
+ super(error_message, response)
83
+ end
84
+ end
85
+
86
+ class BadRequest < CommunicationError
87
+ CODE = 400
88
+
89
+ def initialize(error_message, response)
90
+ super(error_message, response)
91
+ end
92
+ end
93
+ end
@@ -1,7 +1,8 @@
1
1
  require 'action_mailer'
2
2
  require 'mail'
3
3
  require 'base64'
4
- require 'json'
4
+ require 'yajl/json_gem'
5
+
5
6
 
6
7
  # Mailjet::Mailer enables to send a Mail::Message via Mailjet SMTP relay servers
7
8
  # User is the API key, and password the API secret
@@ -15,7 +16,7 @@ class Mailjet::Mailer < ::Mail::SMTP
15
16
  user_name: options.delete(:api_key) || Mailjet.config.api_key,
16
17
  password: options.delete(:secret_key) || Mailjet.config.secret_key,
17
18
  enable_starttls_auto: true
18
- }.merge(options))
19
+ }.merge!(options))
19
20
  end
20
21
  end
21
22
 
@@ -202,9 +203,7 @@ class Mailjet::APIMailer
202
203
 
203
204
  payload = {
204
205
  :To=> to,
205
- }.merge(content)
206
- .merge(base_from)
207
- .merge(@delivery_method_options_v3_1)
206
+ }.merge!(content, base_from, @delivery_method_options_v3_1)
208
207
 
209
208
  payload[:Subject] = mail.subject if !mail.subject.blank?
210
209
  payload[:Sender] = mail[:sender] if !mail[:sender].blank?
@@ -294,9 +293,7 @@ class Mailjet::APIMailer
294
293
  payload[:bcc] = mail[:bcc].formatted.join(', ') if mail[:bcc]
295
294
 
296
295
  # Send the final payload to Mailjet Send API
297
- payload.merge(content)
298
- .merge(base_from)
299
- .merge(@delivery_method_options_v3_0)
296
+ payload.merge!(content, base_from, @delivery_method_options_v3_0)
300
297
  end
301
298
  end
302
299
 
@@ -1,5 +1,5 @@
1
1
  require 'rack/request'
2
- require 'json'
2
+ require 'yajl/json_gem'
3
3
 
4
4
  module Mailjet
5
5
  module Rack
@@ -1,11 +1,9 @@
1
1
  require 'mailjet/connection'
2
+ require 'yajl/json_gem'
3
+ require 'active_support'
2
4
  require 'active_support/core_ext/string'
3
- require 'active_support/core_ext/module/delegation'
4
- #require 'mail'
5
- require 'active_support/hash_with_indifferent_access'
6
- require 'active_support/core_ext/hash'
7
- require 'active_support/json/decoding'
8
- require 'json'
5
+ require 'active_support/core_ext/hash/indifferent_access'
6
+
9
7
 
10
8
 
11
9
  # This option automatically transforms the date output by the API into something a bit more readable.
@@ -16,11 +14,11 @@ require 'json'
16
14
 
17
15
  module Mailjet
18
16
  module Resource
19
-
20
17
  # define here available options for filtering
21
18
  OPTIONS = [:version, :url, :perform_api_call, :api_key, :secret_key, :read_timeout, :open_timeout]
22
19
 
23
20
  NON_JSON_URLS = ['v3/send/message'] # urls that don't accept JSON input
21
+ DATA_URLS = ['plain', 'csv'] # url for send binary data , 'CSVError/text:csv'
24
22
 
25
23
  def self.included(base)
26
24
  base.extend ClassMethods
@@ -49,10 +47,13 @@ module Mailjet
49
47
  def self.default_headers
50
48
  if NON_JSON_URLS.include?(self.resource_path) # don't use JSON if Send API
51
49
  default_headers = { accept: :json, accept_encoding: :deflate }
50
+ elsif DATA_URLS.any? { |data_type| default_headers = { content_type: "text/#{data_type}" } if
51
+ self.resource_path.include?(data_type)
52
+ }
52
53
  else
53
54
  default_headers = { accept: :json, accept_encoding: :deflate, content_type: :json } #use JSON if *not* Send API
54
55
  end
55
- return default_headers.merge(user_agent: "mailjet-api-v3-ruby/#{Gem.loaded_specs["mailjet"].version}")
56
+ return default_headers.merge!(user_agent: "mailjet-api-v3-ruby/#{Gem.loaded_specs["mailjet"].version}")
56
57
  end
57
58
  end
58
59
  end
@@ -60,21 +61,27 @@ module Mailjet
60
61
  module ClassMethods
61
62
  def first(params = {}, options = {})
62
63
  all(params.merge!(limit: 1), options).first
64
+ rescue Mailjet::ApiError => error
65
+ raise error
63
66
  end
64
67
 
65
68
  def all(params = {}, options = {})
66
69
  opts = define_options(options)
67
70
  params = format_params(params)
68
- response = connection(opts).get(default_headers.merge(params: params))
71
+ response = connection(opts).get(default_headers.merge!(params: params))
69
72
  attribute_array = parse_api_json(response)
70
73
  attribute_array.map{ |attributes| instanciate_from_api(attributes) }
74
+ rescue Mailjet::ApiError => error
75
+ raise error
71
76
  end
72
77
 
73
78
  def count(options = {})
74
79
  opts = define_options(options)
75
- response_json = connection(opts).get(default_headers.merge(params: {limit: 1, countrecords: 1}))
80
+ response_json = connection(opts).get(default_headers.merge!(params: {limit: 1, countrecords: 1}))
76
81
  response_hash = JSON.parse(response_json)
77
82
  response_hash['Total']
83
+ rescue Mailjet::ApiError => error
84
+ raise error
78
85
  end
79
86
 
80
87
  def find(id, job_id = nil, options = {})
@@ -87,11 +94,11 @@ module Mailjet
87
94
  # if action method, ammend url to appropriate id
88
95
  opts = define_options(options)
89
96
  self.resource_path = create_action_resource_path(normalized_id, job_id) if self.action
90
- #
97
+
91
98
  attributes = parse_api_json(connection(opts)[normalized_id].get(default_headers)).first
92
99
  instanciate_from_api(attributes)
93
100
 
94
- rescue Mailjet::ApiError => e
101
+ rescue Mailjet::CommunicationError => e
95
102
  if e.code == 404
96
103
  nil
97
104
  else
@@ -118,7 +125,6 @@ module Mailjet
118
125
  resource.save!(opts)
119
126
  resource.attributes[:persisted] = true
120
127
  end
121
-
122
128
  end
123
129
 
124
130
  def delete(id, options = {})
@@ -126,10 +132,28 @@ module Mailjet
126
132
  opts = define_options(options)
127
133
  self.resource_path = create_action_resource_path(id) if self.action
128
134
  connection(opts)[id].delete(default_headers)
135
+ rescue Mailjet::ApiError => error
136
+ raise error
137
+ end
138
+
139
+ def send_data(id, binary_data = nil, options = {})
140
+ opts = define_options(options)
141
+ self.resource_path = create_action_resource_path(id) if self.action
142
+
143
+ response_hash = JSON.parse(connection(opts).post(binary_data, default_headers))
144
+ response_hash['ID'] ? response_hash['ID'] : response_hash
145
+ end
146
+
147
+ def find_by_id(id, options = {})
148
+ # if action method, ammend url to appropriate id
149
+ opts = define_options(options)
150
+ self.resource_path = create_action_resource_path(id) if self.action
151
+
152
+ connection(opts).get(default_headers)
129
153
  end
130
154
 
131
155
  def instanciate_from_api(attributes = {})
132
- self.new(attributes.merge(persisted: true))
156
+ self.new(attributes.merge!(persisted: true))
133
157
  end
134
158
 
135
159
  def parse_api_json(response_json)
@@ -169,9 +193,9 @@ module Mailjet
169
193
  case data
170
194
  when nil
171
195
  nil
172
- when /^(?:\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[T \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?))$/
196
+ when /^(?:\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[T \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?))$/
173
197
  begin
174
- DateTime.parse(data)
198
+ DateTime.iso8601(data)
175
199
  rescue ArgumentError
176
200
  data
177
201
  end
@@ -16,7 +16,7 @@ module Mailjet
16
16
  raw_data.map do |entity|
17
17
  instanciate_from_api(entity)
18
18
  end
19
- rescue Mailjet::ApiError => e
19
+ rescue Mailjet::CommunicationError => e
20
20
  if e.code == 404
21
21
  nil
22
22
  else
@@ -16,7 +16,7 @@ module Mailjet
16
16
  raw_data.map do |entity|
17
17
  instanciate_from_api(entity)
18
18
  end
19
- rescue Mailjet::ApiError => e
19
+ rescue Mailjet::CommunicationError => e
20
20
  if e.code == 404
21
21
  nil
22
22
  else
@@ -0,0 +1,8 @@
1
+ module Mailjet
2
+ class ContactPii
3
+ include Mailjet::Resource
4
+ self.version = 'v4'
5
+ self.resource_path = 'contacts'
6
+ self.public_operations = [:delete]
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Mailjet
2
+ class ContactslistCsv
3
+ include Mailjet::Resource
4
+ self.action = "DATA/contactslist"
5
+ self.resource_path = "#{self.action}/id/CSVData/text:plain"
6
+ self.public_operations = [:post]
7
+ end
8
+ end
@@ -5,6 +5,5 @@ module Mailjet
5
5
  self.public_operations = [:get, :put, :post]
6
6
  self.filters = []
7
7
  self.resourceprop = [:alive_at, :contacts_list, :count, :current, :data_id, :errcount, :err_treshold, :id, :import_options, :job_end, :job_start, :method, :request_at, :status]
8
-
9
8
  end
10
9
  end
@@ -17,7 +17,7 @@ module Mailjet
17
17
  raw_data.map do |entity|
18
18
  instanciate_from_api(entity)
19
19
  end
20
- rescue Mailjet::ApiError => e
20
+ rescue Mailjet::CommunicationError => e
21
21
  if e.code == 404
22
22
  nil
23
23
  else
@@ -17,7 +17,7 @@ module Mailjet
17
17
  raw_data.map do |entity|
18
18
  instanciate_from_api(entity)
19
19
  end
20
- rescue Mailjet::ApiError => e
20
+ rescue Mailjet::CommunicationError => e
21
21
  if e.code == 404
22
22
  nil
23
23
  else
@@ -17,7 +17,7 @@ module Mailjet
17
17
  raw_data.map do |entity|
18
18
  instanciate_from_api(entity)
19
19
  end
20
- rescue Mailjet::ApiError => e
20
+ rescue Mailjet::CommunicationError => e
21
21
  if e.code == 404
22
22
  nil
23
23
  else
@@ -0,0 +1,8 @@
1
+ module Mailjet
2
+ class RetrieveErrosCsv
3
+ include Mailjet::Resource
4
+ self.action = "DATA/BatchJob"
5
+ self.resource_path = "#{self.action}/id/CSVError/text:csv"
6
+ self.public_operations = [:get]
7
+ end
8
+ end
@@ -15,7 +15,7 @@ module Mailjet
15
15
  attributes = parse_api_json(response).first
16
16
 
17
17
  instanciate_from_api(attributes)
18
- rescue Mailjet::ApiError => e
18
+ rescue Mailjet::CommunicationError => e
19
19
  if e.code == 404
20
20
  nil
21
21
  else
@@ -1,3 +1,3 @@
1
1
  module Mailjet
2
- VERSION = "1.7.3"
2
+ VERSION = "1.7.8"
3
3
  end
data/lib/mailjet.rb CHANGED
@@ -1,13 +1,11 @@
1
1
  require 'json/ext'
2
- require 'ostruct'
3
- require 'mailjet/core_extensions/ostruct'
2
+ require 'yajl'
4
3
  require 'mailjet/configuration'
5
- require 'mailjet/api_error'
6
4
 
7
5
  require 'mailjet/resource'
8
6
  require 'mailjet/message_delivery'
9
7
 
10
- Dir[File.expand_path("../mailjet/resources/*.rb", __FILE__)].each do |file|
8
+ Dir[File.expand_path("../mailjet/{resources,exception}/*.rb", __FILE__)].each do |file|
11
9
  require file
12
10
  end
13
11
 
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.3
4
+ version: 1.7.8
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: 2023-02-15 00:00:00.000000000 Z
14
+ date: 2024-02-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
@@ -19,14 +19,14 @@ dependencies:
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 3.1.0
22
+ version: 5.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 3.1.0
29
+ version: 5.0.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rack
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -47,44 +47,44 @@ dependencies:
47
47
  requirements:
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: 2.0.0
50
+ version: 2.1.0
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - ">="
56
56
  - !ruby/object:Gem::Version
57
- version: 2.0.0
57
+ version: 2.1.0
58
58
  - !ruby/object:Gem::Dependency
59
- name: actionmailer
59
+ name: yajl-ruby
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - ">="
63
63
  - !ruby/object:Gem::Version
64
- version: 3.0.9
65
- type: :development
64
+ version: '0'
65
+ type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
- version: 3.0.9
71
+ version: '0'
72
72
  - !ruby/object:Gem::Dependency
73
- name: rake
73
+ name: actionmailer
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
76
  - - ">="
77
77
  - !ruby/object:Gem::Version
78
- version: '0'
78
+ version: 5.0.0
79
79
  type: :development
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: '0'
85
+ version: 5.0.0
86
86
  - !ruby/object:Gem::Dependency
87
- name: json
87
+ name: rake
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
90
  - - ">="
@@ -168,12 +168,10 @@ files:
168
168
  - lib/generators/mailjet/initializer_generator.rb
169
169
  - lib/generators/mailjet/templates/mailjet.rb.erb
170
170
  - lib/mailjet.rb
171
- - lib/mailjet/api_error.rb
172
171
  - lib/mailjet/collection_proxy.rb
173
172
  - lib/mailjet/configuration.rb
174
173
  - lib/mailjet/connection.rb
175
- - lib/mailjet/core_extensions/ostruct.rb
176
- - lib/mailjet/gem_extensions/rest_client.rb
174
+ - lib/mailjet/exception/errors.rb
177
175
  - lib/mailjet/mailer.rb
178
176
  - lib/mailjet/message_delivery.rb
179
177
  - lib/mailjet/rack/endpoint.rb
@@ -203,11 +201,13 @@ files:
203
201
  - lib/mailjet/resources/contact_getcontactslists.rb
204
202
  - lib/mailjet/resources/contact_managecontactslists.rb
205
203
  - lib/mailjet/resources/contact_managemanycontacts.rb
204
+ - lib/mailjet/resources/contact_pii.rb
206
205
  - lib/mailjet/resources/contactdata.rb
207
206
  - lib/mailjet/resources/contactfilter.rb
208
207
  - lib/mailjet/resources/contacthistorydata.rb
209
208
  - lib/mailjet/resources/contactmetadata.rb
210
209
  - lib/mailjet/resources/contactslist.rb
210
+ - lib/mailjet/resources/contactslist_csv.rb
211
211
  - lib/mailjet/resources/contactslist_managecontact.rb
212
212
  - lib/mailjet/resources/contactslist_managemanycontacts.rb
213
213
  - lib/mailjet/resources/contactslistsignup.rb
@@ -248,6 +248,7 @@ files:
248
248
  - lib/mailjet/resources/openstatistics.rb
249
249
  - lib/mailjet/resources/parseroute.rb
250
250
  - lib/mailjet/resources/preferences.rb
251
+ - lib/mailjet/resources/retrieve_errors_csv.rb
251
252
  - lib/mailjet/resources/send.rb
252
253
  - lib/mailjet/resources/sender.rb
253
254
  - lib/mailjet/resources/sender_validate.rb
@@ -1,28 +0,0 @@
1
- require "json"
2
-
3
- module Mailjet
4
- class ApiError < StandardError
5
- attr_reader :code, :reason
6
-
7
- # @param code [Integer] HTTP response status code
8
- # @param body [String] JSON response body
9
- # @param request [Object] any request object
10
- # @param url [String] request URL
11
- # @param params [Hash] request headers and parameters
12
- def initialize(code, body, request, url, params)
13
- @code = code
14
- @reason = begin
15
- resdec = JSON.parse(body)
16
- resdec['ErrorMessage']
17
- rescue JSON::ParserError
18
- body
19
- end
20
-
21
- message = "error #{code} while sending #{request.inspect} to #{url} with #{params.inspect}"
22
- error_details = body.inspect
23
- hint = "Please see https://dev.mailjet.com/guides/#status-codes for more informations on error numbers."
24
-
25
- super("#{message}\n\n#{error_details}\n\n#{hint}\n\n")
26
- end
27
- end
28
- end
@@ -1,9 +0,0 @@
1
- class OpenStruct
2
-
3
- # when asked for id, ruby 1.8.7's implementation of OpenStruct returns object's inner id instead of table's value if present. Evilishish infamous Monkey-Patch.
4
- if RUBY_VERSION =~ /1\.8\./
5
- def id
6
- send(:eval, "@table[:id]")
7
- end
8
- end
9
- end
@@ -1,19 +0,0 @@
1
- module RestClient
2
- module Payload
3
- class Base
4
- def flatten_params_array value, calculated_key
5
- result = []
6
- value.each do |elem|
7
- if elem.is_a? Hash
8
- result += flatten_params(elem, calculated_key)
9
- elsif elem.is_a? Array
10
- result += flatten_params_array(elem, calculated_key)
11
- else
12
- result << ["#{calculated_key}", elem]
13
- end
14
- end
15
- result
16
- end
17
- end
18
- end
19
- end