google-http-actionmailer 0.2.0 → 0.3.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/README.md +41 -0
- data/lib/google_http_actionmailer.rb +1 -1
- data/lib/google_http_actionmailer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc118bab2e0798e2e0fa9ea780750b48840f1563f5f5adb3f58450511613510f
|
4
|
+
data.tar.gz: 11c6e65d3b700f0bcc58fcf5f5299feae2036c4e870fd8b77fa2e7bd2979f526
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 072e4c2f49676361f553e4b0fbcc1f8648a4210537cd03a8e9943d055d6284c146682cfdf96d7ff4c3292492b345b690e3c0cfe1ea8fe33a26484560a057302e
|
7
|
+
data.tar.gz: '03685f26244524317ed588e5a0008053a6f91b4e97f606ebe55629a325ca1f0d3b70e112c1d06997db03beb6877c04806a5273acc37f1d0543164ed965a304b9'
|
data/README.md
CHANGED
@@ -24,6 +24,7 @@ Set up your `authorization` as described in the [Google API Client](https://gith
|
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
config.action_mailer.delivery_method = :google_http_actionmailer
|
27
|
+
|
27
28
|
config.action_mailer.google_http_actionmailer_settings = {
|
28
29
|
authorization: ...,
|
29
30
|
client_options: {
|
@@ -37,10 +38,24 @@ config.action_mailer.google_http_actionmailer_settings = {
|
|
37
38
|
message_options: {
|
38
39
|
fields: ...,
|
39
40
|
content_type: ...,
|
41
|
+
},
|
42
|
+
delivery_options: {
|
43
|
+
before_send: ...,
|
44
|
+
after_send: ...,
|
40
45
|
}
|
41
46
|
}
|
42
47
|
```
|
43
48
|
|
49
|
+
### Options
|
50
|
+
|
51
|
+
| option | details |
|
52
|
+
| ------ | ------- |
|
53
|
+
| authorization | This is the authorization, it could be a access token, etc as described in the [Google API Client](https://github.com/google/google-api-ruby-client/#authorization) |
|
54
|
+
| client_options | General client options as described in the [Google API Client options code](https://github.com/googleapis/google-api-ruby-client/blob/0.26.0/lib/google/apis/options.rb#L38). |
|
55
|
+
| request_options | General request options as described in the [Google API Client options code](https://github.com/googleapis/google-api-ruby-client/blob/0.26.0/lib/google/apis/options.rb#L62). |
|
56
|
+
| message_options | [Specific options](https://github.com/googleapis/google-api-ruby-client/blob/0.26.0/generated/google/apis/gmail_v1/service.rb#L1075) for that message such as fields, content_type, upload_source and quota_user. |
|
57
|
+
| delivery_options | This currently contains hooks for before the message is sent and after the message is sent. |
|
58
|
+
|
44
59
|
For client and request options, you can look [here](https://github.com/google/google-api-ruby-client/blob/master/lib/google/apis/options.rb). And for message options, you can look at the `send_user_message` method [here](https://github.com/google/google-api-ruby-client/blob/master/generated/google/apis/gmail_v1/service.rb#L1150).
|
45
60
|
|
46
61
|
For dynamic setting of delivery method (this may be required given the access tokens usually expire):
|
@@ -54,6 +69,32 @@ mail.delivery_method(
|
|
54
69
|
|
55
70
|
Normal ActionMailer usage will now transparently be sent using Google's HTTPS API.
|
56
71
|
|
72
|
+
To use the delivery options pass a proc that takes two parameters mail (the object created by ActionMailer) and message (the object created by the Gmail API).
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
GoogleHttpActionmailer::DeliveryMethod, {
|
76
|
+
authorization: access_token,
|
77
|
+
client_options: {
|
78
|
+
application_name: ...,
|
79
|
+
application_version: ...,
|
80
|
+
},
|
81
|
+
delivery_options: {
|
82
|
+
after_send: ->(mail, message) {
|
83
|
+
StorePostSendDetails.call(user: self, mail: mail, message: message)
|
84
|
+
},
|
85
|
+
before_send: ->(mail, message) {
|
86
|
+
StorePreSendDetails.call(user: self, mail: mail, message: message)
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|
90
|
+
```
|
91
|
+
|
92
|
+
If you want to set the threadId to your outgoing mail, just add the header 'Thread-ID' with the appropriate value.
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
mail to: email, subject: subject, "Thread-ID": thread_id
|
96
|
+
```
|
97
|
+
|
57
98
|
## Development
|
58
99
|
|
59
100
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -34,7 +34,7 @@ module GoogleHttpActionmailer
|
|
34
34
|
user_id = message_options[:user_id] || 'me'
|
35
35
|
message = Google::Apis::GmailV1::Message.new(
|
36
36
|
raw: mail.to_s,
|
37
|
-
thread_id: mail['Thread-ID']
|
37
|
+
thread_id: mail['Thread-ID'].to_s
|
38
38
|
)
|
39
39
|
|
40
40
|
before_send = delivery_options[:before_send]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-http-actionmailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kartik Luke Singh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|