postageapp 1.3.0 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +6 -0
- data/.travis.yml +9 -39
- data/{LICENSE → LICENSE.md} +1 -1
- data/README.md +117 -13
- data/Rakefile +15 -4
- data/VERSION +1 -0
- data/app/ingresses/action_mailbox/ingresses/postage_app/inbound_emails_controller.rb +52 -0
- data/app/ingresses/action_mailbox/ingresses/postage_app.rb +4 -0
- data/config/routes.rb +8 -0
- data/exe/postageapp +37 -0
- data/lib/generators/postageapp/postageapp_generator.rb +9 -6
- data/lib/postageapp/cli/command/config.rb +74 -0
- data/lib/postageapp/cli/command/create_mailbox.rb +21 -0
- data/lib/postageapp/cli/command/env.rb +58 -0
- data/lib/postageapp/cli/command/get_project_info.rb +3 -0
- data/lib/postageapp/cli/command.rb +110 -0
- data/lib/postageapp/cli.rb +14 -0
- data/lib/postageapp/configuration.rb +237 -74
- data/lib/postageapp/engine.rb +11 -0
- data/lib/postageapp/env.rb +9 -0
- data/lib/postageapp/mailer/mailer_4.rb +30 -14
- data/lib/postageapp/mailer.rb +1 -11
- data/lib/postageapp/rails/railtie.rb +1 -3
- data/lib/postageapp/request.rb +6 -1
- data/lib/postageapp.rb +53 -35
- data/log/.gitignore +1 -0
- data/postageapp.gemspec +7 -10
- data/script/with +2 -2
- data/test/gemfiles/Gemfile.rails-2.3.x +1 -1
- data/test/gemfiles/Gemfile.rails-3.0.x +1 -1
- data/test/gemfiles/Gemfile.rails-3.1.x +1 -1
- data/test/gemfiles/Gemfile.rails-3.2.x +1 -1
- data/test/gemfiles/Gemfile.rails-4.0.x +1 -1
- data/test/gemfiles/Gemfile.rails-4.1.x +1 -1
- data/test/gemfiles/Gemfile.rails-4.2.x +1 -2
- data/test/gemfiles/Gemfile.rails-5.0.x +2 -3
- data/test/gemfiles/Gemfile.rails-5.2.x +12 -0
- data/test/gemfiles/Gemfile.rails-6.0.x +12 -0
- data/test/gemfiles/Gemfile.rails-6.1.x +12 -0
- data/test/gemfiles/Gemfile.ruby +2 -3
- data/test/helper.rb +5 -3
- data/test/log/.gitignore +1 -0
- data/test/mailer/action_mailer_3/notifier.rb +1 -1
- data/test/tmp/.gitignore +1 -0
- data/test/travis_test.rb +58 -40
- data/test/{configuration_test.rb → unit/configuration_test.rb} +18 -12
- data/test/{failed_request_test.rb → unit/failed_request_test.rb} +6 -6
- data/test/{live_test.rb → unit/live_test.rb} +4 -39
- data/test/{mail_delivery_method_test.rb → unit/mail_delivery_method_test.rb} +1 -1
- data/test/{mailer_4_test.rb → unit/mailer_4_test.rb} +2 -2
- data/test/{mailer_helper_methods_test.rb → unit/mailer_helper_methods_test.rb} +4 -4
- data/test/{postageapp_test.rb → unit/postageapp_test.rb} +7 -1
- data/test/{rails_initialization_test.rb → unit/rails_initialization_test.rb} +2 -2
- data/test/{request_test.rb → unit/request_test.rb} +18 -17
- data/test/{response_test.rb → unit/response_test.rb} +4 -4
- data/test/unit/tmp/.gitignore +1 -0
- data/tmp/.gitignore +1 -0
- metadata +41 -48
- data/lib/postageapp/mailer/mailer_2.rb +0 -140
- data/lib/postageapp/mailer/mailer_3.rb +0 -190
- data/lib/postageapp/version.rb +0 -3
- data/test/mailer/action_mailer_2/notifier/with_body_and_attachment.erb +0 -1
- data/test/mailer/action_mailer_2/notifier/with_custom_postage_variables.text.html.erb +0 -1
- data/test/mailer/action_mailer_2/notifier/with_custom_postage_variables.text.plain.erb +0 -1
- data/test/mailer/action_mailer_2/notifier/with_html_and_text_views.text.html.erb +0 -1
- data/test/mailer/action_mailer_2/notifier/with_html_and_text_views.text.plain.erb +0 -1
- data/test/mailer/action_mailer_2/notifier/with_simple_view.erb +0 -1
- data/test/mailer/action_mailer_2/notifier/with_text_only_view.text.plain.erb +0 -1
- data/test/mailer/action_mailer_2/notifier.rb +0 -77
- data/test/mailer_2_test.rb +0 -95
- data/test/mailer_3_test.rb +0 -118
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8fb7fce16defbeb345e4b38780b1fe03a30b15aa60a6da835366f7ae583fef0e
|
4
|
+
data.tar.gz: 5201a95c68b7c63ae1db1059131dd31fbc0a4945ebec7f8540ac52d838a81f6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d57a61ffdc8390963c98490e6b0e68cf98ccf396294cd603acc35c1874044d4453d69ccdbccb550f2cbc7746d64b19078dd62be7d915d80527922048c9909d97
|
7
|
+
data.tar.gz: d93cbdac054b4b5cce7c18e64aa911970c8746293b87f595e1964ccfccc63ad4f7ef9df09412a6e167b9c8982645dd679b56ef90a31f1cb19deda2cc967ef04d
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -3,45 +3,15 @@ before_install: "WITH_VERBOSE=1 script/with current bootstrap"
|
|
3
3
|
install: "WITH_VERBOSE=1 script/with current bundle install"
|
4
4
|
script: "WITH_VERBOSE=1 script/with current bundle exec rake test"
|
5
5
|
rvm:
|
6
|
-
-
|
7
|
-
- 2.
|
8
|
-
- 2.
|
9
|
-
-
|
10
|
-
-
|
11
|
-
- jruby-9.
|
6
|
+
- 2.5.9
|
7
|
+
- 2.6.7
|
8
|
+
- 2.7.3
|
9
|
+
- 3.0.1
|
10
|
+
- jruby-9.1.17.0
|
11
|
+
- jruby-9.2.17.0
|
12
12
|
gemfile:
|
13
13
|
- test/gemfiles/Gemfile.ruby
|
14
|
-
- test/gemfiles/Gemfile.rails-2.3.x
|
15
|
-
- test/gemfiles/Gemfile.rails-3.0.x
|
16
|
-
- test/gemfiles/Gemfile.rails-3.1.x
|
17
|
-
- test/gemfiles/Gemfile.rails-3.2.x
|
18
|
-
- test/gemfiles/Gemfile.rails-4.0.x
|
19
|
-
- test/gemfiles/Gemfile.rails-4.1.x
|
20
|
-
- test/gemfiles/Gemfile.rails-4.2.x
|
21
14
|
- test/gemfiles/Gemfile.rails-5.0.x
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
gemfile: test/gemfiles/Gemfile.rails-2.3.x
|
26
|
-
- rvm: 2.0.0-p648
|
27
|
-
gemfile: test/gemfiles/Gemfile.rails-2.3.x
|
28
|
-
- rvm: 2.1.10
|
29
|
-
gemfile: test/gemfiles/Gemfile.rails-2.3.x
|
30
|
-
- rvm: 2.2.5
|
31
|
-
gemfile: test/gemfiles/Gemfile.rails-2.3.x
|
32
|
-
- rvm: 2.3.1
|
33
|
-
gemfile: test/gemfiles/Gemfile.rails-2.3.x
|
34
|
-
- rvm: jruby-9.1.2.0
|
35
|
-
gemfile: test/gemfiles/Gemfile.rails-2.3.x
|
36
|
-
- rvm: 1.9.3-p551
|
37
|
-
gemfile: test/gemfiles/Gemfile.rails-4.0.x
|
38
|
-
- rvm: 1.9.3-p551
|
39
|
-
gemfile: test/gemfiles/Gemfile.rails-4.1.x
|
40
|
-
- rvm: 1.9.3-p551
|
41
|
-
gemfile: test/gemfiles/Gemfile.rails-4.2.x
|
42
|
-
- rvm: 1.9.3-p551
|
43
|
-
gemfile: test/gemfiles/Gemfile.rails-5.0.x
|
44
|
-
- rvm: 2.0.0-p648
|
45
|
-
gemfile: test/gemfiles/Gemfile.rails-5.0.x
|
46
|
-
- rvm: 2.1.10
|
47
|
-
gemfile: test/gemfiles/Gemfile.rails-5.0.x
|
15
|
+
- test/gemfiles/Gemfile.rails-5.2.x
|
16
|
+
- test/gemfiles/Gemfile.rails-6.0.x
|
17
|
+
- test/gemfiles/Gemfile.rails-6.1.x
|
data/{LICENSE → LICENSE.md}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2011-
|
1
|
+
Copyright (c) 2011-2019 Scott Tadman, Oleg Khabarov, PostageApp Ltd.
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -1,13 +1,35 @@
|
|
1
|
-
# [PostageApp](
|
1
|
+
# [PostageApp](https://postageapp.com/) Ruby Gem [![Build Status](https://secure.travis-ci.org/postageapp/postageapp-ruby.png)](http://travis-ci.org/postageapp/postageapp-ruby)
|
2
2
|
|
3
|
-
This gem is used to integrate Ruby apps with [PostageApp](
|
3
|
+
This gem is used to integrate Ruby apps with [PostageApp](https://postageapp.com/)
|
4
4
|
service. Personalized high-volume email sending can be offloaded to PostageApp
|
5
|
-
via a simple [JSON-based API](
|
5
|
+
via a simple [JSON-based API](https://dev.postageapp.com/api).
|
6
6
|
|
7
|
-
### [API Documentation](
|
7
|
+
### [API Documentation](https://dev.postageapp.com/api/)
|
8
8
|
|
9
9
|
# Installation
|
10
10
|
|
11
|
+
## Rails 5.2 and newer
|
12
|
+
|
13
|
+
Add the `postageapp` gem to your Gemfile:
|
14
|
+
|
15
|
+
gem 'postageapp'
|
16
|
+
|
17
|
+
Then from the Rails project's root run:
|
18
|
+
|
19
|
+
bundle install
|
20
|
+
|
21
|
+
For authentication, add your project's PostageApp credentials to the
|
22
|
+
Rails Encrypted Credentials:
|
23
|
+
|
24
|
+
rails credentials:edit
|
25
|
+
|
26
|
+
The format of this entry should be:
|
27
|
+
|
28
|
+
postageapp:
|
29
|
+
api_key: __PROJECT_API_KEY__
|
30
|
+
|
31
|
+
Where that will be picked up by the plugin when Rails starts.
|
32
|
+
|
11
33
|
## Rails 4.x and newer
|
12
34
|
|
13
35
|
Add the `postageapp` gem to your Gemfile:
|
@@ -26,9 +48,13 @@ Then from the Rails project's root run:
|
|
26
48
|
|
27
49
|
## Sinatra / Rack / Others
|
28
50
|
|
29
|
-
|
51
|
+
Add the `postageapp` gem to your Gemfile:
|
52
|
+
|
53
|
+
gem 'postageapp'
|
54
|
+
|
55
|
+
Then from the project's root run:
|
30
56
|
|
31
|
-
|
57
|
+
bundle install
|
32
58
|
|
33
59
|
The configuration will need to be loaded before executing any API calls:
|
34
60
|
|
@@ -46,7 +72,7 @@ with the appropriate API key will also work.
|
|
46
72
|
# Usage
|
47
73
|
|
48
74
|
Here's an example of sending a message using the
|
49
|
-
[`send_message`](
|
75
|
+
[`send_message`](https://dev.postageapp.com/api/send_message) API call:
|
50
76
|
|
51
77
|
```ruby
|
52
78
|
request = PostageApp::Request.new(
|
@@ -63,7 +89,7 @@ request = PostageApp::Request.new(
|
|
63
89
|
},
|
64
90
|
attachments: {
|
65
91
|
'document.pdf' => {
|
66
|
-
content_type: application/pdf',
|
92
|
+
content_type: 'application/pdf',
|
67
93
|
content: Base64.encode64(File.open('/path/to/document.pdf', 'rb').read)
|
68
94
|
}
|
69
95
|
}
|
@@ -121,7 +147,7 @@ require 'postageapp/mailer'
|
|
121
147
|
There are custom methods that allow setting of `template` and `variables` parts
|
122
148
|
of the API call. They are `postageapp_template` and `postageapp_variables`.
|
123
149
|
Examples how they are used are below. For details what they do please see
|
124
|
-
[documentation](
|
150
|
+
[documentation](https://dev.postageapp.com/api/)
|
125
151
|
|
126
152
|
Please note that `deliver` method will return `PostageApp::Response` object.
|
127
153
|
This way you can immediately check the status of the delivery. For example:
|
@@ -213,11 +239,89 @@ For projects other than Rails you'll need to tell where the `project_root` is:
|
|
213
239
|
|
214
240
|
```ruby
|
215
241
|
PostageApp.configure do |config|
|
216
|
-
config.api_key
|
242
|
+
config.api_key = 'PROJECT_API_KEY'
|
217
243
|
config.project_root = "/path/to/your/project"
|
218
244
|
end
|
219
245
|
```
|
220
246
|
|
221
|
-
#
|
222
|
-
|
223
|
-
|
247
|
+
# Configuration Details
|
248
|
+
|
249
|
+
Configuration can be done either via Ruby code directly, by environment
|
250
|
+
variables, or by a combination of both. Where both are supplied, the
|
251
|
+
Ruby setting will take precedence.
|
252
|
+
|
253
|
+
## Configuration Arguments
|
254
|
+
|
255
|
+
These can all be set with `PostageApp.config`:
|
256
|
+
|
257
|
+
* `api_key`: Project API key to use (required for project API functions)
|
258
|
+
* `account_api_key`: Account API key to use (required for account API functions)
|
259
|
+
* `postback_secret`: Secret to use for validating ActionMailbox requests (optional)
|
260
|
+
* `project_root`: Project root for logging purposes (default: current working directory)
|
261
|
+
* `recipient_override`: Override sender on `send_message` calls (optional)
|
262
|
+
* `logger`: Logger instance to use (optional)
|
263
|
+
* `secure`: Enable verifying TLS connections (default: `true`)
|
264
|
+
* `verify_tls`: Enable TLS certificate verification (default: `true`)
|
265
|
+
* `verify_certificate`: Alias for `verify_tls`
|
266
|
+
* `host`: API host to contact (default: `api.postageapp.com`)
|
267
|
+
* `port`: API port to contact (default: `443`)
|
268
|
+
* `scheme`: HTTP scheme to use (default: `https`)
|
269
|
+
* `protocol`: Alias for `scheme`
|
270
|
+
* `proxy_username`: SOCKS5 proxy username (optional)
|
271
|
+
* `proxy_user`: Alias for `proxy_username`
|
272
|
+
* `proxy_password`: SOCKS5 proxy password (optional)
|
273
|
+
* `proxy_pass`: Alias for `proxy_password`
|
274
|
+
* `proxy_host`: SOCKS5 proxy host (optional)
|
275
|
+
* `proxy_port`: SOCKS5 proxy port (default: `1080`)
|
276
|
+
* `open_timeout`: Timeout in seconds when initiating requests (default: `5`)
|
277
|
+
* `http_open_timeout`: Alias for `open_timeout`
|
278
|
+
* `read_timeout`: Timeout in seconds when awaiting responses (default: `10`)
|
279
|
+
* `http_read_timeout`: Alias for `read_timeout`
|
280
|
+
* `retry_methods`: Which API calls to retry, comma and/or space separated (default: `send_message`)
|
281
|
+
* `requests_to_resend`: Alias for `retry_methods`
|
282
|
+
* `framework`: Framework used (default: `Ruby`)
|
283
|
+
* `environment`: Environment to use (default: `production`)
|
284
|
+
|
285
|
+
A typical configuration involves setting the project API key:
|
286
|
+
|
287
|
+
PostageApp.config do |config|
|
288
|
+
config.api_key = 'PROJECT_API_KEY'
|
289
|
+
end
|
290
|
+
|
291
|
+
Where additional settings can be applied as necessary.
|
292
|
+
|
293
|
+
## Environment Variables
|
294
|
+
|
295
|
+
Most configuration parameters can be set via the environment:
|
296
|
+
|
297
|
+
* `POSTAGEAPP_API_KEY`: Project API key to use (required for project API functions)
|
298
|
+
* `POSTAGEAPP_ACCOUNT_API_KEY`: Account API key to use (required for account API functions)
|
299
|
+
* `POSTAGEAPP_POSTBACK_SECRET`: Secret to use for validating ActionMailbox requests (optional)
|
300
|
+
* `POSTAGEAPP_PROJECT_ROOT`: Project root for logging purposes (default: current working directory)
|
301
|
+
* `POSTAGEAPP_RECIPIENT_OVERRIDE`: Override sender on `send_message` calls (optional)
|
302
|
+
* `POSTAGEAPP_VERIFY_TLS`: (default: `true`)
|
303
|
+
* `POSTAGEAPP_VERIFY_CERTIFICATE`: Alias for `POSTAGEAPP_VERIFY_TLS`
|
304
|
+
* `POSTAGEAPP_HOST`: API host to contact (default: `api.postageapp.com`)
|
305
|
+
* `POSTAGEAPP_PORT`: API port to contact (default: `443`)
|
306
|
+
* `POSTAGEAPP_SCHEME`: HTTP scheme to use (default: `https`)
|
307
|
+
* `POSTAGEAPP_PROTOCOL`: Alias for `POSTAGEAPP_SCHEME`
|
308
|
+
* `POSTAGEAPP_PROXY_USERNAME`: SOCKS5 proxy username (optional)
|
309
|
+
* `POSTAGEAPP_PROXY_USER`: Alias for `POSTAGEAPP_PROXY_USERNAME`
|
310
|
+
* `POSTAGEAPP_PROXY_PASSWORD`: SOCKS5 proxy password (optional)
|
311
|
+
* `POSTAGEAPP_PROXY_PASS`: Alias for `POSTAGEAPP_PROXY_PASSWORD`
|
312
|
+
* `POSTAGEAPP_PROXY_HOST`: SOCKS5 proxy host (optional)
|
313
|
+
* `POSTAGEAPP_PROXY_PORT`: SOCKS5 proxy port (default: `1080`)
|
314
|
+
* `POSTAGEAPP_OPEN_TIMEOUT`: Timeout in seconds when initiating requests (default: `5`)
|
315
|
+
* `POSTAGEAPP_HTTP_OPEN_TIMEOUT`: Alias for `POSTAGEAPP_OPEN_TIMEOUT`
|
316
|
+
* `POSTAGEAPP_READ_TIMEOUT`: Timeout in seconds when awaiting responses (default: `10`)
|
317
|
+
* `POSTAGEAPP_HTTP_READ_TIMEOUT`: Alias for `POSTAGEAPP_READ_TIMEOUT`
|
318
|
+
* `POSTAGEAPP_RETRY_METHODS`: Which API calls to retry, comma and/or space separated (default: `send_message`)
|
319
|
+
* `POSTAGEAPP_REQUESTS_TO_RESEND`: Alias for `POSTAGEAPP_RETRY_METHODS`
|
320
|
+
* `POSTAGEAPP_FRAMEWORK`: Framework used (default: `Ruby`)
|
321
|
+
* `POSTAGEAPP_ENVIRONMENT`: Environment to use (default: `production`)
|
322
|
+
|
323
|
+
# Copyright and Licensing
|
324
|
+
|
325
|
+
(C) 2011-2019 Scott Tadman, Oleg Khabarov, [PostageApp](https://postageapp.com/)
|
326
|
+
|
327
|
+
This is released under the [MIT License](LICENSE.md).
|
data/Rakefile
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
# Avoid contaminating ENV with lots of BUNDLER_ variables
|
2
|
+
# require 'bundler/setup'
|
2
3
|
|
3
4
|
require 'rake/testtask'
|
4
5
|
|
@@ -11,17 +12,27 @@ end
|
|
11
12
|
namespace :travis do
|
12
13
|
desc "Run tests across different environments, simulating Travis"
|
13
14
|
task :test do
|
14
|
-
|
15
|
+
require_relative './test/travis_test'
|
15
16
|
|
16
17
|
TravisTest.run!
|
17
18
|
end
|
18
19
|
|
19
20
|
desc "Report on which versions of Ruby are installed"
|
20
21
|
task :versions do
|
21
|
-
|
22
|
+
require_relative './test/travis_test'
|
22
23
|
|
23
24
|
TravisTest.validate_ruby_versions!
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
|
-
task :
|
28
|
+
task default: :test
|
29
|
+
|
30
|
+
namespace :test do
|
31
|
+
task :rails do
|
32
|
+
ENV['BUNDLE_GEMFILE'] = File.expand_path('./test/gemfiles/Gemfile.rails-6.1.x', __dir__)
|
33
|
+
|
34
|
+
require 'bundler/setup'
|
35
|
+
|
36
|
+
p Rails
|
37
|
+
end
|
38
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.4.2
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
if (defined?(ActionMailbox) and defined?(ActionMailbox::BaseController))
|
4
|
+
class ActionMailbox::Ingresses::PostageApp::InboundEmailsController < ActionMailbox::BaseController
|
5
|
+
before_action :hmac_authenticate
|
6
|
+
|
7
|
+
def create
|
8
|
+
ActionMailbox::InboundEmail.create_and_extract_message_id!(message_param)
|
9
|
+
|
10
|
+
head(:ok)
|
11
|
+
|
12
|
+
rescue JSON::ParserError => e
|
13
|
+
logger.error(e.message)
|
14
|
+
|
15
|
+
head(:unprocessable_entity)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def message_param
|
20
|
+
params.require(:inbound_email).require(:message)
|
21
|
+
end
|
22
|
+
|
23
|
+
def hmac_authenticate
|
24
|
+
return if (hmac_authenticated?)
|
25
|
+
|
26
|
+
head(:unauthorized)
|
27
|
+
end
|
28
|
+
|
29
|
+
def hmac_authenticated?
|
30
|
+
if (PostageApp.config.postback_secret.present?)
|
31
|
+
ActiveSupport::SecurityUtils.secure_compare(
|
32
|
+
request.headers["X-PostageApp-Signature"],
|
33
|
+
hmac_signature(message_param, PostageApp.config.postback_secret)
|
34
|
+
)
|
35
|
+
else
|
36
|
+
raise ArgumentError, <<~END.squish
|
37
|
+
Missing required PostageApp "postback secret" which can be set as
|
38
|
+
in the Rails Encypted Credentials, as POSTAGEAPP_API_POSTBACK_SECRET
|
39
|
+
in the environment, or via a config/initializer script using the
|
40
|
+
PostageApp.config method.
|
41
|
+
END
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
def hmac_signature(*content)
|
47
|
+
Base64.strict_encode64(
|
48
|
+
OpenSSL::HMAC.digest(OpenSSL::Digest::SHA1.new, *content)
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
PostageApp::Engine.routes.draw do
|
2
|
+
if (defined?(ActionMailbox))
|
3
|
+
scope '/rails/action_mailbox', module: 'action_mailbox/ingresses' do
|
4
|
+
post '/postageapp/inbound_emails' => 'postage_app/inbound_emails#create',
|
5
|
+
as: :rails_postageapp_inbound_emails
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
data/exe/postageapp
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH << File.expand_path('../lib', __dir__)
|
4
|
+
|
5
|
+
require 'postageapp'
|
6
|
+
require 'postageapp/cli'
|
7
|
+
|
8
|
+
exit_code = -1
|
9
|
+
|
10
|
+
begin
|
11
|
+
if (ARGV.length > 0)
|
12
|
+
PostageApp::CLI.parse!(*ARGV)
|
13
|
+
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
rescue PostageApp::CLI::Command::MissingArguments
|
18
|
+
exit(-20)
|
19
|
+
rescue PostageApp::CLI::Command::APICallError
|
20
|
+
exit(-30)
|
21
|
+
rescue PostageApp::CLI::UnknownCommand => e
|
22
|
+
$stderr.puts("Error: #{e}")
|
23
|
+
exit_code = -11
|
24
|
+
end
|
25
|
+
|
26
|
+
puts "usage: postageapp command [options]"
|
27
|
+
puts
|
28
|
+
puts "commands:"
|
29
|
+
|
30
|
+
PostageApp::CLI::Command.defined.each do |command, _|
|
31
|
+
puts " #{command}"
|
32
|
+
end
|
33
|
+
|
34
|
+
puts
|
35
|
+
puts "* Documentation: https://dev.postageapp.com/api/"
|
36
|
+
|
37
|
+
exit(exit_code)
|
@@ -10,18 +10,21 @@ class PostageappGenerator < Rails::Generators::Base
|
|
10
10
|
def self.source_root
|
11
11
|
@__source_root ||= File.expand_path(
|
12
12
|
'../../../generators/postageapp/templates',
|
13
|
-
|
13
|
+
__dir__
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
17
17
|
def install
|
18
|
-
unless (
|
19
|
-
|
18
|
+
unless (PostageApp::Env.rails_with_encrypted_credentials?)
|
19
|
+
unless (options[:api_key])
|
20
|
+
puts 'Must pass --api-key with API key of your PostageApp.com project'
|
20
21
|
|
21
|
-
|
22
|
+
exit(-1)
|
23
|
+
end
|
24
|
+
|
25
|
+
template('initializer.rb', 'config/initializers/postageapp.rb')
|
22
26
|
end
|
23
|
-
|
24
|
-
template('initializer.rb', 'config/initializers/postageapp.rb')
|
27
|
+
|
25
28
|
copy_file('postageapp_tasks.rake', 'lib/tasks/postageapp_tasks.rake')
|
26
29
|
|
27
30
|
puts run('rake postageapp:test')
|
@@ -0,0 +1,74 @@
|
|
1
|
+
PostageApp::CLI::Command.define do
|
2
|
+
argument :'no-header',
|
3
|
+
optional: true,
|
4
|
+
boolean: true,
|
5
|
+
desc: 'An identifier to refer to this mailbox on subsequent API calls'
|
6
|
+
|
7
|
+
argument :markdown,
|
8
|
+
optional: true,
|
9
|
+
boolean: true,
|
10
|
+
desc: 'Emit markdown formatted description of variables'
|
11
|
+
|
12
|
+
perform do |arguments|
|
13
|
+
if (arguments[:markdown])
|
14
|
+
PostageApp::Configuration.params.each do |param, config|
|
15
|
+
case (default = config[:default])
|
16
|
+
when Proc
|
17
|
+
default = default.call
|
18
|
+
end
|
19
|
+
|
20
|
+
puts '* `%s`: %s (%s)' % [
|
21
|
+
param,
|
22
|
+
config[:desc],
|
23
|
+
case (config[:required])
|
24
|
+
when String
|
25
|
+
'required %s' % config[:required]
|
26
|
+
when true
|
27
|
+
'required'
|
28
|
+
else
|
29
|
+
default ? 'default: `%s`' % default : 'optional'
|
30
|
+
end
|
31
|
+
]
|
32
|
+
|
33
|
+
config[:aliases]&.each do |param_alias|
|
34
|
+
puts '* `%s`: Alias for `%s`' % [
|
35
|
+
param_alias,
|
36
|
+
param
|
37
|
+
]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
else
|
41
|
+
unless (arguments[:'no-header'])
|
42
|
+
puts '%-40s %s' % [ 'Variable', 'Description' ]
|
43
|
+
puts '-' * 78
|
44
|
+
end
|
45
|
+
|
46
|
+
PostageApp::Configuration.params.each do |param, config|
|
47
|
+
case (default = config[:default])
|
48
|
+
when Proc
|
49
|
+
default = default.call
|
50
|
+
end
|
51
|
+
|
52
|
+
puts '%-40s %s (%s)' % [
|
53
|
+
param,
|
54
|
+
config[:desc],
|
55
|
+
case (config[:required])
|
56
|
+
when String
|
57
|
+
'required %s' % config[:required]
|
58
|
+
when true
|
59
|
+
'required'
|
60
|
+
else
|
61
|
+
default ? 'default: %s' % default : 'optional'
|
62
|
+
end
|
63
|
+
]
|
64
|
+
|
65
|
+
config[:aliases]&.each do |param_alias|
|
66
|
+
puts '%-40s Alias for %s' % [
|
67
|
+
param_alias,
|
68
|
+
param
|
69
|
+
]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|