lib/afterbanks_psd2/resources/transaction.rb in afterbanks-psd2-api-ruby-0.1.0 vs lib/afterbanks_psd2/resources/transaction.rb in afterbanks-psd2-api-ruby-0.1.1

- old
+ new

@@ -8,17 +8,25 @@ transaction_id: { type: :string, original_name: :transactionId }, category_id: { type: :integer, original_name: :categoryId }, account: { type: :afterbankspsd2_account } def self.list(token:, products:, start_date:) + raise ArgumentError, "Token is missing" if token.nil? || token.empty? + raise ArgumentError, "Products must be a string" unless products.is_a?(String) + raise ArgumentError, "Products is missing" if products.nil? || products.empty? + raise ArgumentError, "Start date is missing" if start_date.nil? || products.empty? + raise ArgumentError, "Start date must be a Date" unless start_date.is_a?(Date) + params = { servicekey: AfterbanksPSD2.configuration.servicekey, token: token, products: products, startDate: start_date.strftime("%d-%m-%Y") } + options = {} + # if the start_date is older than 90 days, we need to increase timeout to 2 hours if start_date < Date.today << 3 options = { timeout: 7200 } @@ -44,10 +52,10 @@ ) end def self.transactions_information_for(response:, products:) transactions_information = [] - products_array = products.split(",") + products_array = products.to_s.split(",").map(&:strip) response.each do |account_information| product = account_information['product'] next unless products_array.include?(product)