Class: Belvo::Client

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

Overview

Allows easy access to Belvo API servers.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(secret_key_id, secret_key_password, url = nil) ⇒ APISession

Returns Authenticated Belvo API session.

Parameters:

  • secret_key_id (String)
  • secret_key_password (String)
  • url (String, nil) (defaults to: nil)

    API host URL, can be set from the environment using the variable name BELVO_API_URL

Raises:



19
20
21
22
23
24
25
26
27
28
# File 'lib/belvo.rb', line 19

def initialize(secret_key_id, secret_key_password, url = nil)
  (belvo_api_url = url) || ENV['BELVO_API_URL']
  raise BelvoAPIError, 'You need to provide a URL.' if belvo_api_url.nil?

  @session = Belvo::APISession.new(belvo_api_url)

  return if @session.(secret_key_id, secret_key_password)

  raise BelvoAPIError, 'Login failed.'
end

Instance Attribute Details

#sessionAPISession (readonly)

Current Belvo API session

Returns:



12
13
14
# File 'lib/belvo.rb', line 12

def session
  @session
end

Instance Method Details

#accountsAccount

Provides access to Accounts resource

Returns:



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

def accounts
  @accounts = Account.new @session
end

#balancesBalance

Provides access to Balances resource

Returns:



56
57
58
# File 'lib/belvo.rb', line 56

def balances
  @balances = Balance.new @session
end

#institutionsInstitution

Provides access to Instituions resource

Returns:



86
87
88
# File 'lib/belvo.rb', line 86

def institutions
  @institutions = Institution.new @session
end

#invoicesInvoice

Provides access to Invoices resource

Returns:



68
69
70
# File 'lib/belvo.rb', line 68

def invoices
  @invoices = Invoice.new @session
end

Provides access to Links resource

Returns:



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

def links
  @links = Link.new @session
end

#ownersOwner

Provides access to Owners resource

Returns:



50
51
52
# File 'lib/belvo.rb', line 50

def owners
  @owners = Owner.new @session
end

#statementsStatement

Provides access to Statements resource

Returns:



62
63
64
# File 'lib/belvo.rb', line 62

def statements
  @statements = Statement.new @session
end

#tax_returnsTaxReturn

Provides access to TaxReturns resource

Returns:



74
75
76
# File 'lib/belvo.rb', line 74

def tax_returns
  @tax_returns = TaxReturn.new @session
end

#tax_statusTaxStatus

Provides access to TaxStatus resource

Returns:



80
81
82
# File 'lib/belvo.rb', line 80

def tax_status
  @tax_status = TaxStatus.new @session
end

#transactionsTransaction

Provides access to Transactions resource

Returns:



44
45
46
# File 'lib/belvo.rb', line 44

def transactions
  @transactions = Transaction.new @session
end

#widget_tokenWidgetToken

Provides access to WidgetToken resource

Returns:



92
93
94
# File 'lib/belvo.rb', line 92

def widget_token
  @widget_token = WidgetToken.new @session
end