class A55::Client

Attributes

account_id[R]

Public Class Methods

new(account_id = nil, options = {}) click to toggle source
# File lib/a55/client.rb, line 11
def initialize(account_id = nil, options = {})
  @token = options[:token] || A55.authenticate
  @account_id = account_id || A55.account_id || ENV['A55_ACCOUNT_ID']
  raise A55::MissingTokenError unless @token
  self.class.base_uri A55.api_url
  self.class.default_options.merge!(headers: { 'Authorization' => "Token #{@token}", 'Content-Type' => 'application/json'}, verify: A55.production? )
end

Public Instance Methods

bank_slip() click to toggle source
# File lib/a55/client.rb, line 28
def bank_slip
  @bank_slip_client ||= BankSlip.new(self)
end
get(path, options = {}) click to toggle source
# File lib/a55/client.rb, line 32
def get(path, options  = {})
  self.class.get(path, options)
end
instructions() click to toggle source
# File lib/a55/client.rb, line 24
def instructions
  @instruction_client ||= Instruction.new(self)
end
perform_request(path) click to toggle source
# File lib/a55/client.rb, line 19
def perform_request(path)
  response = self.class.get(path)
  response
end
post(path, options = {}) click to toggle source
# File lib/a55/client.rb, line 36
def post(path, options = {})
  self.class.post(path, body: options.to_json, headers: default_headers)
end
put(path, options = {}) click to toggle source
# File lib/a55/client.rb, line 40
def put(path, options = {})
  self.class.put(path, body: options.to_json, headers: default_headers)
end

Private Instance Methods

default_headers() click to toggle source
# File lib/a55/client.rb, line 45
def default_headers
  { 'Content-Type' => 'application/json' }
end