class OFX::Data::Banking::Transaction

Constants

FIELDS
VALID_TYPES

Attributes

fitid[R]

Public Class Methods

new(opts) click to toggle source
# File lib/ofx/data/banking/transaction.rb, line 26
def initialize(opts)
  @type = opts.fetch(:type)
  raise ArgumentError, ":type must be one of #{VALID_TYPES.inspect}, was #{@type}" if !VALID_TYPES.include?(@type)
  @date_posted = opts.fetch(:date_posted)
  @amount = BigDecimal.new(opts.fetch(:amount))
  @fitid = opts.fetch(:fitid)
  @bank_account_to = opts.fetch(:bank_account_to, nil)
  @name = opts.fetch(:name, nil)
  raise ArgumentError, ":name must be 1-32 characters long" if @name && @name.length > 32
  @refnum = opts.fetch(:refnum, nil)
  raise ArgumentError, ":refnum must be 1-32 characters long" if @refnum && @refnum.length > 32
  @payee_id = opts.fetch(:payee_id, nil)
  raise ArgumentError, ":payee_id must be 1-12 characters long" if @payee_id && @payee_id.length > 12
  @memo = opts.fetch(:memo, nil)
  raise ArgumentError, ":memo must be 1-255 characters long" if @memo && @memo.length > 255
end
with_synthetic_fitid(opts) click to toggle source
# File lib/ofx/data/banking/transaction.rb, line 14
def self.with_synthetic_fitid(opts)
  input = FIELDS.map { |key|
    opts.fetch(key, "")
  }.map { |value|
    value.respond_to?(:fitid_str) ? value.fitid_str : value.to_s
  }.join("")
  fitid = Digest::SHA1.hexdigest(input)
  new(opts.merge(fitid: fitid))
end

Public Instance Methods

ofx_type() click to toggle source
# File lib/ofx/data/banking/transaction.rb, line 43
def ofx_type
  :"banking.statement_transaction"
end