Class: Quickmail::Authentication

Inherits:
Object
  • Object
show all
Defined in:
lib/quickmail/authentication.rb

Class Method Summary collapse

Class Method Details

.oauth(payload = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/quickmail/authentication.rb', line 7

def oauth(payload = {})
  RestClient::Request.new({
      method: :post,
      url: Quickmail.api_base + '/token',
      payload: payload,
      headers: {content_type: "application/x-www-form-urlencoded"}
    }).execute do |response, request, result|
    if response.code != 200
      raise ApiRequestError.new(
        response_code: response.code,
        response_headers: response.headers,
        response_body: response.to_str
      )
    end
    response
  end
end