class CoinSync::Importers::Changelly

Public Instance Methods

read_transaction_list(source) click to toggle source
# File lib/coinsync/importers/changelly.rb, line 31
def read_transaction_list(source)
  csv = CSV.new(source, col_sep: ',')

  transactions = []

  csv.each do |line|
    next if line[0] == 'Status'

    entry = HistoryEntry.new(line)

    next if entry.status != 'finished'

    transactions << Transaction.new(
      exchange: 'Changelly',
      time: entry.date,
      bought_amount: entry.received_amount,
      bought_currency: entry.received_currency,
      sold_amount: entry.exchanged_amount,
      sold_currency: entry.exchanged_currency
    )
  end

  transactions.reverse
end