Class: Belvo::Resource
- Inherits:
-
Object
- Object
- Belvo::Resource
- Defined in:
- lib/belvo/resources.rb
Overview
Represents a consumable REST resource from Belvo API
Direct Known Subclasses
Account, Balance, EmploymentRecords, Income, Institution, InvestmentsPortfolio, Invoice, Link, Owner, RecurringExpenses, RiskInsights, Statement, TaxComplianceStatus, TaxDeclaration, TaxRetentions, TaxReturn, TaxStatus, Transaction, WidgetToken
Instance Attribute Summary collapse
-
#endpoint ⇒ String
readonly
Resource API endpoint.
Instance Method Summary collapse
-
#clean(body:) ⇒ Hash
Remove nil values from a request body.
-
#delete(id:) ⇒ Boolean
Delete existing resource.
-
#detail(id:) ⇒ Hash
Show specific resource details.
-
#initialize(session) ⇒ Resource
constructor
A new instance of Resource.
-
#list(params: nil) {|Hash| ... } ⇒ Array
List all results.
-
#resume(session_id:, token:, link: nil) ⇒ Object
Resume data extraction session.
Constructor Details
#initialize(session) ⇒ Resource
Returns a new instance of Resource.
15 16 17 |
# File 'lib/belvo/resources.rb', line 15 def initialize(session) @session = session end |
Instance Attribute Details
#endpoint ⇒ String (readonly)
Resource API endpoint
12 13 14 |
# File 'lib/belvo/resources.rb', line 12 def endpoint @endpoint end |
Instance Method Details
#clean(body:) ⇒ Hash
Remove nil values from a request body
22 23 24 |
# File 'lib/belvo/resources.rb', line 22 def clean(body:) body.delete_if { |_key, value| value.nil? } end |
#delete(id:) ⇒ Boolean
Delete existing resource
46 47 48 |
# File 'lib/belvo/resources.rb', line 46 def delete(id:) @session.delete(@endpoint, id) end |
#detail(id:) ⇒ Hash
Show specific resource details
39 40 41 |
# File 'lib/belvo/resources.rb', line 39 def detail(id:) @session.detail(@endpoint, id) end |
#list(params: nil) {|Hash| ... } ⇒ Array
List all results
31 32 33 |
# File 'lib/belvo/resources.rb', line 31 def list(params: nil) @session.list(@endpoint, params: params) end |
#resume(session_id:, token:, link: nil) ⇒ Object
Resume data extraction session. Use this method after you have received a
HTTP 428 response.
55 56 57 58 |
# File 'lib/belvo/resources.rb', line 55 def resume(session_id:, token:, link: nil) data = { session: session_id, token: token, link: link } @session.patch(@endpoint, data) end |