class OFX::Document

Attributes

uri[R]

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method OFX::Aggregate::new
# File lib/ofx/document.rb, line 7
def initialize(options = {})
  @start = options[:start] || (Date.today - 30)
  @end = options[:end] || Date.today
  @uri = options[:uri]
  @user = options[:user]
  @password = options[:password]
  @routing = options[:routing]
  @account = options[:account]
  @fi_org = options[:fi_org]
  @fi_fid = options[:fi_fid]
  @app_id = options[:app_id]
  @app_ver = options[:app_ver]
  super
end

Public Instance Methods

bank() click to toggle source
# File lib/ofx/document.rb, line 35
def bank
  BankMessageSet.new(
    name: :bankmsgsrqv1,
    routing: routing,
    account: account,
    id: trnuid,
    start: @start,
    end: @end
  )
end
signon() click to toggle source
# File lib/ofx/document.rb, line 22
def signon
  SignonMessageSet.new(
    name: :signonmsgsrqv1,
    time: Time.now.strftime('%Y%m%d%H%M%S'),
    user: user,
    password: password,
    fi_org: fi_org,
    fi_fid: fi_fid,
    app_id: app_id,
    app_ver: app_ver
  )
end

Protected Instance Methods

account() click to toggle source
# File lib/ofx/document.rb, line 76
def account
  @account || ENV['OFX_ACCOUNT'] || (raise Errors::AccountMissing)
end
app_id() click to toggle source
# File lib/ofx/document.rb, line 80
def app_id
  @app_id || ENV['OFX_APP_ID'] || (raise Errors::AppIdMissing)
end
app_ver() click to toggle source
# File lib/ofx/document.rb, line 84
def app_ver
  @app_ver || ENV['OFX_APP_VER'] || (raise Errors::AppVerMissing)
end
body() click to toggle source
# File lib/ofx/document.rb, line 112
def body
  [ofx_header, element_group].join
end
dtclient() click to toggle source
# File lib/ofx/document.rb, line 48
def dtclient
  Time.now.strftime('%Y%m%d%H%M%S')
end
fi_fid() click to toggle source
# File lib/ofx/document.rb, line 68
def fi_fid
  @fi_fid || ENV['OFX_FI_FID'] || (raise Errors::FiFidMissing)
end
fi_org() click to toggle source
# File lib/ofx/document.rb, line 64
def fi_org
  @fi_org || ENV['OFX_FI_ORG'] || (raise Errors::FiOrgMissing)
end
http() click to toggle source
# File lib/ofx/document.rb, line 92
def http
  @http ||= HTTP.new(uri: @uri)
end
ofx_header() click to toggle source
# File lib/ofx/document.rb, line 96
def ofx_header
  {
    ofxheader: 100,
    data: 'OFXSGML',
    version: 103,
    security: 'NONE',
    encoding: 'UNICODE',
    charset: 1252,
    compression: 'NONE',
    oldfileuid: 'NONE',
    newfileuid: 'NONE'
  }.inject('') do |result, values|
    result.dup << "#{values[0].upcase}:#{values[1]}\n"
  end
end
password() click to toggle source
# File lib/ofx/document.rb, line 60
def password
  @password || ENV['OFX_PASSWORD'] || (raise Errors::PasswordMissing)
end
routing() click to toggle source
# File lib/ofx/document.rb, line 72
def routing
  @routing || ENV['OFX_ROUTING'] || (raise Errors::RoutingMissing)
end
trnuid() click to toggle source
# File lib/ofx/document.rb, line 52
def trnuid
  Time.now.to_i.to_s
end
user() click to toggle source
# File lib/ofx/document.rb, line 56
def user
  @user || ENV['OFX_USER'] || (raise Errors::UserMissing)
end