Skip to content

Instantly share code, notes, and snippets.

@denisoster
Created August 9, 2019 13:39
Show Gist options
  • Select an option

  • Save denisoster/3739d05be4bb919bf4d5cf45a1d4cdea to your computer and use it in GitHub Desktop.

Select an option

Save denisoster/3739d05be4bb919bf4d5cf45a1d4cdea to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
require 'active_support/time'
require 'ap'
require 'privatbank'
require 'privatbank/p24'
merchant_id = 'merchant_id'
merchant_password = 'merchant_password'
card_number = 'card_number'
Privatbank.configure do |config|
config.merchant_id = merchant_id
config.merchant_password = merchant_password
end
from_date = DateTime.new(2019, 1, 1)
till_date = Date.today
responses = []
(from_date.month..till_date.month).map do |i|
new_from_date = from_date.change(month: i)
new_till_date = new_from_date.end_of_month
puts "Receive transactions for #{Date::MONTHNAMES[new_from_date.month]}"
response = Privatbank::P24.account_statement(card_number,
from_date: new_from_date,
till_date: new_till_date)
responses.unshift(response)
end
ap responses.flatten
puts "Count transaction: #{responses.count}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment