Class: Enkimail::Client
- Inherits:
-
Object
- Object
- Enkimail::Client
- Defined in:
- lib/enkimail/client.rb
Constant Summary collapse
- DEFAULT_BASE_URL =
"https://api.enkimail.com"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
Instance Method Summary collapse
- #deliver(mail) ⇒ Object
-
#initialize(api_key, base_url: nil) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(api_key, base_url: nil) ⇒ Client
12 13 14 15 |
# File 'lib/enkimail/client.rb', line 12 def initialize(api_key, base_url: nil) @api_key = api_key @base_url = (base_url || DEFAULT_BASE_URL).chomp("/") end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/enkimail/client.rb', line 10 def api_key @api_key end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
10 11 12 |
# File 'lib/enkimail/client.rb', line 10 def base_url @base_url end |
Instance Method Details
#deliver(mail) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/enkimail/client.rb', line 17 def deliver(mail) response = connection.post("/api/v1/transactional_emails") do |req| req.body = build_payload(mail) end handle_response(response) rescue Faraday::Error => e raise Error, "Enkimail Connection Error: #{e.message}" end |