Class: Cobrato::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/cobrato/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Client

Returns a new instance of Client.



5
6
7
# File 'lib/cobrato/client.rb', line 5

def initialize(token)
  @http = Http.new(token)
end

Instance Attribute Details

#httpObject (readonly)

Returns the value of attribute http.



3
4
5
# File 'lib/cobrato/client.rb', line 3

def http
  @http
end

Instance Method Details

#authenticated?Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
# File 'lib/cobrato/client.rb', line 9

def authenticated?
  http.get("") do |response|
    response.code == 200
  end
rescue RequestError => e
  raise e unless e.code == 401
  false
end

#bank_accountsObject



22
23
24
# File 'lib/cobrato/client.rb', line 22

def bank_accounts
  Resources::BankAccount.new(http)
end

#charge_accountsObject



26
27
28
# File 'lib/cobrato/client.rb', line 26

def charge_accounts
  Resources::ChargeAccount.new(http)
end

#chargesObject



30
31
32
# File 'lib/cobrato/client.rb', line 30

def charges
  Resources::Charge.new(http)
end

#charging_typesObject



38
39
40
# File 'lib/cobrato/client.rb', line 38

def charging_types
  Resources::ChargingType.new(http)
end

#payeesObject



18
19
20
# File 'lib/cobrato/client.rb', line 18

def payees
  Resources::Payee.new(http)
end

#webhooksObject



34
35
36
# File 'lib/cobrato/client.rb', line 34

def webhooks
  Resources::Webhook.new(http)
end