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:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/belvo.rb', line 20

def initialize(secret_key_id, secret_key_password, url = nil)
  (belvo_api_url = url) || ENV['BELVO_API_URL']
  belvo_api_url = Environment.get_url(belvo_api_url)

  if belvo_api_url.nil?
    raise BelvoAPIError, 'You need to provide a URL or a valid environment.'
  end

  @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:



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

def session
  @session
end

Instance Method Details

#accountsAccount

Provides access to Accounts resource

Returns:



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

def accounts
  @accounts = Account.new @session
end

#balancesBalance

Provides access to Balances resource

Returns:



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

def balances
  @balances = Balance.new @session
end

#employment_recordsEmploymentRecords

Provides access to EmploymentRecords resource

Returns:



145
146
147
# File 'lib/belvo.rb', line 145

def employment_records
  @employment_records = EmploymentRecords.new @session
end

#incomesIncome

Provides access to Incomes resource

Returns:



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

def incomes
  @incomes = Income.new @session
end

#institutionsInstitution

Provides access to the Institutions resource

Returns:



127
128
129
# File 'lib/belvo.rb', line 127

def institutions
  @institutions = Institution.new @session
end

#investments_portfolioInvestmentsPortfolio

Provides access to InvestmentsPortfolio resource



139
140
141
# File 'lib/belvo.rb', line 139

def investments_portfolio
  @investments_portfolio = InvestmentsPortfolio.new @session
end

#invoicesInvoice

Provides access to Invoices resource

Returns:



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

def invoices
  @invoices = Invoice.new @session
end

Provides access to Links resource

Returns:



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

def links
  @links = Link.new @session
end

#ownersOwner

Provides access to Owners resource

Returns:



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

def owners
  @owners = Owner.new @session
end

#recurring_expensesRecurringExpense

Provides access to RecurringExpenses resource

Returns:

  • (RecurringExpense)


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

def recurring_expenses
  @recurring_expenses = RecurringExpenses.new @session
end

#risk_insightsRiskInsights

Provides access to RiskInsights resource

Returns:



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

def risk_insights
  @risk_insights = RiskInsights.new @session
end

#statementsStatement

Provides access to Statements resource

Returns:



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

def statements
  @statements = Statement.new @session
end

#tax_compliance_statusTaxComplianceStatus

Provides access to TaxComplianceStatus resource

Returns:



97
98
99
# File 'lib/belvo.rb', line 97

def tax_compliance_status
  @tax_compliance_status = TaxComplianceStatus.new @session
end

#tax_declarationsTaxDeclaration

Provides access to TaxDeclarations resource

Returns:



109
110
111
# File 'lib/belvo.rb', line 109

def tax_declarations
  @tax_declarations = TaxDeclaration.new @session
end

#tax_retentionsTaxRetentions

Provides access to the TaxRetentions resource

Returns:



121
122
123
# File 'lib/belvo.rb', line 121

def tax_retentions
  @tax_retentions = TaxRetentions.new @session
end

#tax_returnsTaxReturn

Provides access to TaxReturns resource

Returns:



103
104
105
# File 'lib/belvo.rb', line 103

def tax_returns
  @tax_returns = TaxReturn.new @session
end

#tax_statusTaxStatus

Provides access to TaxStatus resource

Returns:



115
116
117
# File 'lib/belvo.rb', line 115

def tax_status
  @tax_status = TaxStatus.new @session
end

#transactionsTransaction

Provides access to Transactions resource

Returns:



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

def transactions
  @transactions = Transaction.new @session
end

#widget_tokenWidgetToken

Provides access to WidgetToken resource

Returns:



133
134
135
# File 'lib/belvo.rb', line 133

def widget_token
  @widget_token = WidgetToken.new @session
end