Class: AfterbanksPSD2::Transaction
- Defined in:
- lib/afterbanks_psd2/resources/transaction.rb
Class Method Summary collapse
- .list(token:, products:, start_date:) ⇒ Object
- .transactions_information_for(response:, products:) ⇒ Object
Methods inherited from Resource
fields_information, #fields_information, has_fields, #initialize
Constructor Details
This class inherits a constructor from AfterbanksPSD2::Resource
Class Method Details
.list(token:, products:, start_date:) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/afterbanks_psd2/resources/transaction.rb', line 12 def self.list(token:, products:, start_date:) params = { servicekey: AfterbanksPSD2.configuration.servicekey, token: token, products: products, startDate: start_date.strftime("%d-%m-%Y") } # if the start_date is older than 90 days, we need to increase timeout to 2 hours if start_date < Date.today << 3 = { timeout: 7200 } end response, debug_id = AfterbanksPSD2.api_call( method: :post, path: '/transactions/', params: params, options: ) Response.new( result: Collection.new( transactions_information_for( response: response, products: products ), self ), body: response, debug_id: debug_id ) end |
.transactions_information_for(response:, products:) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/afterbanks_psd2/resources/transaction.rb', line 47 def self.transactions_information_for(response:, products:) transactions_information = [] products_array = products.split(",") response.each do |account_information| product = account_information['product'] next unless products_array.include?(product) transactions = account_information['transactions'] next if transactions.nil? || transactions.empty? account = AfterbanksPSD2::Account.new(account_information) transactions.each do |transaction| transaction['account'] = account end transactions_information += transactions end transactions_information end |