class SendpulseClient::Connection

Constants

Token

Public Class Methods

delete_request(path, body = {}) click to toggle source
# File lib/sendpulse_client/connection.rb, line 54
def delete_request(path, body = {})
  body = {
    body: data,
    headers: auth_headers
  }

  delete(path, body).parsed_response
end
get_request(path, data = {}) click to toggle source
# File lib/sendpulse_client/connection.rb, line 36
def get_request(path, data = {})
  params = {
    query: data,
    headers: auth_headers
  }

  get(path, params).parsed_response
end
post_request(path, data = {}) click to toggle source
# File lib/sendpulse_client/connection.rb, line 45
def post_request(path, data = {})
  body = {
    body: data,
    headers: auth_headers
  }

  post(path, body).parsed_response
end

Private Class Methods

auth_headers() click to toggle source
# File lib/sendpulse_client/connection.rb, line 65
def auth_headers
  { 'Authorization' => token.to_s }
end
token() click to toggle source
# File lib/sendpulse_client/connection.rb, line 69
def token
  if @token && @token.valid?
    @token
  else
    @token = Token.new
    @token.set!
    @token
  end
end