Class: OFX::CreditCardStatementResponse

Inherits:
TransactionalResponse show all
Defined in:
lib/ofx/credit_card_statement_message_set.rb,
lib/ofx/1.0.2/credit_card_statement_message_set.rb

Instance Attribute Summary collapse

Attributes inherited from TransactionalResponse

#client_cookie, #transaction_identifier

Attributes inherited from Response

#status

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TransactionalResponse

#to_ofx_102_s

Methods inherited from Response

#to_ofx_102_s

Instance Attribute Details

#accountObject

Returns the value of attribute account.



61
62
63
# File 'lib/ofx/credit_card_statement_message_set.rb', line 61

def 
  @account
end

#available_balanceObject

Returns the value of attribute available_balance.



65
66
67
# File 'lib/ofx/credit_card_statement_message_set.rb', line 65

def available_balance
  @available_balance
end

#default_currencyObject

Returns the value of attribute default_currency.



60
61
62
# File 'lib/ofx/credit_card_statement_message_set.rb', line 60

def default_currency
  @default_currency
end

#ledger_balanceObject

Returns the value of attribute ledger_balance.



64
65
66
# File 'lib/ofx/credit_card_statement_message_set.rb', line 64

def ledger_balance
  @ledger_balance
end

#marketing_informationObject

Returns the value of attribute marketing_information.



62
63
64
# File 'lib/ofx/credit_card_statement_message_set.rb', line 62

def marketing_information
  @marketing_information
end

#transaction_rangeObject

Returns the value of attribute transaction_range.



67
68
69
# File 'lib/ofx/credit_card_statement_message_set.rb', line 67

def transaction_range
  @transaction_range
end

#transactionsObject

Returns the value of attribute transactions.



68
69
70
# File 'lib/ofx/credit_card_statement_message_set.rb', line 68

def transactions
  @transactions
end

Class Method Details

.from_ofx_102_hash(transaction_hash) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/ofx/1.0.2/credit_card_statement_message_set.rb', line 117

def self.from_ofx_102_hash(transaction_hash)
    response = CreditCardStatementResponse.new
               
    response.transaction_identifier = transaction_hash['TRNUID']
    response.status = OFX::Status.from_ofx_102_hash(transaction_hash['STATUS'])
    
    response_hash = transaction_hash['CCSTMTRS']
    return unless response_hash
    
    response.default_currency = response_hash['CURDEF']
    response. = CreditCardAccount.from_ofx_102_hash(response_hash['CCACCTFROM'])
    
    response.marketing_information = response_hash['MKTGINFO']

    response.ledger_balance = Balance.from_ofx_102_hash(response_hash['LEDGERBAL']) if response_hash['LEDGERBAL']
    response.available_balance = Balance.from_ofx_102_hash(response_hash['AVAILBAL']) if response_hash['AVAILBAL']
    
    transaction_list_hash = response_hash['BANKTRANLIST']
    if (transaction_list_hash)
        if transaction_list_hash['DTSTART'] && transaction_list_hash['DTEND']
            response.transaction_range = transaction_list_hash['DTSTART'].to_datetime..transaction_list_hash['DTEND'].to_datetime
        end
        
        response.transactions = []
        transactions = transaction_list_hash['STMTTRN'] if transaction_list_hash['STMTTRN'].kind_of?(Array)
        transactions = [transaction_list_hash['STMTTRN']] if transaction_list_hash['STMTTRN'].kind_of?(Hash)
        transactions = [] unless transactions
        
        transactions.each do |transaction_hash|
            transaction = Transaction.new
            
            transaction.transaction_type = Transaction.ofx_102_transaction_type_name_to_transaction_type(transaction_hash['TRNTYPE'])
            transaction.date_posted = transaction_hash['DTPOSTED'].to_datetime if transaction_hash['DTPOSTED']
            transaction.date_initiated = transaction_hash['DTUSER'].to_datetime if transaction_hash['DTUSER']
            transaction.date_available = transaction_hash['DTAVAIL'].to_datetime if transaction_hash['DTAVAIL']

            transaction.amount = transaction_hash['TRNAMT'].to_d if transaction_hash['TRNAMT']
            transaction.currency = transaction_hash['CURRENCY'] || transaction_hash['ORIGCURRENCY'] || response.default_currency

            transaction.financial_institution_transaction_identifier = transaction_hash['FITID']
            transaction.corrected_financial_institution_transaction_identifier = transaction_hash['CORRECTFITID']
            transaction.correction_action = case transaction_hash['CORRECT_ACTION']
                                                when 'REPLACE' then :replace
                                                when 'DELETE'  then :delete
                                            end if transaction_hash['CORRECT_ACTION']
            transaction.server_transaction_identifier = transaction_hash['SRVRTID']
            transaction.check_number = transaction_hash['CHECKNUM']
            transaction.reference_number = transaction_hash['REFNUM']
                    
            transaction.standard_industrial_code = transaction_hash['SIC']
            
            transaction.payee_identifier = transaction_hash['PAYEEID']
            if transaction_hash['PAYEE']
                raise NotImplementedError
            else
                transaction.payee = transaction_hash['NAME']
            end
            
            if (transaction_hash['BANKACCTTO'])
                transaction. = BankingAccount.from_ofx_102_hash(transaction_hash['BANKACCTTO'])
            elsif (transaction_hash['CCACCTTO'])
                transaction. = CreditCardAccount.from_ofx_102_hash(transaction_hash['CCACCTTO'])
            end
            
            transaction.memo = transaction_hash['MEMO']
            
            response.transactions << transaction
        end
    end
    
    response
end

Instance Method Details

#ofx_102_nameObject



109
110
111
# File 'lib/ofx/1.0.2/credit_card_statement_message_set.rb', line 109

def ofx_102_name
    'CCSTMT'
end

#ofx_102_response_bodyObject

Raises:

  • (NotImplementedError)


113
114
115
# File 'lib/ofx/1.0.2/credit_card_statement_message_set.rb', line 113

def ofx_102_response_body
    raise NotImplementedError
end