mailjet 0.0.5 → 1.0.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 +81 -259
- data/Rakefile +5 -4
- data/lib/mailjet.rb +7 -11
- data/lib/mailjet/api_error.rb +9 -5
- data/lib/mailjet/collection_proxy.rb +15 -0
- data/lib/mailjet/configuration.rb +4 -8
- data/lib/mailjet/connection.rb +72 -0
- data/lib/mailjet/gem_extensions/rest_client.rb +19 -0
- data/lib/mailjet/mailer.rb +37 -2
- data/lib/mailjet/message_delivery.rb +9 -0
- data/lib/mailjet/reporting.rb +10 -7
- data/lib/mailjet/resource.rb +199 -0
- data/lib/mailjet/resources/apikey.rb +12 -0
- data/lib/mailjet/resources/apikeyaccess.rb +12 -0
- data/lib/mailjet/resources/apikeytotals.rb +14 -0
- data/lib/mailjet/resources/apitoken.rb +12 -0
- data/lib/mailjet/resources/batchjob.rb +12 -0
- data/lib/mailjet/resources/bouncestatistics.rb +14 -0
- data/lib/mailjet/resources/campaign.rb +12 -0
- data/lib/mailjet/resources/campaignstatistics.rb +14 -0
- data/lib/mailjet/resources/clickstatistics.rb +14 -0
- data/lib/mailjet/resources/contact.rb +12 -0
- data/lib/mailjet/resources/contactdata.rb +12 -0
- data/lib/mailjet/resources/contactfilter.rb +12 -0
- data/lib/mailjet/resources/contacthistorydata.rb +12 -0
- data/lib/mailjet/resources/contactmetadata.rb +12 -0
- data/lib/mailjet/resources/contactslist.rb +12 -0
- data/lib/mailjet/resources/contactslistsignup.rb +12 -0
- data/lib/mailjet/resources/contactstatistics.rb +14 -0
- data/lib/mailjet/resources/csvimport.rb +12 -0
- data/lib/mailjet/resources/domainstatistics.rb +14 -0
- data/lib/mailjet/resources/eventcallbackurl.rb +12 -0
- data/lib/mailjet/resources/geostatistics.rb +14 -0
- data/lib/mailjet/resources/graphstatistics.rb +14 -0
- data/lib/mailjet/resources/listrecipient.rb +12 -0
- data/lib/mailjet/resources/listrecipientstatistics.rb +14 -0
- data/lib/mailjet/resources/liststatistics.rb +14 -0
- data/lib/mailjet/resources/manycontacts.rb +12 -0
- data/lib/mailjet/resources/message.rb +12 -0
- data/lib/mailjet/resources/messagehistory.rb +14 -0
- data/lib/mailjet/resources/messageinformation.rb +14 -0
- data/lib/mailjet/resources/messagesentstatistics.rb +14 -0
- data/lib/mailjet/resources/messagestate.rb +12 -0
- data/lib/mailjet/resources/messagestatistics.rb +14 -0
- data/lib/mailjet/resources/metadata.rb +14 -0
- data/lib/mailjet/resources/metasender.rb +12 -0
- data/lib/mailjet/resources/myprofile.rb +12 -0
- data/lib/mailjet/resources/newsletter.rb +12 -0
- data/lib/mailjet/resources/newsletterblock.rb +12 -0
- data/lib/mailjet/resources/newsletterproperties.rb +12 -0
- data/lib/mailjet/resources/newslettertemplate.rb +12 -0
- data/lib/mailjet/resources/newslettertemplateblock.rb +12 -0
- data/lib/mailjet/resources/newslettertemplatecategory.rb +12 -0
- data/lib/mailjet/resources/newslettertemplateproperties.rb +12 -0
- data/lib/mailjet/resources/openinformation.rb +14 -0
- data/lib/mailjet/resources/openstatistics.rb +14 -0
- data/lib/mailjet/resources/parseroute.rb +12 -0
- data/lib/mailjet/resources/preferences.rb +12 -0
- data/lib/mailjet/resources/sender.rb +12 -0
- data/lib/mailjet/resources/senderstatistics.rb +14 -0
- data/lib/mailjet/resources/toplinkclicked.rb +14 -0
- data/lib/mailjet/resources/trigger.rb +12 -0
- data/lib/mailjet/resources/user.rb +12 -0
- data/lib/mailjet/resources/useragentstatistics.rb +14 -0
- data/lib/mailjet/resources/widget.rb +12 -0
- data/lib/mailjet/resources/widgetcustomvalue.rb +12 -0
- data/lib/mailjet/version.rb +1 -1
- metadata +155 -44
- data/lib/mailjet/api.rb +0 -20
- data/lib/mailjet/api_request.rb +0 -70
- data/lib/mailjet/campaign.rb +0 -67
- data/lib/mailjet/click.rb +0 -15
- data/lib/mailjet/contact.rb +0 -18
- data/lib/mailjet/email.rb +0 -4
- data/lib/mailjet/list.rb +0 -58
- data/lib/mailjet/template_category.rb +0 -13
- data/lib/mailjet/template_model.rb +0 -13
- data/test/mailjet/api_request_test.rb +0 -72
- data/test/mailjet/api_test.rb +0 -13
- data/test/mailjet/campaign_test.rb +0 -66
- data/test/mailjet/configuration_test.rb +0 -16
- data/test/mailjet/contact_test.rb +0 -24
- data/test/mailjet/list_test.rb +0 -67
- data/test/mailjet/rack/endpoint_test.rb +0 -30
- data/test/mailjet/reporting_test.rb +0 -26
- data/test/mailjet/template_category_test.rb +0 -13
- data/test/mailjet/template_model_test.rb +0 -13
- data/test/mailjet_test.rb +0 -17
- data/test/minitest_helper.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 156203494ae9dd313d17567b8a512d76d69c702f
|
4
|
+
data.tar.gz: e6abc5b3be30813cd8ba595269ffca54d046f8ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ef83c13a06ab4abcdc1cad0bab70c8825fca208c6f69c2cb26198607cdd623aff145edb3bb002df65aad36955c2fda3093027787cb671e373df2488c8f9ef86
|
7
|
+
data.tar.gz: 1394da23d224428d2c3def93b3e6ae4a960bbfb74377c164f3cf2bbb31c442981b0d3282dde237737c97052c5de190ca9e02eafc334da06a21bee5f0b383b442
|
data/README.md
CHANGED
@@ -16,26 +16,34 @@
|
|
16
16
|
[mailjet]: http://www.mailjet.com
|
17
17
|
[rubinius]: http://rubini.us/
|
18
18
|
[ree]: http://www.rubyenterpriseedition.com/
|
19
|
-
[jruby]:http://jruby.org/
|
20
|
-
[mailjetter]:https://github.com/holinnn/mailjetter/
|
19
|
+
[jruby]: http://jruby.org/
|
20
|
+
[mailjetter]: https://github.com/holinnn/mailjetter/
|
21
|
+
[activeresource]: https://github.com/rails/activeresource
|
22
|
+
[apidoc]: http://dev.mailjet.com/guides
|
23
|
+
[apidoc-recipient]: http://mjdemo.poxx.net/~shubham/listrecipient.html?utm_source=github&utm_medium=link&utm_content=readme&utm_campaign=mailjet-gem
|
24
|
+
[camelcase-api]: http://api.rubyonrails.org/classes/String.html#method-i-camelcase
|
25
|
+
[underscore-api]: http://api.rubyonrails.org/classes/String.html#method-i-underscore
|
26
|
+
[actionmailerdoc]: http://guides.rubyonrails.org/action_mailer_basics.html#sending-emails-with-dynamic-delivery-options
|
27
|
+
[send-api-doc]: http://dev.mailjet.com/guides/send-api-guide/
|
28
|
+
[v1-branch]: https://github.com/mailjet/mailjet-gem/tree/v1
|
21
29
|
|
22
30
|
<!-- You can read this readme file in other languages:
|
23
31
|
english | [french](./README.fr.md) -->
|
24
32
|
|
25
33
|
This gem helps you to:
|
26
34
|
|
27
|
-
* Send transactional emails through Mailjet API in Rails 3
|
28
|
-
* Manage your lists, contacts and campaigns
|
35
|
+
* Send transactional emails through Mailjet API in Rails 3/4
|
36
|
+
* Manage your lists, contacts and campaigns, and much more...
|
29
37
|
* Track email delivery through event API
|
30
38
|
|
31
39
|
Compatibility:
|
32
40
|
|
33
|
-
- Ruby 1.8.7
|
34
41
|
- Ruby 1.9.X
|
35
|
-
-
|
36
|
-
- [Rubinius][rubinius]
|
42
|
+
- Ruby 2.0.0
|
37
43
|
|
38
|
-
Rails ActionMailer integration designed for Rails 3.X
|
44
|
+
Rails ActionMailer integration designed for Rails 3.X and 4.X
|
45
|
+
|
46
|
+
IMPORTANT: Mailjet gem switched to API v3, the new API provided by Mailjet. For the wrapper for API v1, check the [v1 branch][v1-branch].
|
39
47
|
|
40
48
|
## Install
|
41
49
|
|
@@ -88,310 +96,124 @@ As easy as:
|
|
88
96
|
|
89
97
|
```ruby
|
90
98
|
# application.rb
|
91
|
-
config.action_mailer.delivery_method = :
|
92
|
-
|
93
|
-
```
|
94
|
-
|
95
|
-
## Manage your campaigns
|
96
|
-
|
97
|
-
### Contacts
|
98
|
-
|
99
|
-
#### Filter your contacts
|
100
|
-
|
101
|
-
```ruby
|
102
|
-
> contacts = Mailjet::Contact.all(status: 'active', start: 100, limit: 2)
|
103
|
-
=> [#<Mailjet::Contact>, #<Mailjet::Contact>]
|
104
|
-
> contacts = Mailjet::Contact.all(openers: true, start: 100, limit: 2)
|
105
|
-
=> [#<Mailjet::Contact>, #<Mailjet::Contact>]
|
106
|
-
```
|
107
|
-
|
108
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/contact/list*
|
109
|
-
*All parameters and attributes for the openers option at https://eu.mailjet.com/docs/api/contact/openers*
|
110
|
-
|
111
|
-
#### More info about your contacts
|
99
|
+
config.action_mailer.delivery_method = :mailjet_smtp
|
112
100
|
|
113
|
-
```ruby
|
114
|
-
> contacts[0].infos
|
115
|
-
=> {blocked: 12, click: 1, email: 'test@mailjet.com'}
|
116
101
|
```
|
117
102
|
|
118
|
-
|
119
|
-
|
120
|
-
### Lists
|
121
|
-
|
122
|
-
#### Create a new list
|
123
|
-
|
124
|
-
```ruby
|
125
|
-
> list = Mailjet::List.create(label: 'My Mailjet list', name: "mymailjetlist")
|
126
|
-
```
|
127
|
-
|
128
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/lists/create*
|
129
|
-
|
130
|
-
#### List your lists
|
131
|
-
|
132
|
-
```ruby
|
133
|
-
> Mailjet::List.all(limit: 10, start: 0, orderby: 'id ASC')
|
134
|
-
```
|
135
|
-
|
136
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/lists/all*
|
137
|
-
|
138
|
-
#### Update a list
|
139
|
-
|
140
|
-
```ruby
|
141
|
-
> list = Mailjet::List.all.find{|l| l.name == 'mymailjetlist' }
|
142
|
-
> list = list.update(label: 'My updated Mailjet list', name: "myupdatedmailjetlist")
|
143
|
-
```
|
144
|
-
|
145
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/lists/update*
|
146
|
-
|
147
|
-
#### Show all contacts within a list
|
148
|
-
|
149
|
-
```ruby
|
150
|
-
> list.contacts
|
151
|
-
=> [#<Mailjet::Contact>, #<Mailjet::Contact>]
|
152
|
-
```
|
153
|
-
|
154
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/lists/contacts*
|
155
|
-
|
156
|
-
#### Add contacts to your list
|
157
|
-
|
158
|
-
```ruby
|
159
|
-
> list.add_contacts("test@mailjet.com", "test2@mailjet.com", force: true )
|
160
|
-
=> OK
|
161
|
-
```
|
162
|
-
|
163
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/lists/addmanycontacts*
|
164
|
-
|
165
|
-
#### Unsubscribe contact from a list
|
166
|
-
|
167
|
-
```ruby
|
168
|
-
> list.unsubscribe_contact("test@mailjet.com")
|
169
|
-
=> OK
|
170
|
-
```
|
171
|
-
|
172
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/lists/unsubcontact*
|
173
|
-
|
174
|
-
#### Remove contacts from a list
|
175
|
-
|
176
|
-
```ruby
|
177
|
-
> list.remove_contacts("test@mailjet.com", "test2@mailjet.com")
|
178
|
-
=> OK
|
179
|
-
```
|
180
|
-
|
181
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/lists/removemanycontacts*
|
182
|
-
|
183
|
-
#### Direct list email
|
184
|
-
|
185
|
-
```ruby
|
186
|
-
> list.email
|
187
|
-
=> "jk324jlO3N32203@lists.mailjet.com"
|
188
|
-
```
|
189
|
-
|
190
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/lists/email*
|
191
|
-
|
192
|
-
|
193
|
-
#### Get statistics
|
194
|
-
|
195
|
-
```ruby
|
196
|
-
> list.statistics
|
197
|
-
=> {active: 20, bounce: 1, click: 14, created_at: "2012-02-02 21:59:59", ...}
|
198
|
-
```
|
199
|
-
|
200
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/lists/statistics*
|
201
|
-
|
202
|
-
#### Delete a list
|
103
|
+
Or if you prefer sending messages through mailjet REST API:
|
203
104
|
|
204
105
|
```ruby
|
205
|
-
|
206
|
-
|
207
|
-
```
|
208
|
-
|
209
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/lists/delete*
|
210
|
-
|
211
|
-
### Campaigns
|
212
|
-
|
213
|
-
#### Create a new campaign:
|
214
|
-
|
215
|
-
```ruby
|
216
|
-
> campaign = Mailjet::Campaign.create(title: "My Mailjet Campaign", list_id: Mailjet::List.all.first.id, from: "mailjet-registered-email@domain.com", from_name: "Sender Name", subject: "Our new product", lang: "en", footer: "default")
|
217
|
-
```
|
218
|
-
|
219
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/message/createcampaign*
|
220
|
-
|
221
|
-
#### List your campaigns:
|
222
|
-
|
223
|
-
```ruby
|
224
|
-
> campaigns = Mailjet::Campaign.all(start: 10, limit: 20)
|
225
|
-
=> [#<Mailjet::Campaign>, #<Mailjet::Campaign>, ...]
|
226
|
-
```
|
227
|
-
|
228
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/message/campaigns*
|
229
|
-
|
230
|
-
#### Find one campaign:
|
231
|
-
|
232
|
-
```ruby
|
233
|
-
> campaigns = Mailjet::Campaign.find(19)
|
234
|
-
=> #<Mailjet::Campaign>
|
235
|
-
```
|
236
|
-
|
237
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/message/campaigns*
|
238
|
-
|
239
|
-
#### Update your campaign:
|
240
|
-
|
241
|
-
```ruby
|
242
|
-
> campaign.update(title: "My *new* Mailjet Campaign")
|
243
|
-
```
|
244
|
-
|
245
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/message/updatecampaign*
|
246
|
-
|
247
|
-
#### Get all the subscribers to your campaign:
|
248
|
-
|
249
|
-
```ruby
|
250
|
-
> campaign.contacts(limit: 2, start: 0, status: 'queued')
|
251
|
-
=> [#<Mailjet::Contact id: 123, email: 'test@mailjet.com', sent_at: "2012-02-02 21:59:59", status: 'queued'>, #<Mailjet::Contact id: 456, email: 'test2@mailjet.com', sent_at: "2012-02-02 23:13:02", status: 'queued'>]
|
106
|
+
# application.rb
|
107
|
+
config.action_mailer.delivery_method = :mailjet_api
|
252
108
|
```
|
253
109
|
|
254
|
-
|
110
|
+
You can use mailjet specific options with `delivery_method_options` as detailed in the official [ActionMailer doc][actionmailerdoc]
|
255
111
|
|
256
|
-
|
112
|
+
## Manage your campaigns
|
257
113
|
|
258
|
-
|
259
|
-
> campaign.send!
|
260
|
-
=> OK
|
261
|
-
```
|
114
|
+
This gem provide a convenient wrapper for consuming the mailjet API. The wrapper is highly inspired by [ActiveResource][activeresource] even though it does not depend on it.
|
262
115
|
|
263
|
-
|
116
|
+
You can find out all the resources you can access to in the [Official API docs][apidocs].
|
264
117
|
|
265
|
-
|
118
|
+
Let's have a look at the power of this thin wrapper
|
266
119
|
|
267
|
-
|
268
|
-
> campaign.test('test@mailjet.com')
|
269
|
-
=> OK # response status
|
270
|
-
```
|
120
|
+
### Wrapper REST API
|
271
121
|
|
272
|
-
|
122
|
+
Let's say we want to manage list recipients.
|
273
123
|
|
274
|
-
####
|
124
|
+
#### GET all the recipients in one query:
|
275
125
|
|
276
126
|
```ruby
|
277
|
-
>
|
278
|
-
=>
|
127
|
+
> recipients = Mailjet::Listrecipient.all(limit: 0)
|
128
|
+
=> [#<Mailjet::Listrecipient>, #<Mailjet::Listrecipient>]
|
279
129
|
```
|
280
130
|
|
281
|
-
|
131
|
+
By default, `.all` will retrieve only 10 resources, so, you have to specify `limit: 0` if you want to GET them all.
|
282
132
|
|
283
|
-
|
133
|
+
You can refine queries using [API Filters][apidoc-recipient]`*` as well as the following parameters:
|
284
134
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
135
|
+
* format: `:json, :xml, :rawxml, :html, :csv` or `:phpserialized` (default: `:json`)
|
136
|
+
* limit: int (default: 10)
|
137
|
+
* offset: int (default: 0)
|
138
|
+
* sort: `[[:property, :asc], [:property, :desc]]`
|
289
139
|
|
290
|
-
|
140
|
+
`*` See below for [naming conventions](#naming-conventions)
|
291
141
|
|
292
|
-
####
|
142
|
+
#### GET the resources count
|
293
143
|
|
294
144
|
```ruby
|
295
|
-
> Mailjet::
|
296
|
-
=>
|
145
|
+
> Mailjet::Listrecipient.count
|
146
|
+
=> 83
|
297
147
|
```
|
298
148
|
|
299
|
-
|
300
|
-
|
301
|
-
#### Get the raw HTML form a campaign:
|
149
|
+
#### GET the first resource matching a query
|
302
150
|
|
303
151
|
```ruby
|
304
|
-
>
|
305
|
-
=>
|
152
|
+
> Mailjet::Listrecipient.first
|
153
|
+
=> #<Mailjet::Listrecipient>
|
306
154
|
```
|
307
155
|
|
308
|
-
|
309
|
-
|
310
|
-
#### Set the raw HTML for a campaign:
|
156
|
+
#### GET a resource from its id
|
311
157
|
|
312
158
|
```ruby
|
313
|
-
>
|
314
|
-
=>
|
159
|
+
> recipient = Mailjet::Listrecipient.find(id)
|
160
|
+
=> #<Mailjet::Listrecipient>
|
315
161
|
```
|
316
162
|
|
317
|
-
|
318
|
-
|
319
|
-
#### Duplicate a campaign:
|
163
|
+
#### Updating a resource
|
320
164
|
|
321
165
|
```ruby
|
322
|
-
>
|
323
|
-
=> #<Mailjet::
|
166
|
+
> recipient = Mailjet::Listrecipient.first
|
167
|
+
=> #<Mailjet::Listrecipient>
|
168
|
+
> recipient.is_active = false
|
169
|
+
=> false
|
170
|
+
> recipient.attributes
|
171
|
+
=> {...} # attributes hash
|
172
|
+
> recipient.save
|
173
|
+
=> true
|
174
|
+
> recipient.update_attributes(is_active: true)
|
175
|
+
=> true
|
324
176
|
```
|
325
177
|
|
326
|
-
|
178
|
+
#### Deleting a resource
|
179
|
+
```ruby
|
180
|
+
> recipient = Mailjet::Listrecipient.first
|
181
|
+
=> #<Mailjet::Listrecipient>
|
182
|
+
> recipient.delete
|
183
|
+
> Mailjet::Listrecipient.delete(123)
|
184
|
+
=> #<Mailjet::Listrecipient>
|
185
|
+
```
|
327
186
|
|
328
|
-
###
|
187
|
+
### Naming conventions
|
329
188
|
|
330
|
-
|
189
|
+
* Classes names are the [camelcased][camelcase-api] version of resource names (e.g. class name for `listrecipient` resource will be `Listrecipient` - notice the "r" of "recipient" is downcase since the "listrecipient" resource has no dash or underscore between "list" and "recipient")
|
190
|
+
* Ruby attribute names are the [underscored][underscore-api] versions of API attributes names (e.g. `IsActive` will be `is_active` in ruby)
|
191
|
+
* If you do not like the name of the resource, you can easily rename them. For instance, if you want a capital R to ListRecipient, you can define the following class:
|
331
192
|
|
332
193
|
```ruby
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/report/click*
|
340
|
-
|
341
|
-
#### Info about domains your emails are sent to
|
342
|
-
|
343
|
-
```ruby
|
344
|
-
> Mailjet::Reporting.domains(start: 3, limit: 6)
|
345
|
-
=> [{bounce_rate: 0.1, clicked_rate: 0.2, ...}, {bounce_rate: 0.8, clicked_rate: 0.1, ...}]
|
194
|
+
class ListRecipient
|
195
|
+
include Mailjet::Resource
|
196
|
+
self.resource_path = 'listrecipient'
|
197
|
+
self.public_operations = [:get, :put, :post, :delete] # optional
|
198
|
+
end
|
346
199
|
```
|
347
200
|
|
348
|
-
|
201
|
+
## Send emails through API
|
349
202
|
|
350
|
-
|
203
|
+
In order to send emails through the API, you just have to `create` a new `MessageDelivery` resource.
|
351
204
|
|
352
|
-
```ruby
|
353
|
-
> Mailjet::Reporting.clients(start: 3, limit: 6)
|
354
|
-
=> [{client: "Gmail", open_rate: 0.1, platform: "Windows", ...}, {client: "Outlook", open_rate: 0.3, platform: "Windows", ...}]
|
355
205
|
```
|
356
|
-
|
357
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/report/emailclients*
|
358
|
-
|
359
|
-
#### Info about email sent
|
360
|
-
|
361
|
-
```ruby
|
362
|
-
> Mailjet::Reporting.emails(from_domain: "domain.com", limit: 10)
|
363
|
-
=> [#<Mailjet::Email>, #<Mailjet::Email>, #<Mailjet::Email>, ...]
|
206
|
+
Mailjet::MessageDelivery.create(from: "me@example.com", to: "you@example.com", subject: "Mailjet is awesome", text: "Yes, it is!")
|
364
207
|
```
|
365
208
|
|
366
|
-
|
367
|
-
|
368
|
-
#### Global stats about a set of emails
|
369
|
-
|
370
|
-
```ruby
|
371
|
-
> Mailjet::Reporting.statistics(from_domain: "domain.com", limit: 10)
|
372
|
-
=> { avg_clicked_delay: 123, avg_opened_rate: 0.432, blocked: 13, ...}
|
209
|
+
If you want to send it to multiple recipients, just use an array:
|
373
210
|
```
|
374
|
-
|
375
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/report/emailstatistics*
|
376
|
-
|
377
|
-
|
378
|
-
#### Opened email Geolocation
|
379
|
-
|
380
|
-
```ruby
|
381
|
-
> Mailjet::Reporting.geolocation(from_domain: "domain.com", limit: 10)
|
382
|
-
=> [{click: 123, country: "France", open: 234}, {click: 9876, country: "US", open: 12345}]
|
211
|
+
Mailjet::MessageDelivery.create(from: "me@example.com", to: ["you@example.com", "someone-else@example.com"], subject: "Mailjet is awesome", text: "Yes, it is!")
|
383
212
|
```
|
384
213
|
|
385
|
-
|
386
|
-
|
387
|
-
#### User-Agents used to open emails
|
388
|
-
|
389
|
-
```ruby
|
390
|
-
> Mailjet::Reporting.agents(start: 3, limit: 6)
|
391
|
-
=> [{cnt_clicked: 123, part: 30, platform: "Windows", user_agent: "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0"}, ...]
|
392
|
-
```
|
214
|
+
In order to Mailjet modifiers, you cannot use the regular form of Ruby 2 hashes. Instead, use a String `e.g.: 'mj-prio' => 2` or a quoted symbol `e.g.: 'mj-prio' => 2`.
|
393
215
|
|
394
|
-
|
216
|
+
You can check available params in the [official doc][send-api-doc].
|
395
217
|
|
396
218
|
## Track email delivery
|
397
219
|
|
data/Rakefile
CHANGED
@@ -5,12 +5,13 @@ Bundler::GemHelper.install_tasks
|
|
5
5
|
|
6
6
|
$:.push File.expand_path("../lib", __FILE__)
|
7
7
|
|
8
|
-
Rake::TestTask.new(:
|
8
|
+
Rake::TestTask.new(:spec) do |t|
|
9
9
|
t.libs << 'lib'
|
10
|
-
t.libs << '
|
11
|
-
t.pattern = '
|
10
|
+
t.libs << 'spec'
|
11
|
+
# t.pattern = 'spec/**/*_spec.rb'
|
12
12
|
t.verbose = true
|
13
|
+
t.test_files = Dir['spec/**/*_spec.rb']
|
13
14
|
end
|
14
15
|
|
15
16
|
|
16
|
-
task :default => :
|
17
|
+
task :default => :spec
|
data/lib/mailjet.rb
CHANGED
@@ -1,19 +1,15 @@
|
|
1
1
|
require 'active_support'
|
2
2
|
require 'ostruct'
|
3
3
|
require 'mailjet/core_extensions/ostruct'
|
4
|
-
require 'mailjet/api'
|
5
|
-
require 'mailjet/api_request'
|
6
|
-
require 'mailjet/api_error'
|
7
4
|
require 'mailjet/configuration'
|
8
|
-
require 'mailjet/
|
9
|
-
require 'mailjet/list'
|
10
|
-
require 'mailjet/campaign'
|
11
|
-
require 'mailjet/template_category'
|
12
|
-
require 'mailjet/template_model'
|
13
|
-
require 'mailjet/reporting'
|
14
|
-
require 'mailjet/click'
|
15
|
-
require 'mailjet/email'
|
5
|
+
require 'mailjet/api_error'
|
16
6
|
|
7
|
+
require 'mailjet/resource'
|
8
|
+
require 'mailjet/message_delivery'
|
9
|
+
|
10
|
+
Dir[File.expand_path("../mailjet/resources/*.rb", __FILE__)].each do |file|
|
11
|
+
require file
|
12
|
+
end
|
17
13
|
|
18
14
|
module Mailjet
|
19
15
|
def self.configure
|