Class: A55::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/a55/client.rb,
lib/a55/client/bank_slip.rb,
lib/a55/client/instruction.rb

Defined Under Namespace

Classes: BankSlip, Instruction

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account_id = nil, options = {}) ⇒ Client

Returns a new instance of Client.



11
12
13
14
15
16
17
# File 'lib/a55/client.rb', line 11

def initialize( = nil, options = {})
  @token = options[:token] || A55.authenticate
  @account_id =  || A55. || 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

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



10
11
12
# File 'lib/a55/client.rb', line 10

def 
  @account_id
end

Instance Method Details

#bank_slipObject



28
29
30
# File 'lib/a55/client.rb', line 28

def bank_slip
  @bank_slip_client ||= BankSlip.new(self)
end

#get(path, options = {}) ⇒ Object



32
33
34
# File 'lib/a55/client.rb', line 32

def get(path, options  = {})
  self.class.get(path, options)
end

#instructionsObject



24
25
26
# File 'lib/a55/client.rb', line 24

def instructions
  @instruction_client ||= Instruction.new(self)
end

#perform_request(path) ⇒ Object



19
20
21
22
# File 'lib/a55/client.rb', line 19

def perform_request(path)
  response = self.class.get(path)
  response
end

#post(path, options = {}) ⇒ Object



36
37
38
# 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 = {}) ⇒ Object



40
41
42
# File 'lib/a55/client.rb', line 40

def put(path, options = {})
  self.class.put(path, body: options.to_json, headers: default_headers)
end