Class: EmailOctopus::API
- Inherits:
-
Object
- Object
- EmailOctopus::API
- Defined in:
- lib/email_octopus/api.rb,
lib/email_octopus/api/error.rb,
lib/email_octopus/api/response.rb,
lib/email_octopus/api/error/not_found.rb,
lib/email_octopus/api/error/unauthorized.rb,
lib/email_octopus/api/error/api_key_invalid.rb,
lib/email_octopus/api/error/invalid_parameters.rb
Overview
HTTP API gateway to communicate with Email Octopus.
Defined Under Namespace
Constant Summary collapse
- HOST =
'emailoctopus.com/api/1.1'
- PORT =
443
- HEADERS =
{ 'Content-Type' => 'application/json' }.freeze
Instance Method Summary collapse
- #delete(path) ⇒ Object
- #get(path) ⇒ Object
-
#initialize(api_key) ⇒ API
constructor
A new instance of API.
- #patch(path, body = {}) ⇒ Object
- #post(path, body = {}) ⇒ Object
- #put(path, body = {}) ⇒ Object
Constructor Details
Instance Method Details
#delete(path) ⇒ Object
39 40 41 |
# File 'lib/email_octopus/api.rb', line 39 def delete(path) Response.new @http.delete("#{path}?api_key=#{@api_key}", HEADERS) end |
#get(path) ⇒ Object
20 21 22 |
# File 'lib/email_octopus/api.rb', line 20 def get(path) Response.new @http.get("#{path}?api_key=#{@api_key}", HEADERS) end |
#patch(path, body = {}) ⇒ Object
29 30 31 32 |
# File 'lib/email_octopus/api.rb', line 29 def patch(path, body = {}) body['api_key'] = @api_key Response.new @http.patch(path, body.to_json, HEADERS) end |