mailjet 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -3
- data/lib/mailjet/api_error.rb +1 -1
- data/lib/mailjet/campaign.rb +0 -1
- data/lib/mailjet/list.rb +8 -2
- data/lib/mailjet/version.rb +1 -1
- data/test/mailjet/campaign_test.rb +1 -1
- data/test/mailjet/list_test.rb +6 -1
- data/test/mailjet/reporting_test.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0e2c12ab0cc6237b42bd1d380226a9c34129ea8
|
4
|
+
data.tar.gz: 89d3e6c6d4d64cfa2a07b3e2d336ac0ce65dfae3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 803e5a56bf4c2cb174c49af87e6c2ba6a8376613c186dfe01153c62956f027029b82773eaf5c5acbf0f0dbd29920dc61bade288820aeebde184adf53a3e35dd7
|
7
|
+
data.tar.gz: 5ef130cf9c095200c80a8e6adc91934932beb0d675b343aa1bf6c7b72fdb363e248c809f9f55bb3134664f1d8b8707e820b19227cade2122c38b8d46fd73e7d4
|
data/README.md
CHANGED
@@ -162,6 +162,15 @@ config.action_mailer.delivery_method = :mailjet
|
|
162
162
|
|
163
163
|
*All parameters and attributes at https://eu.mailjet.com/docs/api/lists/addmanycontacts*
|
164
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
|
+
|
165
174
|
#### Remove contacts from a list
|
166
175
|
|
167
176
|
```ruby
|
@@ -301,11 +310,11 @@ config.action_mailer.delivery_method = :mailjet
|
|
301
310
|
#### Set the raw HTML for a campaign:
|
302
311
|
|
303
312
|
```ruby
|
304
|
-
> campaign.set_html("<html><head><title>Test</title></head><body>Test <a href=\"[[UNSUB_LINK_EN]]\">[[UNSUB_LINK_EN]]</a></body></html>")
|
313
|
+
> campaign.set_html("<html><head><title>Test</title></head><body>Test <a href=\"[[UNSUB_LINK_EN]]\">[[UNSUB_LINK_EN]]</a></body></html>")
|
305
314
|
=> OK # response status
|
306
315
|
```
|
307
316
|
|
308
|
-
*All parameters and attributes at https://eu.mailjet.com/docs/api/message/sethtmlcampaign*
|
317
|
+
*All parameters and attributes at https://eu.mailjet.com/docs/api/message/sethtmlcampaign*
|
309
318
|
|
310
319
|
#### Duplicate a campaign:
|
311
320
|
|
@@ -452,7 +461,7 @@ Then at the root of the gem, simply run:
|
|
452
461
|
|
453
462
|
```bash
|
454
463
|
bundle
|
455
|
-
rake
|
464
|
+
bundle exec rake
|
456
465
|
```
|
457
466
|
## Send a pull request
|
458
467
|
|
data/lib/mailjet/api_error.rb
CHANGED
@@ -7,7 +7,7 @@ module Mailjet
|
|
7
7
|
# code is ugly, output is pretty
|
8
8
|
super("error #{code} while sending #{request.inspect} to #{request_path} with #{params.inspect}\n\n" +
|
9
9
|
(res['errors'].present? ?
|
10
|
-
(res['errors'] || []).map do |param, text|
|
10
|
+
[(res['errors'] || [])].flatten.map do |param, text|
|
11
11
|
[param, text].map(&:to_s).reject(&:blank?).join(': ')
|
12
12
|
end.join("\n") :
|
13
13
|
res.inspect
|
data/lib/mailjet/campaign.rb
CHANGED
@@ -48,7 +48,6 @@ module Mailjet
|
|
48
48
|
def create(options = {})
|
49
49
|
campaign_attr = (options.delete(:api) || Mailjet::Api.singleton).messageCreatecampaign(options, 'Post')["campaign"]
|
50
50
|
campaign = find(campaign_attr["id"]).tap{ |c| campaign_attr.each{ |k, v| c.send("#{k}=", v) } }
|
51
|
-
puts campaign.inspect
|
52
51
|
campaign
|
53
52
|
end
|
54
53
|
|
data/lib/mailjet/list.rb
CHANGED
@@ -12,7 +12,13 @@ module Mailjet
|
|
12
12
|
contacts = params.map{|p| p.is_a?(Mailjet::Contact) ? p.email.to_s : p.to_s }.reject(&:blank?)
|
13
13
|
(options.delete(:api) || Mailjet::Api.singleton).listsAddmanycontacts(options.reverse_merge(:contacts => contacts.to_json, :id => self.id), 'Post')["status"]
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
|
+
def unsubscribe_contact(*params)
|
17
|
+
options = params.last.is_a?(Hash) ? params.pop : {}
|
18
|
+
contact = params.map{|p| p.is_a?(Mailjet::Contact) ? p.email.to_s : p.to_s }.reject(&:blank?).first
|
19
|
+
(options.delete(:api) || Mailjet::Api.singleton).listsUnsubcontact(options.reverse_merge(:contact => contact, :id => self.id), 'Post')["status"]
|
20
|
+
end
|
21
|
+
|
16
22
|
def remove_contacts(*params)
|
17
23
|
options = params.last.is_a?(Hash) ? params.pop : {}
|
18
24
|
contacts = params.map{|p| p.is_a?(Mailjet::Contact) ? p.email.to_s : p.to_s }.reject(&:blank?)
|
@@ -32,7 +38,7 @@ module Mailjet
|
|
32
38
|
def statistics(options = {})
|
33
39
|
(options.delete(:api) || Mailjet::Api.singleton).listsStatistics(options.reverse_merge(:id => self.id))["statistics"]
|
34
40
|
end
|
35
|
-
|
41
|
+
|
36
42
|
def delete(options = {})
|
37
43
|
(options.delete(:api) || Mailjet::Api.singleton).listsDelete(options.reverse_merge(:id => self.id))["status"]
|
38
44
|
end
|
data/lib/mailjet/version.rb
CHANGED
@@ -54,7 +54,7 @@ describe Mailjet::Campaign do
|
|
54
54
|
dup.set_html(html_test).must_equal 'OK'
|
55
55
|
dup.html.must_equal html_test
|
56
56
|
|
57
|
-
sleep
|
57
|
+
sleep 20 # wait for the campaign to be send
|
58
58
|
campaign = Mailjet::Campaign.find(campaign.id)
|
59
59
|
|
60
60
|
# Mailjet::Campaign#contacts
|
data/test/mailjet/list_test.rb
CHANGED
@@ -40,7 +40,12 @@ describe Mailjet::List do
|
|
40
40
|
contacts = list.contacts
|
41
41
|
contacts.first.must_be_instance_of Mailjet::Contact
|
42
42
|
contacts.map(&:email).sort.must_equal ["c1@contacts.com", "c2@contacts.com", "c3@contacts.com", "c4@contacts.com", "c5@contacts.com"]
|
43
|
-
|
43
|
+
|
44
|
+
# Mailjet::List#unsubscribe_contact
|
45
|
+
list.unsubscribe_contact("c1@contacts.com").must_equal "OK"
|
46
|
+
exception = proc {list.unsubscribe_contact("c1@contacts.com")}.must_raise(Mailjet::ApiError)
|
47
|
+
exception.to_s.must_match /This contact is already unsub./
|
48
|
+
|
44
49
|
# Mailjet::List#remove_contacts
|
45
50
|
list.remove_contacts.must_equal "NotModified"
|
46
51
|
list.remove_contacts("does-not-exist@nowhere.com").must_equal "NotModified"
|
@@ -18,7 +18,7 @@ describe Mailjet::Reporting do
|
|
18
18
|
Mailjet::Reporting.statistics["cnt_messages"].wont_be_nil
|
19
19
|
|
20
20
|
# Mailjet::Reporting.geolocation
|
21
|
-
Mailjet::Reporting.geolocation.must_be_instance_of
|
21
|
+
Mailjet::Reporting.geolocation.must_be_instance_of Array
|
22
22
|
|
23
23
|
# Mailjet::Reporting.agents
|
24
24
|
Mailjet::Reporting.agents.must_be_instance_of Array
|
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: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aurélien AMILIN
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -25,6 +25,20 @@ dependencies:
|
|
25
25
|
- - '>='
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 3.1.0
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rack
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.4.0
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.4.0
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: actionmailer
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|