Class: MailHandler::Sending::PostmarkAPISender
- Inherits:
-
MailHandler::Sender
- Object
- MailHandler::Sender
- MailHandler::Sending::PostmarkAPISender
- Defined in:
- lib/mailhandler/sending/api.rb
Overview
sending email by Postmark API
Direct Known Subclasses
Constant Summary collapse
- DEFAULTS =
{ host: 'api.postmarkapp.com', read_timeout: 15, open_timeout: 15 }.freeze
Instance Attribute Summary collapse
-
#api_token ⇒ Object
Returns the value of attribute api_token.
-
#client ⇒ Object
Returns the value of attribute client.
-
#host ⇒ Object
Returns the value of attribute host.
-
#http_open_timeout ⇒ Object
Returns the value of attribute http_open_timeout.
-
#http_read_timeout ⇒ Object
Returns the value of attribute http_read_timeout.
-
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
Attributes inherited from MailHandler::Sender
Instance Method Summary collapse
- #init_client ⇒ Object
-
#initialize(api_token = nil) ⇒ PostmarkAPISender
constructor
A new instance of PostmarkAPISender.
- #send(email) ⇒ Object
- #setup_sending_client ⇒ Object
Methods inherited from MailHandler::Sender
#dispatcher_client, #send_email
Constructor Details
#initialize(api_token = nil) ⇒ PostmarkAPISender
Returns a new instance of PostmarkAPISender.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/mailhandler/sending/api.rb', line 17 def initialize(api_token = nil) @type = :postmark_api @host = DEFAULTS[:host] @api_token = api_token @use_ssl = false @http_open_timeout = DEFAULTS[:open_timeout] @http_read_timeout = DEFAULTS[:read_timeout] init_client end |
Instance Attribute Details
#api_token ⇒ Object
Returns the value of attribute api_token.
10 11 12 |
# File 'lib/mailhandler/sending/api.rb', line 10 def api_token @api_token end |
#client ⇒ Object
Returns the value of attribute client.
10 11 12 |
# File 'lib/mailhandler/sending/api.rb', line 10 def client @client end |
#host ⇒ Object
Returns the value of attribute host.
10 11 12 |
# File 'lib/mailhandler/sending/api.rb', line 10 def host @host end |
#http_open_timeout ⇒ Object
Returns the value of attribute http_open_timeout.
10 11 12 |
# File 'lib/mailhandler/sending/api.rb', line 10 def http_open_timeout @http_open_timeout end |
#http_read_timeout ⇒ Object
Returns the value of attribute http_read_timeout.
10 11 12 |
# File 'lib/mailhandler/sending/api.rb', line 10 def http_read_timeout @http_read_timeout end |
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
10 11 12 |
# File 'lib/mailhandler/sending/api.rb', line 10 def use_ssl @use_ssl end |
Instance Method Details
#init_client ⇒ Object
34 35 36 |
# File 'lib/mailhandler/sending/api.rb', line 34 def init_client @client = setup_sending_client end |
#send(email) ⇒ Object
28 29 30 31 32 |
# File 'lib/mailhandler/sending/api.rb', line 28 def send(email) verify_email(email) init_client client.(email) end |
#setup_sending_client ⇒ Object
38 39 40 41 42 43 |
# File 'lib/mailhandler/sending/api.rb', line 38 def setup_sending_client # clearing cache so valid host is accepted, and not the cached one Postmark::HttpClient.instance_variable_set('@http', nil) Postmark::ApiClient.new(api_token, http_open_timeout: http_open_timeout, http_read_timeout: http_read_timeout, host: host, secure: @use_ssl) end |