mailkick 0.4.1 → 0.4.2

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: 6e4c1d35fb49e05d3415afe507e229c2cbe7f4da0e2f684e91b5754a0418422f
4
- data.tar.gz: 0fe44b2723b4dbce1d4d5486530a3cbacfc14bfb406c1b47ff28bbb28f2f7a20
3
+ metadata.gz: 00db7fdae2daa66b3d994ac64b34a084c385fb76d3dfa81d379955d4df0249d3
4
+ data.tar.gz: f78fce2a60960fc4c821f788bee0458e28f2c005655b972cccc95078abda4952
5
5
  SHA512:
6
- metadata.gz: 1271af0d6c368f853f77dad646584e4a91b90bde9033c93ce29cba4c5d1a646c298983fcf46d0c89b2979ddf3cb40764e63574846673e29cd9b7f15053f69674
7
- data.tar.gz: 37db46884bdec50cb02503e898e3834bc878d83cec5681a616da71f12c3b21236c90d32e9da2e7e2812f0fef88cff99292c73e65d1fe399c765d5a8d9cb45e1a
6
+ metadata.gz: ed17bf62b821fd7627152d62d02b572d304bbb6221032d76d07ab8c05afeab7304aa1ae2c12e35aa164ec0e081fac5580a00ec215a53ee7cbcffdfee5dc5afaf
7
+ data.tar.gz: 05a745028f412d6d7c626bd9fa5a20ebd40acd77ee84893078878176ca3f30f37e263676119c29bf142f30c6d2e3963e35b297a9746fbfe1d76557f2a0d3bb8e
@@ -1,20 +1,25 @@
1
- ## 0.4.1
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
- #### Sendgrid
92
+ The following services are supported:
93
93
 
94
- Add the gem
94
+ - [Mailchimp](#mailchimp)
95
+ - [Mailgun](#mailgun)
96
+ - [Mandrill](#mandrill)
97
+ - [Postmark](#postmark)
98
+ - [SendGrid](#sendgrid)
95
99
 
96
- ```ruby
97
- gem 'sendgrid_toolkit'
98
- ```
100
+ Will gladly accept pull requests for others.
99
101
 
100
- Be sure `ENV["SENDGRID_USERNAME"]` and `ENV["SENDGRID_PASSWORD"]` are set.
102
+ #### Mailchimp
101
103
 
102
- #### Mandrill
104
+ Add the gem
103
105
 
104
106
  ```ruby
105
- gem 'mandrill-api'
107
+ gem 'gibbon', '>= 2'
106
108
  ```
107
109
 
108
- Be sure `ENV["MANDRILL_APIKEY"]` is set.
110
+ And set `ENV["MAILCHIMP_API_KEY"]` and `ENV["MAILCHIMP_LIST_ID"]`.
109
111
 
110
- #### Mailchimp
112
+ #### Mailgun
113
+
114
+ Add the gem
111
115
 
112
116
  ```ruby
113
- gem 'gibbon', '>= 2'
117
+ gem 'mailgun-ruby'
114
118
  ```
115
119
 
116
- Be sure `ENV["MAILCHIMP_API_KEY"]` and `ENV["MAILCHIMP_LIST_ID"]` are set.
120
+ And set `ENV["MAILGUN_API_KEY"]`.
117
121
 
118
- #### Mailgun
122
+ #### Mandrill
123
+
124
+ Add the gem
119
125
 
120
126
  ```ruby
121
- gem 'mailgun-ruby'
127
+ gem 'mandrill-api'
122
128
  ```
123
129
 
124
- Be sure `ENV["MAILGUN_API_KEY"]` is set.
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
- Be sure `ENV["POSTMARK_API_KEY"]` is set.
140
+ And set `ENV["POSTMARK_API_KEY"]`.
133
141
 
134
- #### Other
142
+ #### SendGrid
135
143
 
136
- Will gladly accept pull requests.
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::Sendgrid.new(api_key: "API_KEY"),
145
- Mailkick::Service::Mandrill.new(api_key: "API_KEY")
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
+ ```
@@ -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
@@ -17,10 +17,6 @@ module Mailkick
17
17
 
18
18
  creds.respond_to?(:secret_key_base) ? creds.secret_key_base : creds.secret_token
19
19
  end
20
-
21
- ActiveSupport.on_load :action_mailer do
22
- helper Mailkick::UrlHelper
23
- end
24
20
  end
25
21
  end
26
22
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Mailkick
4
4
  class Service
5
- class Sendgrid < Mailkick::Service
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
@@ -1,3 +1,3 @@
1
1
  module Mailkick
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
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.1
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: 2019-10-28 00:00:00.000000000 Z
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.0.3
228
+ rubygems_version: 3.1.2
228
229
  signing_key:
229
230
  specification_version: 4
230
231
  summary: Email subscriptions made easy