flowmailer_rails 0.1.0 → 0.2.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/Gemfile.lock +33 -33
- data/README.md +28 -4
- data/lib/flowmailer_rails/mailer.rb +14 -2
- data/lib/flowmailer_rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 26ad29df91bf8ce2e60eea7d6bc7e35ead984aaacb88a09fce445ec98def8542
|
|
4
|
+
data.tar.gz: 606d48b72365d4c9c36bf3b605ff29a4ed9ff159b34889209280ccf1b90872ce
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6571137fd7a30106c0fa50adc8e0631c6ae7f74efeea7f5a4dbecccad74dc94a3419ee4143d46a2e9ac681d072d6c9fc9b6ea53914f810383cee6e0cc90381dc
|
|
7
|
+
data.tar.gz: fdf61fa3331fea173cdfaa6e36826b30f7c5e1e48286ee6c91cad28d71264aadcd9b26f040c225617db810aa4dc5c365cd4f3202266e4d9f21a47546f69fa578
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
flowmailer_rails (0.
|
|
4
|
+
flowmailer_rails (0.2.0)
|
|
5
5
|
actionmailer (>= 3.0.0)
|
|
6
6
|
faraday (>= 0.7.4, < 1.0)
|
|
7
7
|
faraday_middleware
|
|
@@ -9,68 +9,69 @@ PATH
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
actionmailer (6.
|
|
13
|
-
actionpack (= 6.
|
|
14
|
-
actionview (= 6.
|
|
15
|
-
activejob (= 6.
|
|
12
|
+
actionmailer (6.1.3.2)
|
|
13
|
+
actionpack (= 6.1.3.2)
|
|
14
|
+
actionview (= 6.1.3.2)
|
|
15
|
+
activejob (= 6.1.3.2)
|
|
16
|
+
activesupport (= 6.1.3.2)
|
|
16
17
|
mail (~> 2.5, >= 2.5.4)
|
|
17
18
|
rails-dom-testing (~> 2.0)
|
|
18
|
-
actionpack (6.
|
|
19
|
-
actionview (= 6.
|
|
20
|
-
activesupport (= 6.
|
|
21
|
-
rack (~> 2.0, >= 2.0.
|
|
19
|
+
actionpack (6.1.3.2)
|
|
20
|
+
actionview (= 6.1.3.2)
|
|
21
|
+
activesupport (= 6.1.3.2)
|
|
22
|
+
rack (~> 2.0, >= 2.0.9)
|
|
22
23
|
rack-test (>= 0.6.3)
|
|
23
24
|
rails-dom-testing (~> 2.0)
|
|
24
25
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
25
|
-
actionview (6.
|
|
26
|
-
activesupport (= 6.
|
|
26
|
+
actionview (6.1.3.2)
|
|
27
|
+
activesupport (= 6.1.3.2)
|
|
27
28
|
builder (~> 3.1)
|
|
28
29
|
erubi (~> 1.4)
|
|
29
30
|
rails-dom-testing (~> 2.0)
|
|
30
31
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
31
|
-
activejob (6.
|
|
32
|
-
activesupport (= 6.
|
|
32
|
+
activejob (6.1.3.2)
|
|
33
|
+
activesupport (= 6.1.3.2)
|
|
33
34
|
globalid (>= 0.3.6)
|
|
34
|
-
activesupport (6.
|
|
35
|
+
activesupport (6.1.3.2)
|
|
35
36
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
36
|
-
i18n (>=
|
|
37
|
-
minitest (
|
|
38
|
-
tzinfo (~>
|
|
39
|
-
zeitwerk (~> 2.
|
|
37
|
+
i18n (>= 1.6, < 2)
|
|
38
|
+
minitest (>= 5.1)
|
|
39
|
+
tzinfo (~> 2.0)
|
|
40
|
+
zeitwerk (~> 2.3)
|
|
40
41
|
addressable (2.7.0)
|
|
41
42
|
public_suffix (>= 2.0.2, < 5.0)
|
|
42
43
|
ast (2.4.1)
|
|
43
44
|
builder (3.2.4)
|
|
44
|
-
concurrent-ruby (1.1.
|
|
45
|
+
concurrent-ruby (1.1.8)
|
|
45
46
|
crack (0.4.4)
|
|
46
47
|
crass (1.0.6)
|
|
47
48
|
diff-lcs (1.3)
|
|
48
49
|
docile (1.3.2)
|
|
49
50
|
erubi (1.10.0)
|
|
50
|
-
faraday (0.17.
|
|
51
|
+
faraday (0.17.4)
|
|
51
52
|
multipart-post (>= 1.2, < 3)
|
|
52
53
|
faraday_middleware (0.14.0)
|
|
53
54
|
faraday (>= 0.7.4, < 1.0)
|
|
54
55
|
globalid (0.4.2)
|
|
55
56
|
activesupport (>= 4.2.0)
|
|
56
57
|
hashdiff (1.0.1)
|
|
57
|
-
i18n (1.8.
|
|
58
|
+
i18n (1.8.10)
|
|
58
59
|
concurrent-ruby (~> 1.0)
|
|
59
|
-
loofah (2.
|
|
60
|
+
loofah (2.9.1)
|
|
60
61
|
crass (~> 1.0.2)
|
|
61
62
|
nokogiri (>= 1.5.9)
|
|
62
63
|
mail (2.7.1)
|
|
63
64
|
mini_mime (>= 0.1.1)
|
|
64
|
-
mini_mime (1.0
|
|
65
|
-
|
|
66
|
-
minitest (5.14.2)
|
|
65
|
+
mini_mime (1.1.0)
|
|
66
|
+
minitest (5.14.4)
|
|
67
67
|
multipart-post (2.1.1)
|
|
68
|
-
nokogiri (1.
|
|
69
|
-
|
|
68
|
+
nokogiri (1.11.6-arm64-darwin)
|
|
69
|
+
racc (~> 1.4)
|
|
70
70
|
parallel (1.20.0)
|
|
71
71
|
parser (2.7.2.0)
|
|
72
72
|
ast (~> 2.4.1)
|
|
73
73
|
public_suffix (4.0.6)
|
|
74
|
+
racc (1.5.2)
|
|
74
75
|
rack (2.2.3)
|
|
75
76
|
rack-test (1.1.0)
|
|
76
77
|
rack (>= 1.0, < 3)
|
|
@@ -82,7 +83,7 @@ GEM
|
|
|
82
83
|
rainbow (3.0.0)
|
|
83
84
|
rake (13.0.1)
|
|
84
85
|
regexp_parser (1.8.2)
|
|
85
|
-
rexml (3.2.
|
|
86
|
+
rexml (3.2.5)
|
|
86
87
|
rspec (3.9.0)
|
|
87
88
|
rspec-core (~> 3.9.0)
|
|
88
89
|
rspec-expectations (~> 3.9.0)
|
|
@@ -119,15 +120,14 @@ GEM
|
|
|
119
120
|
standard (0.6.2)
|
|
120
121
|
rubocop (= 0.91.1)
|
|
121
122
|
rubocop-performance (= 1.8.1)
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
thread_safe (~> 0.1)
|
|
123
|
+
tzinfo (2.0.4)
|
|
124
|
+
concurrent-ruby (~> 1.0)
|
|
125
125
|
unicode-display_width (1.7.0)
|
|
126
126
|
webmock (3.10.0)
|
|
127
127
|
addressable (>= 2.3.6)
|
|
128
128
|
crack (>= 0.3.2)
|
|
129
129
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
130
|
-
zeitwerk (2.4.
|
|
130
|
+
zeitwerk (2.4.2)
|
|
131
131
|
|
|
132
132
|
PLATFORMS
|
|
133
133
|
ruby
|
|
@@ -143,4 +143,4 @@ DEPENDENCIES
|
|
|
143
143
|
webmock (~> 3.10.0)
|
|
144
144
|
|
|
145
145
|
BUNDLED WITH
|
|
146
|
-
2.
|
|
146
|
+
2.1.4
|
data/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
# FlowmailerRails
|
|
2
|
+
[](https://rubygems.org/gems/flowmailer_rails)
|
|
3
|
+

|
|
2
4
|
|
|
3
5
|
Send ActionMailer emails with Flowmailer
|
|
4
6
|
|
|
@@ -14,14 +16,36 @@ And then execute:
|
|
|
14
16
|
|
|
15
17
|
$ bundle
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
## Usage
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
### Configuration
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
Add basic configuration by providing it with your account id and client Id and Secret for an API source with submitt access.
|
|
24
|
+
```ruby
|
|
25
|
+
# config/production.rb
|
|
26
|
+
config.action_mailer.flowmailer_settings = {
|
|
27
|
+
account_id: ENV["FLOWMAILER_ACCOUNT_ID"],
|
|
28
|
+
client_id: ENV["FLOWMAILER_CLIENT_ID"],
|
|
29
|
+
client_secret: ENV["FLOWMAILER_CLIENT_SECRET"],
|
|
30
|
+
}
|
|
31
|
+
```
|
|
22
32
|
|
|
23
|
-
|
|
33
|
+
You can also provide procs that handles the `access_token` retrieval if you already have that logic in your Rails app:
|
|
34
|
+
```ruby
|
|
35
|
+
# config/production.rb
|
|
36
|
+
config.action_mailer.flowmailer_settings = {
|
|
37
|
+
account_id: ENV["FLOWMAILER_ACCOUNT_ID"],
|
|
38
|
+
access_token: -> { FooBar.access_token },
|
|
39
|
+
fetch_new_access_token: -> { FooBar.fetch_new_access_token },
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Tell Rails to use Flowmailer as the delivery method
|
|
24
44
|
|
|
45
|
+
```ruby
|
|
46
|
+
# config/production.rb
|
|
47
|
+
config.action_mailer.delivery_method = :flowmailer
|
|
48
|
+
```
|
|
25
49
|
## Development
|
|
26
50
|
|
|
27
51
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
@@ -5,6 +5,7 @@ module FlowmailerRails
|
|
|
5
5
|
class Mailer
|
|
6
6
|
class NoAccessTokenError < StandardError; end
|
|
7
7
|
class DeliveryError < StandardError; end
|
|
8
|
+
class TooBigMessageError < DeliveryError; end
|
|
8
9
|
class ExpiredAccessTokenError < StandardError; end
|
|
9
10
|
|
|
10
11
|
OAUTH_ENDPOINT = "https://login.flowmailer.net".freeze
|
|
@@ -38,8 +39,7 @@ module FlowmailerRails
|
|
|
38
39
|
begin
|
|
39
40
|
response = api_client.post(path, json, authorization_header)
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
raise DeliveryError, response.body unless response.success?
|
|
42
|
+
handle_failure(response)
|
|
43
43
|
rescue ExpiredAccessTokenError
|
|
44
44
|
if (retries += 1) <= 3
|
|
45
45
|
fetch_new_access_token
|
|
@@ -52,6 +52,18 @@ module FlowmailerRails
|
|
|
52
52
|
response
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
def handle_failure(response)
|
|
56
|
+
return if response.success?
|
|
57
|
+
|
|
58
|
+
raise ExpiredAccessTokenError if response.status == 401
|
|
59
|
+
|
|
60
|
+
too_big_error = response.body&.[]("allErrors")&.find { |error| error["code"] == "message.toobig" }
|
|
61
|
+
|
|
62
|
+
raise TooBigMessageError, too_big_error["defaultMessage"] if too_big_error.present?
|
|
63
|
+
|
|
64
|
+
raise DeliveryError, response.body
|
|
65
|
+
end
|
|
66
|
+
|
|
55
67
|
def api_client
|
|
56
68
|
@api_client ||= Faraday.new(url: API_ENDPOINT) { |conn|
|
|
57
69
|
conn.request :json
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: flowmailer_rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonas Brusman
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-06-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: actionmailer
|
|
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
199
199
|
- !ruby/object:Gem::Version
|
|
200
200
|
version: '0'
|
|
201
201
|
requirements: []
|
|
202
|
-
rubygems_version: 3.
|
|
202
|
+
rubygems_version: 3.1.4
|
|
203
203
|
signing_key:
|
|
204
204
|
specification_version: 4
|
|
205
205
|
summary: ActionMailer adapter for Flowmailer
|