Class: Tml::Postoffice
Constant Summary collapse
- PO_HOST =
'https://postoffice.translationexchange.com'- API_VERSION =
'v1'
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#deliver(to, template, tokens = {}, options = {}) ⇒ Object
Postoffice API client.
-
#host ⇒ Object
API host.
-
#token ⇒ Object
API token.
Methods inherited from Base
attributes, belongs_to, has_many, #hash_value, hash_value, #initialize, #method_missing, #to_hash, #update_attributes
Constructor Details
This class inherits a constructor from Tml::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Tml::Base
Instance Method Details
#deliver(to, template, tokens = {}, options = {}) ⇒ Object
Postoffice API client
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/tml/postoffice.rb', line 68 def deliver(to, template, tokens = {}, = {}) if key.blank? Tml.logger.error("Failed to deliver #{template} to #{to} - PostOffice has not been configured") return end Tml.logger.debug("Delivering #{template} to #{to}") params = { client_id: key, template: template, tokens: tokens, to: to, via: [:via], from: [:from], locale: [:locale], first_name: [:first_name], last_name: [:last_name], name: [:name] } params = Tml::Utils.remove_nils(params) api_client.execute_request("#{host}/api/#{API_VERSION}/deliver", params, {:method => :post}) end |
#host ⇒ Object
API host
58 59 60 |
# File 'lib/tml/postoffice.rb', line 58 def host super || PO_HOST end |
#token ⇒ Object
API token
63 64 65 |
# File 'lib/tml/postoffice.rb', line 63 def token access_token end |