module Smtpcom::Sendapi::Request::ClassMethods

Attributes

response[R]

Public Instance Methods

_auth_key() click to toggle source
# File lib/smtpcom/sendapi/request.rb, line 51
def _auth_key
  { apiKey: Smtpcom::Sendapi.api_key }
end
_get(path, params = {}, formatted = false) click to toggle source
# File lib/smtpcom/sendapi/request.rb, line 9
def _get(path, params = {}, formatted = false)
  @response = HTTParty.get \
    _url(path),
    headers: _json_headers,
    query: params.merge(_auth_key),
    format: :json
  if formatted
    Utils.format_response_row @response.parsed_response
  else
    @response.parsed_response
  end
end
_get_raw(path, params = {}) click to toggle source
# File lib/smtpcom/sendapi/request.rb, line 22
def _get_raw(path, params = {})
  @response = HTTParty.get \
    _url(path),
    headers: (params.delete(:headers) || _json_headers),
    query: params.merge(_auth_key)
  @response.body
end
_json_headers() click to toggle source
# File lib/smtpcom/sendapi/request.rb, line 47
def _json_headers
  { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
end
_post(path, params = {}, formatted = false) click to toggle source
# File lib/smtpcom/sendapi/request.rb, line 30
def _post(path, params = {}, formatted = false)
  @response = HTTParty.post \
    _url(path),
    headers: _json_headers,
    body: params.merge(_auth_key).to_json,
    format: :json
  if formatted
    Utils.format_response_row @response.parsed_response
  else
    @response.parsed_response
  end
end
_url(path) click to toggle source
# File lib/smtpcom/sendapi/request.rb, line 43
def _url(path)
  File.join Smtpcom::Sendapi.api_host, Smtpcom::Sendapi.api_base, path
end