Class: OFX::FinancialClient

Inherits:
Object
  • Object
show all
Defined in:
lib/ofx/financial_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(financial_institutions_and_credentials) ⇒ FinancialClient

Returns a new instance of FinancialClient.



28
29
30
# File 'lib/ofx/financial_client.rb', line 28

def initialize(financial_institutions_and_credentials)
    @financial_institutions_and_credentials = financial_institutions_and_credentials
end

Instance Attribute Details

#client_unique_identifierObject

Returns the value of attribute client_unique_identifier.



26
27
28
# File 'lib/ofx/financial_client.rb', line 26

def client_unique_identifier
  @client_unique_identifier
end

#date_of_last_profile_updateObject

Returns the value of attribute date_of_last_profile_update.



25
26
27
# File 'lib/ofx/financial_client.rb', line 25

def date_of_last_profile_update
  @date_of_last_profile_update
end

Instance Method Details

#application_identification(ofx_client_spoof = nil) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ofx/financial_client.rb', line 45

def application_identification(ofx_client_spoof=nil)
    # Reference: http://wiki.mthbuilt.com/Tweaking_OFX_Connections
    case ofx_client_spoof
    when 'Money'
        OFX::ApplicationIdentification.new('Money', '1600')
    when 'Quicken'
        OFX::ApplicationIdentification.new('QWIN', '1700')
    when 'QuickBooks'
        OFX::ApplicationIdentification.new('QBW', '1800')
    else
        OFX::ApplicationIdentification.new('OFX', '0010')
    end
end

#create_profile_update_request_messageObject



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/ofx/financial_client.rb', line 76

def create_profile_update_request_message()
    profileMessageSet = OFX::FinancialInstitutionProfileMessageSet.new
    
    profileRequest = OFX::FinancialInstitutionProfileRequest.new
    profileRequest.transaction_identifier = OFX::TransactionUniqueIdentifier.new
    profileRequest.client_routing = 'MSGSET'
    profileRequest.date_of_last_profile_update = self.date_of_last_profile_update
    profileMessageSet.requests << profileRequest
    
    profileMessageSet
end

#create_signon_request_message(financial_institution_id, ofx_client_id = nil) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/ofx/financial_client.rb', line 59

def create_signon_request_message(financial_institution_id, ofx_client_id=nil)
    signonMessageSet = OFX::SignonMessageSet.new

    signonRequest = OFX::SignonRequest.new
    signonRequest.date = DateTime.now
    signonRequest.user_identification = self.user_identification_for(financial_institution_id)
    signonRequest.generate_user_key = false
    signonRequest.language = "ENG"
    signonRequest.financial_institution_identification = self.financial_institution_identification_for(financial_institution_id)
    signonRequest.session_cookie = nil
    signonRequest.application_identification = self.application_identification(ofx_client_id)
    signonRequest.client_unique_identifier = self.client_unique_identifier
    signonMessageSet.requests << signonRequest

    signonMessageSet
end

#financial_institution_identification_for(financial_institution_id) ⇒ Object



32
33
34
35
36
37
# File 'lib/ofx/financial_client.rb', line 32

def financial_institution_identification_for(financial_institution_id)
    @financial_institutions_and_credentials.each do |pair|
        return pair[0] if (pair[0].financial_institution_identifier == financial_institution_id)
    end
    return nil
end

#user_identification_for(financial_institution_id) ⇒ Object



38
39
40
41
42
43
# File 'lib/ofx/financial_client.rb', line 38

def user_identification_for(financial_institution_id)
    @financial_institutions_and_credentials.each do |pair|
        return pair[1] if (pair[0].financial_institution_identifier == financial_institution_id)
    end
    return nil
end