mailjet 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +22 -23
- data/Rakefile +1 -19
- data/lib/mailjet/connection.rb +20 -1
- data/lib/mailjet/resource.rb +9 -4
- data/lib/mailjet/version.rb +1 -1
- metadata +5 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 966d15689307bd9561460419db93e8de8e8bcc4cf2f9d392339edfb8c73d1635
|
|
4
|
+
data.tar.gz: 8b2d2d8baaeb3701b743322ecf1d5a209052327c887bab34eabeb4525a8c93b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5f9f8fd4344c61259f7ea13ccf59de0a35ee15cb6a171322dda20033f7f8db8652c3c0cd0f52f04aac6db7aafb676b7341ab581ec82e0d3abe1b41e6e35cf623
|
|
7
|
+
data.tar.gz: b311a067e80b8ba6b14d407c2fdca0c37062862695f243c31973d37d64367ac27637507ddaf1c77ed2360cbca24fe14f74c2d7bf9b623a9fecd97e7faebfb845
|
data/README.md
CHANGED
|
@@ -8,29 +8,15 @@
|
|
|
8
8
|
|
|
9
9
|
[][travis]
|
|
10
10
|
[][gemnasium]
|
|
11
|
-
[][stillmaintained]
|
|
12
12
|

|
|
13
13
|
|
|
14
14
|
-->
|
|
15
15
|
|
|
16
|
-
[travis]:
|
|
16
|
+
[travis]: https://travis-ci.org/jbescoyez/mailjet
|
|
17
17
|
[gemnasium]: https://gemnasium.com/jbescoyez/mailjet
|
|
18
|
-
[stillmaintained]:
|
|
19
|
-
[mailjet]: http://www.mailjet.com
|
|
20
|
-
[rubinius]: http://rubini.us/
|
|
21
|
-
[ree]: http://www.rubyenterpriseedition.com/
|
|
22
|
-
[jruby]: http://jruby.org/
|
|
18
|
+
[stillmaintained]: https://stillmaintained.com/jbescoyez/mailjet
|
|
23
19
|
[mailjetter]: https://github.com/holinnn/mailjetter/
|
|
24
|
-
[activeresource]: https://github.com/rails/activeresource
|
|
25
|
-
[apidoc]: http://dev.mailjet.com/guides
|
|
26
|
-
[apidoc-recipient]: http://mjdemo.poxx.net/~shubham/listrecipient.html?utm_source=github&utm_medium=link&utm_content=readme&utm_campaign=mailjet-gem
|
|
27
|
-
[camelcase-api]: http://api.rubyonrails.org/classes/String.html#method-i-camelcase
|
|
28
|
-
[underscore-api]: http://api.rubyonrails.org/classes/String.html#method-i-underscore
|
|
29
|
-
[actionmailerdoc]: http://guides.rubyonrails.org/action_mailer_basics.html#sending-emails-with-dynamic-delivery-options
|
|
30
|
-
[send-api-doc]: http://dev.mailjet.com/guides/?ruby#choose-sending-method
|
|
31
|
-
[v1-branch]: https://github.com/mailjet/mailjet-gem/tree/v1
|
|
32
|
-
[mailjet_doc]: http://dev.mailjet.com/guides/?ruby#
|
|
33
|
-
[api_doc]: https://github.com/mailjet/api-documentation
|
|
34
20
|
|
|
35
21
|
<!-- You can read this readme file in other languages:
|
|
36
22
|
english | [french](./README.fr.md) -->
|
|
@@ -53,6 +39,7 @@ Check out all the resources and Ruby code examples in the [Offical Documentation
|
|
|
53
39
|
- [Call configuration specifics](#call-configuration-specifics)
|
|
54
40
|
- [API versioning](#api-versioning)
|
|
55
41
|
- [Base URL](#base-url)
|
|
42
|
+
- [Timeouts](#timeouts)
|
|
56
43
|
- [List of resources](#list-of-resources)
|
|
57
44
|
- [Naming conventions](#naming-conventions)
|
|
58
45
|
- [Request examples](#request-examples)
|
|
@@ -201,6 +188,18 @@ end
|
|
|
201
188
|
|
|
202
189
|
If your account has been moved to Mailjet's **US architecture**, the URL value you need to set is `https://api.us.mailjet.com`.
|
|
203
190
|
|
|
191
|
+
Always use an `https://` URL. If `end_point`, or a `url:` passed to a call, starts with `http://`, your API keys travel unencrypted and the gem prints a warning the first time it connects.
|
|
192
|
+
|
|
193
|
+
### Timeouts
|
|
194
|
+
|
|
195
|
+
By default the gem uses Faraday's timeouts. Pass `open_timeout` (seconds to open the connection) and `read_timeout` (seconds to wait for each read) on a call to change them:
|
|
196
|
+
|
|
197
|
+
```ruby
|
|
198
|
+
Mailjet::Contact.all({ limit: 10 }, open_timeout: 2, read_timeout: 10)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
A call that times out raises `Mailjet::CommunicationError`.
|
|
202
|
+
|
|
204
203
|
## List of resources
|
|
205
204
|
|
|
206
205
|
You can find the list of all available resources for this library, as well as their configuration, in [/lib/mailjet/resources](https://github.com/mailjet/mailjet-gem/tree/master/lib/mailjet/resources).
|
|
@@ -436,7 +435,7 @@ Mailjet::Statistics_recipient_esp.all(campaign_id: campaign_id, esp_name: "gmail
|
|
|
436
435
|
|
|
437
436
|
## Send emails with ActionMailer
|
|
438
437
|
|
|
439
|
-
A quick walkthrough to use Rails Action Mailer [here](
|
|
438
|
+
A quick walkthrough to use Rails Action Mailer [here](https://guides.rubyonrails.org/action_mailer_basics.html).
|
|
440
439
|
|
|
441
440
|
First set your delivery method (here Mailjet SMTP relay servers):
|
|
442
441
|
|
|
@@ -446,14 +445,14 @@ config.action_mailer.delivery_method = :mailjet
|
|
|
446
445
|
|
|
447
446
|
```
|
|
448
447
|
|
|
449
|
-
Or if you prefer sending messages through [Mailjet Send API](
|
|
448
|
+
Or if you prefer sending messages through [Mailjet Send API](https://dev.mailjet.com/guides/#send-transactional-email):
|
|
450
449
|
|
|
451
450
|
```ruby
|
|
452
451
|
# application.rb
|
|
453
452
|
config.action_mailer.delivery_method = :mailjet_api
|
|
454
453
|
```
|
|
455
454
|
|
|
456
|
-
You can use Mailjet specific options with `delivery_method_options` as detailed in the official [ActionMailer doc](
|
|
455
|
+
You can use Mailjet specific options with `delivery_method_options` as detailed in the official [ActionMailer doc](https://guides.rubyonrails.org/action_mailer_basics.html#sending-emails-with-dynamic-delivery-options):
|
|
457
456
|
|
|
458
457
|
```ruby
|
|
459
458
|
class AwesomeMailer < ApplicationMailer
|
|
@@ -555,7 +554,7 @@ Hello world in HTML!
|
|
|
555
554
|
Hello world in plain text!
|
|
556
555
|
```
|
|
557
556
|
|
|
558
|
-
There's also the ability to set [Mailjet custom headers](
|
|
557
|
+
There's also the ability to set [Mailjet custom headers](https://dev.mailjet.com/guides/#send-api-json-properties)
|
|
559
558
|
```ruby
|
|
560
559
|
#app/mailers/user_mailer.rb
|
|
561
560
|
class UserMailer < ApplicationMailer
|
|
@@ -577,7 +576,7 @@ For sending email, you can call the method:
|
|
|
577
576
|
UserMailer.welcome_email.deliver_now!
|
|
578
577
|
```
|
|
579
578
|
|
|
580
|
-
For more information on `ActionMailer::MessageDelivery`, see the documentation [HERE](
|
|
579
|
+
For more information on `ActionMailer::MessageDelivery`, see the documentation [HERE](https://edgeapi.rubyonrails.org/classes/ActionMailer/MessageDelivery.html)
|
|
581
580
|
|
|
582
581
|
#### Manage contacts via CSV Upload
|
|
583
582
|
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)
|
|
@@ -594,7 +593,7 @@ Mailjet::ContactPii.delete(contact_ID)
|
|
|
594
593
|
|
|
595
594
|
You can setup your Rack application in order to receive feedback on emails you sent (clicks, etc.)
|
|
596
595
|
|
|
597
|
-
First notify Mailjet of your desired endpoint (say: '
|
|
596
|
+
First notify Mailjet of your desired endpoint (say: 'https://www.my_domain.com/mailjet/callback') at https://app.mailjet.com/account/triggers
|
|
598
597
|
|
|
599
598
|
Then configure Mailjet's Rack application to catch these callbacks.
|
|
600
599
|
|
data/Rakefile
CHANGED
|
@@ -2,25 +2,7 @@ require "rspec/core/rake_task"
|
|
|
2
2
|
require 'bundler/gem_tasks'
|
|
3
3
|
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
5
|
-
t.pattern =
|
|
6
|
-
"spec/mailjet/rack/endpoint_spec.rb",
|
|
7
|
-
"spec/mailjet/api_error_spec.rb",
|
|
8
|
-
"spec/mailjet/apikey_spec.rb",
|
|
9
|
-
"spec/mailjet/mailer_spec.rb",
|
|
10
|
-
"spec/mailjet/resource_spec.rb",
|
|
11
|
-
"spec/configuration_spec.rb",
|
|
12
|
-
"spec/mailjet_spec.rb",
|
|
13
|
-
"spec/resources/contact_spec.rb",
|
|
14
|
-
"spec/resources/contactmetadata_spec.rb",
|
|
15
|
-
"spec/resources/messagehistory_spec.rb",
|
|
16
|
-
"spec/resources/getcontactslists_spec.rb",
|
|
17
|
-
"spec/resources/template_detailcontent_spec.rb",
|
|
18
|
-
"spec/resources/integration_spec.rb",
|
|
19
|
-
"spec/resources/newsletter_spec.rb",
|
|
20
|
-
"spec/resources/statcounters_spec.rb",
|
|
21
|
-
"spec/resources/send_spec.rb",
|
|
22
|
-
"spec/resources/resource_spec.rb",
|
|
23
|
-
]
|
|
5
|
+
t.pattern = "spec/**/*_spec.rb"
|
|
24
6
|
end
|
|
25
7
|
|
|
26
8
|
task default: [:spec]
|
data/lib/mailjet/connection.rb
CHANGED
|
@@ -16,13 +16,25 @@ module Mailjet
|
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
# plain HTTP sends the API keys unencrypted; warn once per process
|
|
20
|
+
def self.warn_if_insecure(end_point)
|
|
21
|
+
return if @insecure_warned
|
|
22
|
+
|
|
23
|
+
origin = end_point.to_s[%r{\Ahttp://[^/]*}i]
|
|
24
|
+
return unless origin
|
|
25
|
+
|
|
26
|
+
@insecure_warned = true
|
|
27
|
+
warn("[mailjet] #{origin} uses plain HTTP, which sends your API keys and data unencrypted. Set end_point or url: to an https:// URL instead.")
|
|
28
|
+
end
|
|
29
|
+
|
|
19
30
|
def initialize(end_point, api_key, secret_key, options = {})
|
|
31
|
+
self.class.warn_if_insecure(end_point)
|
|
20
32
|
self.options = options
|
|
21
33
|
self.api_key = api_key
|
|
22
34
|
self.secret_key = secret_key
|
|
23
35
|
self.public_operations = options[:public_operations] || []
|
|
24
36
|
self.read_only = options[:read_only]
|
|
25
|
-
self.adapter = Faraday.new(end_point,
|
|
37
|
+
self.adapter = Faraday.new(end_point, request: timeout_options) do |conn|
|
|
26
38
|
conn.response :raise_error, include_request: true
|
|
27
39
|
conn.request :authorization, :basic, api_key, secret_key
|
|
28
40
|
conn.headers['Content-Type'] = 'application/json'
|
|
@@ -56,6 +68,13 @@ module Mailjet
|
|
|
56
68
|
|
|
57
69
|
private
|
|
58
70
|
|
|
71
|
+
def timeout_options
|
|
72
|
+
{
|
|
73
|
+
open_timeout: options[:open_timeout],
|
|
74
|
+
read_timeout: options[:read_timeout],
|
|
75
|
+
}.compact
|
|
76
|
+
end
|
|
77
|
+
|
|
59
78
|
def handle_api_call(method, additional_headers = {}, payload = {}, &block)
|
|
60
79
|
formatted_payload = (additional_headers["Content-Type"] == 'application/json') ? Yajl::Encoder.encode(payload) : payload
|
|
61
80
|
raise Mailjet::MethodNotAllowed unless method_allowed(method)
|
data/lib/mailjet/resource.rb
CHANGED
|
@@ -16,7 +16,7 @@ require 'active_support/core_ext/object/blank'
|
|
|
16
16
|
module Mailjet
|
|
17
17
|
module Resource
|
|
18
18
|
# define here available options for filtering
|
|
19
|
-
OPTIONS = [:version, :url, :perform_api_call, :api_key, :secret_key]
|
|
19
|
+
OPTIONS = [:version, :url, :perform_api_call, :api_key, :secret_key, :read_timeout, :open_timeout]
|
|
20
20
|
|
|
21
21
|
NON_JSON_URLS = ['v3/send/message'] # urls that don't accept JSON input
|
|
22
22
|
DATA_URLS = ['plain', 'csv'] # url for send binary data , 'CSVError/text:csv'
|
|
@@ -41,7 +41,9 @@ module Mailjet
|
|
|
41
41
|
options[:secret_key] || Mailjet.config.secret_key,
|
|
42
42
|
public_operations: public_operations,
|
|
43
43
|
read_only: read_only,
|
|
44
|
-
perform_api_call: options[:perform_api_call]
|
|
44
|
+
perform_api_call: options[:perform_api_call],
|
|
45
|
+
open_timeout: options[:open_timeout],
|
|
46
|
+
read_timeout: options[:read_timeout])
|
|
45
47
|
end
|
|
46
48
|
|
|
47
49
|
def self.default_headers
|
|
@@ -267,7 +269,7 @@ module Mailjet
|
|
|
267
269
|
return if replaced_by.nil? || @deprecation_warned
|
|
268
270
|
|
|
269
271
|
@deprecation_warned = true
|
|
270
|
-
|
|
272
|
+
warn("[mailjet] #{name} is deprecated and will be removed in 2.0.0. Use #{replaced_by} instead.")
|
|
271
273
|
end
|
|
272
274
|
|
|
273
275
|
end
|
|
@@ -317,8 +319,11 @@ module Mailjet
|
|
|
317
319
|
end
|
|
318
320
|
|
|
319
321
|
def attributes=(attribute_hash = {})
|
|
322
|
+
# write straight to the attributes hash: going through send would call
|
|
323
|
+
# the class-wide setters (version=, action=, ...) for API fields that
|
|
324
|
+
# share their names, such as the Version field of an eventcallbackurl
|
|
320
325
|
attribute_hash.each do |attribute_name, value|
|
|
321
|
-
|
|
326
|
+
attributes[attribute_name] = value
|
|
322
327
|
end
|
|
323
328
|
end
|
|
324
329
|
|
data/lib/mailjet/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mailjet
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tyler Nappy
|
|
8
8
|
- Jean-Baptiste Escoyez
|
|
9
9
|
- Aurélien AMILIN
|
|
10
10
|
- Benoit Bénézech
|
|
11
|
-
autorequire:
|
|
12
11
|
bindir: bin
|
|
13
12
|
cert_chain: []
|
|
14
|
-
date:
|
|
13
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
15
14
|
dependencies:
|
|
16
15
|
- !ruby/object:Gem::Dependency
|
|
17
16
|
name: activesupport
|
|
@@ -279,7 +278,7 @@ files:
|
|
|
279
278
|
- lib/mailjet/resources/widget.rb
|
|
280
279
|
- lib/mailjet/resources/widgetcustomvalue.rb
|
|
281
280
|
- lib/mailjet/version.rb
|
|
282
|
-
homepage:
|
|
281
|
+
homepage: https://www.mailjet.com
|
|
283
282
|
licenses: []
|
|
284
283
|
metadata: {}
|
|
285
284
|
post_install_message: |2+
|
|
@@ -307,11 +306,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
307
306
|
- !ruby/object:Gem::Version
|
|
308
307
|
version: '0'
|
|
309
308
|
requirements: []
|
|
310
|
-
rubygems_version:
|
|
311
|
-
signing_key:
|
|
309
|
+
rubygems_version: 4.0.20
|
|
312
310
|
specification_version: 4
|
|
313
311
|
summary: Mailjet a powerful all-in-one email service provider clients can use to get
|
|
314
312
|
maximum insight and deliverability results from both their marketing and transactional
|
|
315
313
|
emails. Our analytics tools and intelligent APIs give senders the best understanding
|
|
316
314
|
of how to maximize benefits for each individual contact, with each email sent.
|
|
317
315
|
test_files: []
|
|
316
|
+
...
|