class Mailstro::Resource

Private Instance Methods

connection() click to toggle source
# File lib/mailstro/resource.rb, line 33
def connection
  @connection ||= Faraday.new(:url => Mailstro.configuration.api_endpoint) do |faraday|
    faraday.use Mailstro::Middleware::Response::RaiseError

    faraday.request :url_encoded
    faraday.request :json

    faraday.response :mashify
    faraday.response :json

    faraday.adapter Faraday.default_adapter
  end
end
delete(path, body = {}) click to toggle source
# File lib/mailstro/resource.rb, line 24
def delete(path, body = {})
  connection.delete(path) do |request|
    request.headers = {
      'Content-Type' => 'application/json'
    }
    request.body = params(body)
  end.body
end
params(params) click to toggle source
# File lib/mailstro/resource.rb, line 11
def params(params)
  params.merge(:api_key => Mailstro.configuration.api_key)
end
post(path, body = {}) click to toggle source
# File lib/mailstro/resource.rb, line 15
def post(path, body = {})
  connection.post(path) do |request|
    request.headers = {
      'Content-Type' => 'application/json'
    }
    request.body = params(body)
  end.body
end