Class: Belvo::Transaction
Overview
A Transaction contains the detailed information of each movement inside an Account.
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#initialize(session) ⇒ Transaction
constructor
A new instance of Transaction.
-
#list(params: nil) {|Hash| ... } ⇒ Array
List all transactions for specific link id.
-
#retrieve(link:, date_from:, options: nil) ⇒ Hash
Retrieve transactions from an existing link.
Methods inherited from Resource
#clean, #delete, #detail, #resume
Constructor Details
#initialize(session) ⇒ Transaction
Returns a new instance of Transaction.
177 178 179 180 |
# File 'lib/belvo/resources.rb', line 177 def initialize(session) super(session) @endpoint = 'api/transactions/' end |
Instance Method Details
#list(params: nil) {|Hash| ... } ⇒ Array
List all transactions for specific link id
188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/belvo/resources.rb', line 188 def list(params: nil) params = {} if params.nil? unless params.key?(:link) raise RequestError.new( 'Link id required', 400, 'A link ID is required to list transactions' ) end @session.list(@endpoint, params: params) end |
#retrieve(link:, date_from:, options: nil) ⇒ Hash
Retrieve transactions from an existing link
206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/belvo/resources.rb', line 206 def retrieve(link:, date_from:, options: nil) = TransactionOptions.from() date_to = .date_to || Date.today.to_s body = { link: link, date_from: date_from, date_to: date_to, token: .token, account: .account, save_data: .save_data || true }.merge() body = clean body: body @session.post(@endpoint, body) end |