mailkick 0.4.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,41 @@
1
+ # https://github.com/wildbit/postmark-gem
2
+
3
+ module Mailkick
4
+ class Service
5
+ class Postmark < Mailkick::Service
6
+ REASONS_MAP = {
7
+ "SpamNotification" => "spam",
8
+ "SpamComplaint" => "spam",
9
+ "Unsubscribe" => "unsubscribe",
10
+ }
11
+
12
+ def initialize(options = {})
13
+ @client = ::Postmark::ApiClient.new(options[:api_key] || ENV["POSTMARK_API_KEY"])
14
+ end
15
+
16
+ def opt_outs
17
+ bounces
18
+ end
19
+
20
+ def bounces
21
+ fetch(@client.bounces)
22
+ end
23
+
24
+ def self.discoverable?
25
+ !!(defined?(::Postmark) && ENV["POSTMARK_API_KEY"])
26
+ end
27
+
28
+ protected
29
+
30
+ def fetch(response)
31
+ response.map do |record|
32
+ {
33
+ email: record[:email],
34
+ time: ActiveSupport::TimeZone["UTC"].parse(record[:bounced_at]),
35
+ reason: REASONS_MAP.fetch(record[:type], "bounce")
36
+ }
37
+ end
38
+ end
39
+ end
40
+ end
41
+ 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
@@ -0,0 +1,8 @@
1
+ module Mailkick
2
+ module UrlHelper
3
+ def mailkick_unsubscribe_url(subscriber, list, **options)
4
+ token = Mailkick.generate_token(subscriber, list)
5
+ mailkick.unsubscribe_subscription_url(token, **options)
6
+ end
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module Mailkick
2
- VERSION = "0.4.0"
2
+ VERSION = "1.0.1"
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.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-16 00:00:00.000000000 Z
11
+ date: 2021-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,156 +16,16 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5'
19
+ version: '5.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: gibbon
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '2'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '2'
55
- - !ruby/object:Gem::Dependency
56
- name: mailgun-ruby
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: mandrill-api
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: minitest
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: rake
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: sendgrid_toolkit
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: combustion
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: rails
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: sqlite3
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
- description:
168
- email: andrew@chartkick.com
26
+ version: '5.2'
27
+ description:
28
+ email: andrew@ankane.org
169
29
  executables: []
170
30
  extensions: []
171
31
  extra_rdoc_files: []
@@ -174,8 +34,8 @@ files:
174
34
  - LICENSE.txt
175
35
  - README.md
176
36
  - app/controllers/mailkick/subscriptions_controller.rb
177
- - app/helpers/mailkick/url_helper.rb
178
37
  - app/models/mailkick/opt_out.rb
38
+ - app/models/mailkick/subscription.rb
179
39
  - app/views/mailkick/subscriptions/show.html.erb
180
40
  - config/routes.rb
181
41
  - lib/generators/mailkick/install_generator.rb
@@ -183,18 +43,23 @@ files:
183
43
  - lib/generators/mailkick/views_generator.rb
184
44
  - lib/mailkick.rb
185
45
  - lib/mailkick/engine.rb
46
+ - lib/mailkick/legacy.rb
186
47
  - lib/mailkick/model.rb
187
48
  - lib/mailkick/service.rb
49
+ - lib/mailkick/service/aws_ses.rb
188
50
  - lib/mailkick/service/mailchimp.rb
189
51
  - lib/mailkick/service/mailgun.rb
190
52
  - lib/mailkick/service/mandrill.rb
53
+ - lib/mailkick/service/postmark.rb
191
54
  - lib/mailkick/service/sendgrid.rb
55
+ - lib/mailkick/service/sendgrid_v2.rb
56
+ - lib/mailkick/url_helper.rb
192
57
  - lib/mailkick/version.rb
193
58
  homepage: https://github.com/ankane/mailkick
194
59
  licenses:
195
60
  - MIT
196
61
  metadata: {}
197
- post_install_message:
62
+ post_install_message:
198
63
  rdoc_options: []
199
64
  require_paths:
200
65
  - lib
@@ -202,15 +67,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
202
67
  requirements:
203
68
  - - ">="
204
69
  - !ruby/object:Gem::Version
205
- version: '2.4'
70
+ version: '2.6'
206
71
  required_rubygems_version: !ruby/object:Gem::Requirement
207
72
  requirements:
208
73
  - - ">="
209
74
  - !ruby/object:Gem::Version
210
75
  version: '0'
211
76
  requirements: []
212
- rubygems_version: 3.0.4
213
- signing_key:
77
+ rubygems_version: 3.2.3
78
+ signing_key:
214
79
  specification_version: 4
215
- summary: Email subscriptions made easy
80
+ summary: Email subscriptions for Rails
216
81
  test_files: []
@@ -1,15 +0,0 @@
1
- module Mailkick
2
- module UrlHelper
3
- def mailkick_unsubscribe_url(email: nil, user: nil, list: nil, **options)
4
- email ||= controller.try(:message).try(:to).try(:first)
5
-
6
- Mailkick::Engine.routes.url_helpers.url_for(
7
- (ActionMailer::Base.default_url_options || {}).merge(options).merge(
8
- controller: "mailkick/subscriptions",
9
- action: "unsubscribe",
10
- id: Mailkick.generate_token(email, user: user, list: list)
11
- )
12
- )
13
- end
14
- end
15
- end