mailkick 0.4.1 → 0.4.2
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/CHANGELOG.md +24 -19
- data/README.md +43 -20
- data/lib/mailkick.rb +9 -1
- data/lib/mailkick/engine.rb +0 -4
- data/lib/mailkick/service/sendgrid.rb +4 -1
- data/lib/mailkick/service/sendgrid_v2.rb +52 -0
- data/{app/helpers → lib}/mailkick/url_helper.rb +0 -0
- data/lib/mailkick/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00db7fdae2daa66b3d994ac64b34a084c385fb76d3dfa81d379955d4df0249d3
|
4
|
+
data.tar.gz: f78fce2a60960fc4c821f788bee0458e28f2c005655b972cccc95078abda4952
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed17bf62b821fd7627152d62d02b572d304bbb6221032d76d07ab8c05afeab7304aa1ae2c12e35aa164ec0e081fac5580a00ec215a53ee7cbcffdfee5dc5afaf
|
7
|
+
data.tar.gz: 05a745028f412d6d7c626bd9fa5a20ebd40acd77ee84893078878176ca3f30f37e263676119c29bf142f30c6d2e3963e35b297a9746fbfe1d76557f2a0d3bb8e
|
data/CHANGELOG.md
CHANGED
@@ -1,20 +1,25 @@
|
|
1
|
-
## 0.4.
|
1
|
+
## 0.4.2 (2020-04-06)
|
2
|
+
|
3
|
+
- Added support for official SendGrid gem
|
4
|
+
- Fixed deprecation warning
|
5
|
+
|
6
|
+
## 0.4.1 (2019-10-27)
|
2
7
|
|
3
8
|
- Added Postmark support
|
4
9
|
|
5
|
-
## 0.4.0
|
10
|
+
## 0.4.0 (2019-07-15)
|
6
11
|
|
7
12
|
- Fixed error with model methods and `email_key` option
|
8
13
|
- Fixed bug with `opted_out` scope
|
9
14
|
- Dropped support for Action Mailer 4.2
|
10
15
|
|
11
|
-
## 0.3.1
|
16
|
+
## 0.3.1 (2018-04-21)
|
12
17
|
|
13
18
|
- Fixed `Secret should not be nil` error in Rails 5.2
|
14
19
|
- Gracefully handle missing email
|
15
20
|
- Added `user` option to `mailkick_unsubscribe_url`
|
16
21
|
|
17
|
-
## 0.3.0
|
22
|
+
## 0.3.0 (2018-04-20)
|
18
23
|
|
19
24
|
- Improved performance
|
20
25
|
- Fixed `Subscription not found` for Rails 5.2
|
@@ -22,68 +27,68 @@
|
|
22
27
|
- Use `smtp_settings[:domain]` for Mailgun
|
23
28
|
- Dropped support for Action Mailer < 4.2
|
24
29
|
|
25
|
-
## 0.2.1
|
30
|
+
## 0.2.1 (2017-10-30)
|
26
31
|
|
27
32
|
- Fixed errors with Rails 5+
|
28
33
|
- Fixed errors with the latest version of Gibbon
|
29
34
|
|
30
|
-
## 0.2.0
|
35
|
+
## 0.2.0 (2017-05-01)
|
31
36
|
|
32
37
|
- Added support for Rails 5.1
|
33
38
|
|
34
|
-
## 0.1.6
|
39
|
+
## 0.1.6 (2017-01-10)
|
35
40
|
|
36
41
|
- Fixed error with frozen strings
|
37
42
|
|
38
|
-
## 0.1.5
|
43
|
+
## 0.1.5 (2016-12-06)
|
39
44
|
|
40
45
|
- Use `safely`
|
41
46
|
- Only discover services if not manually set
|
42
47
|
- Added `mount` option
|
43
48
|
|
44
|
-
## 0.1.4
|
49
|
+
## 0.1.4 (2016-02-20)
|
45
50
|
|
46
51
|
- Use `Module#prepend` instead of `alias_method_chain`
|
47
52
|
|
48
|
-
## 0.1.3
|
53
|
+
## 0.1.3 (2015-06-29)
|
49
54
|
|
50
55
|
- Fixed issue with double escaping tokens
|
51
56
|
|
52
|
-
## 0.1.2
|
57
|
+
## 0.1.2 (2015-06-07)
|
53
58
|
|
54
59
|
- Added support for Mailgun
|
55
60
|
|
56
|
-
## 0.1.1
|
61
|
+
## 0.1.1 (2015-01-31)
|
57
62
|
|
58
63
|
- Fixed tokens with `+` in them
|
59
64
|
|
60
|
-
## 0.1.0
|
65
|
+
## 0.1.0 (2014-08-31)
|
61
66
|
|
62
67
|
- Fixed secret token for Rails 4.1
|
63
68
|
|
64
|
-
## 0.0.6
|
69
|
+
## 0.0.6 (2014-05-09)
|
65
70
|
|
66
71
|
- Rails 3 fix
|
67
72
|
|
68
|
-
## 0.0.5
|
73
|
+
## 0.0.5 (2014-05-05)
|
69
74
|
|
70
75
|
- Fixed bug with subscriptions page
|
71
76
|
|
72
|
-
## 0.0.4
|
77
|
+
## 0.0.4 (2014-05-05)
|
73
78
|
|
74
79
|
- Added `email_key` option to `mailkick_user`
|
75
80
|
|
76
|
-
## 0.0.3
|
81
|
+
## 0.0.3 (2014-05-04)
|
77
82
|
|
78
83
|
- Added support for multiple lists
|
79
84
|
- Changed `mailkick_user` method names - sorry early adopters :(
|
80
85
|
|
81
|
-
## 0.0.2
|
86
|
+
## 0.0.2 (2014-05-04)
|
82
87
|
|
83
88
|
- Added Mailchimp service
|
84
89
|
- Fixed Mandrill service
|
85
90
|
- Added `uniq` to `subscribed` scope
|
86
91
|
|
87
|
-
## 0.0.1
|
92
|
+
## 0.0.1 (2014-05-04)
|
88
93
|
|
89
94
|
- First release
|
data/README.md
CHANGED
@@ -89,51 +89,65 @@ Fetch bounces, spam reports, and unsubscribes from your email service.
|
|
89
89
|
Mailkick.fetch_opt_outs
|
90
90
|
```
|
91
91
|
|
92
|
-
|
92
|
+
The following services are supported:
|
93
93
|
|
94
|
-
|
94
|
+
- [Mailchimp](#mailchimp)
|
95
|
+
- [Mailgun](#mailgun)
|
96
|
+
- [Mandrill](#mandrill)
|
97
|
+
- [Postmark](#postmark)
|
98
|
+
- [SendGrid](#sendgrid)
|
95
99
|
|
96
|
-
|
97
|
-
gem 'sendgrid_toolkit'
|
98
|
-
```
|
100
|
+
Will gladly accept pull requests for others.
|
99
101
|
|
100
|
-
|
102
|
+
#### Mailchimp
|
101
103
|
|
102
|
-
|
104
|
+
Add the gem
|
103
105
|
|
104
106
|
```ruby
|
105
|
-
gem '
|
107
|
+
gem 'gibbon', '>= 2'
|
106
108
|
```
|
107
109
|
|
108
|
-
|
110
|
+
And set `ENV["MAILCHIMP_API_KEY"]` and `ENV["MAILCHIMP_LIST_ID"]`.
|
109
111
|
|
110
|
-
####
|
112
|
+
#### Mailgun
|
113
|
+
|
114
|
+
Add the gem
|
111
115
|
|
112
116
|
```ruby
|
113
|
-
gem '
|
117
|
+
gem 'mailgun-ruby'
|
114
118
|
```
|
115
119
|
|
116
|
-
|
120
|
+
And set `ENV["MAILGUN_API_KEY"]`.
|
117
121
|
|
118
|
-
####
|
122
|
+
#### Mandrill
|
123
|
+
|
124
|
+
Add the gem
|
119
125
|
|
120
126
|
```ruby
|
121
|
-
gem '
|
127
|
+
gem 'mandrill-api'
|
122
128
|
```
|
123
129
|
|
124
|
-
|
130
|
+
And set `ENV["MANDRILL_APIKEY"]`.
|
125
131
|
|
126
132
|
#### Postmark
|
127
133
|
|
134
|
+
Add the gem
|
135
|
+
|
128
136
|
```ruby
|
129
137
|
gem 'postmark'
|
130
138
|
```
|
131
139
|
|
132
|
-
|
140
|
+
And set `ENV["POSTMARK_API_KEY"]`.
|
133
141
|
|
134
|
-
####
|
142
|
+
#### SendGrid
|
135
143
|
|
136
|
-
|
144
|
+
Add the gem
|
145
|
+
|
146
|
+
```ruby
|
147
|
+
gem 'sendgrid-ruby'
|
148
|
+
```
|
149
|
+
|
150
|
+
And set `ENV["SENDGRID_API_KEY"]`. The API key requires only the `Suppressions` permission.
|
137
151
|
|
138
152
|
### Advanced
|
139
153
|
|
@@ -141,8 +155,8 @@ For more control over services, set them by hand.
|
|
141
155
|
|
142
156
|
```ruby
|
143
157
|
Mailkick.services = [
|
144
|
-
Mailkick::Service::
|
145
|
-
Mailkick::Service::
|
158
|
+
Mailkick::Service::SendGridV2.new(api_key: "API_KEY"),
|
159
|
+
Mailkick::Service::Mailchimp.new(api_key: "API_KEY", list_id: "LIST_ID")
|
146
160
|
]
|
147
161
|
```
|
148
162
|
|
@@ -229,3 +243,12 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
|
|
229
243
|
- Fix bugs and [submit pull requests](https://github.com/ankane/mailkick/pulls)
|
230
244
|
- Write, clarify, or fix documentation
|
231
245
|
- Suggest or add new features
|
246
|
+
|
247
|
+
To get started with development and testing:
|
248
|
+
|
249
|
+
```sh
|
250
|
+
git clone https://github.com/ankane/mailkick.git
|
251
|
+
cd mailkick
|
252
|
+
bundle install
|
253
|
+
bundle exec rake test
|
254
|
+
```
|
data/lib/mailkick.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# dependencies
|
2
|
-
require "set"
|
3
2
|
require "active_support"
|
4
3
|
|
4
|
+
# stdlib
|
5
|
+
require "set"
|
6
|
+
|
5
7
|
# modules
|
6
8
|
require "mailkick/model"
|
7
9
|
require "mailkick/service"
|
@@ -9,7 +11,9 @@ require "mailkick/service/mailchimp"
|
|
9
11
|
require "mailkick/service/mailgun"
|
10
12
|
require "mailkick/service/mandrill"
|
11
13
|
require "mailkick/service/sendgrid"
|
14
|
+
require "mailkick/service/sendgrid_v2"
|
12
15
|
require "mailkick/service/postmark"
|
16
|
+
require "mailkick/url_helper"
|
13
17
|
require "mailkick/version"
|
14
18
|
|
15
19
|
# integrations
|
@@ -104,6 +108,10 @@ module Mailkick
|
|
104
108
|
end
|
105
109
|
end
|
106
110
|
|
111
|
+
ActiveSupport.on_load :action_mailer do
|
112
|
+
helper Mailkick::UrlHelper
|
113
|
+
end
|
114
|
+
|
107
115
|
ActiveSupport.on_load(:active_record) do
|
108
116
|
extend Mailkick::Model
|
109
117
|
end
|
data/lib/mailkick/engine.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Mailkick
|
4
4
|
class Service
|
5
|
-
class
|
5
|
+
class SendGrid < Mailkick::Service
|
6
6
|
def initialize(options = {})
|
7
7
|
@api_user = options[:api_user] || ENV["SENDGRID_USERNAME"]
|
8
8
|
@api_key = options[:api_key] || ENV["SENDGRID_PASSWORD"]
|
@@ -41,5 +41,8 @@ module Mailkick
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
44
|
+
|
45
|
+
# backwards compatibility
|
46
|
+
Sendgrid = SendGrid
|
44
47
|
end
|
45
48
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# https://github.com/sendgrid/sendgrid-ruby
|
2
|
+
|
3
|
+
module Mailkick
|
4
|
+
class Service
|
5
|
+
class SendGridV2 < Mailkick::Service
|
6
|
+
def initialize(options = {})
|
7
|
+
@api_key = options[:api_key] || ENV["SENDGRID_API_KEY"]
|
8
|
+
end
|
9
|
+
|
10
|
+
def opt_outs
|
11
|
+
unsubscribes + spam_reports + bounces
|
12
|
+
end
|
13
|
+
|
14
|
+
def unsubscribes
|
15
|
+
fetch(client.suppression.unsubscribes, "unsubscribe")
|
16
|
+
end
|
17
|
+
|
18
|
+
def spam_reports
|
19
|
+
fetch(client.suppression.spam_reports, "spam")
|
20
|
+
end
|
21
|
+
|
22
|
+
def bounces
|
23
|
+
fetch(client.suppression.bounces, "bounce")
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.discoverable?
|
27
|
+
!!(defined?(::SendGrid::API) && ENV["SENDGRID_API_KEY"])
|
28
|
+
end
|
29
|
+
|
30
|
+
protected
|
31
|
+
|
32
|
+
def client
|
33
|
+
@client ||= ::SendGrid::API.new(api_key: @api_key).client
|
34
|
+
end
|
35
|
+
|
36
|
+
def fetch(query, reason)
|
37
|
+
# TODO paginate
|
38
|
+
response = query.get
|
39
|
+
|
40
|
+
raise "Bad status code: #{response.status_code}" if response.status_code.to_i != 200
|
41
|
+
|
42
|
+
response.parsed_body.map do |record|
|
43
|
+
{
|
44
|
+
email: record[:email],
|
45
|
+
time: Time.at(record[:created]),
|
46
|
+
reason: reason
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
File without changes
|
data/lib/mailkick/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -188,7 +188,6 @@ files:
|
|
188
188
|
- LICENSE.txt
|
189
189
|
- README.md
|
190
190
|
- app/controllers/mailkick/subscriptions_controller.rb
|
191
|
-
- app/helpers/mailkick/url_helper.rb
|
192
191
|
- app/models/mailkick/opt_out.rb
|
193
192
|
- app/views/mailkick/subscriptions/show.html.erb
|
194
193
|
- config/routes.rb
|
@@ -204,6 +203,8 @@ files:
|
|
204
203
|
- lib/mailkick/service/mandrill.rb
|
205
204
|
- lib/mailkick/service/postmark.rb
|
206
205
|
- lib/mailkick/service/sendgrid.rb
|
206
|
+
- lib/mailkick/service/sendgrid_v2.rb
|
207
|
+
- lib/mailkick/url_helper.rb
|
207
208
|
- lib/mailkick/version.rb
|
208
209
|
homepage: https://github.com/ankane/mailkick
|
209
210
|
licenses:
|
@@ -224,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
225
|
- !ruby/object:Gem::Version
|
225
226
|
version: '0'
|
226
227
|
requirements: []
|
227
|
-
rubygems_version: 3.
|
228
|
+
rubygems_version: 3.1.2
|
228
229
|
signing_key:
|
229
230
|
specification_version: 4
|
230
231
|
summary: Email subscriptions made easy
|