ofx_for_ruby 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/.externalToolBuilders/Rebuild parsers.launch +10 -0
  2. data/.gitignore +9 -0
  3. data/.loadpath +5 -0
  4. data/.project +27 -0
  5. data/COPYING +674 -0
  6. data/Gemfile +2 -0
  7. data/README +47 -0
  8. data/RELEASE_NOTES +45 -0
  9. data/Rakefile +63 -0
  10. data/lib/ofx.rb +60 -0
  11. data/lib/ofx/1.0.2/banking_message_set.rb +261 -0
  12. data/lib/ofx/1.0.2/credit_card_statement_message_set.rb +269 -0
  13. data/lib/ofx/1.0.2/document.rb +34 -0
  14. data/lib/ofx/1.0.2/email_message_set.rb +34 -0
  15. data/lib/ofx/1.0.2/financial_institution_profile_message_set.rb +155 -0
  16. data/lib/ofx/1.0.2/header.rb +48 -0
  17. data/lib/ofx/1.0.2/interbank_funds_transfer_message_set.rb +30 -0
  18. data/lib/ofx/1.0.2/investment_security_list_message_set.rb +30 -0
  19. data/lib/ofx/1.0.2/investment_statement_message_set.rb +30 -0
  20. data/lib/ofx/1.0.2/lexer.rb +135 -0
  21. data/lib/ofx/1.0.2/message_set.rb +165 -0
  22. data/lib/ofx/1.0.2/ofx_102.racc +90 -0
  23. data/lib/ofx/1.0.2/ofx_102.rex +65 -0
  24. data/lib/ofx/1.0.2/parser.rb +215 -0
  25. data/lib/ofx/1.0.2/payment_message_set.rb +30 -0
  26. data/lib/ofx/1.0.2/serializer.rb +114 -0
  27. data/lib/ofx/1.0.2/signon_message_set.rb +121 -0
  28. data/lib/ofx/1.0.2/signup_message_set.rb +186 -0
  29. data/lib/ofx/1.0.2/statements.rb +54 -0
  30. data/lib/ofx/1.0.2/status.rb +30 -0
  31. data/lib/ofx/1.0.2/wire_funds_transfer_message_set.rb +30 -0
  32. data/lib/ofx/banking_message_set.rb +125 -0
  33. data/lib/ofx/credit_card_statement_message_set.rb +104 -0
  34. data/lib/ofx/document.rb +30 -0
  35. data/lib/ofx/email_message_set.rb +42 -0
  36. data/lib/ofx/file_unique_identifier.rb +28 -0
  37. data/lib/ofx/financial_client.rb +76 -0
  38. data/lib/ofx/financial_institution.rb +83 -0
  39. data/lib/ofx/financial_institution_profile_message_set.rb +67 -0
  40. data/lib/ofx/header.rb +115 -0
  41. data/lib/ofx/http/cacert.pem +3509 -0
  42. data/lib/ofx/http/ofx_http_client.rb +84 -0
  43. data/lib/ofx/interbank_funds_transfer_message_set.rb +33 -0
  44. data/lib/ofx/investment_security_list_message_set.rb +33 -0
  45. data/lib/ofx/investment_statement_message_set.rb +33 -0
  46. data/lib/ofx/message_set.rb +78 -0
  47. data/lib/ofx/payment_message_set.rb +33 -0
  48. data/lib/ofx/serializer.rb +39 -0
  49. data/lib/ofx/signon_message_set.rb +141 -0
  50. data/lib/ofx/signup_message_set.rb +84 -0
  51. data/lib/ofx/statements.rb +49 -0
  52. data/lib/ofx/status.rb +100 -0
  53. data/lib/ofx/transaction_unique_identifier.rb +28 -0
  54. data/lib/ofx/version.rb +82 -0
  55. data/lib/ofx/wire_funds_transfer_message_set.rb +33 -0
  56. data/ofx_for_ruby.gemspec +25 -0
  57. data/planning/OFX Specification completion.ods +0 -0
  58. data/test/capital_one/capital_one_helper.rb +77 -0
  59. data/test/capital_one/fixtures/README +10 -0
  60. data/test/capital_one/fixtures/fipid-5599.xml +98 -0
  61. data/test/capital_one/test_banking_statement.rb +108 -0
  62. data/test/capital_one/test_financial_institution_profile.rb +295 -0
  63. data/test/capital_one/test_ofx_http_client.rb +72 -0
  64. data/test/capital_one/test_signup_account_information.rb +100 -0
  65. data/test/citi/citi_helper.rb +77 -0
  66. data/test/citi/fixtures/README +9 -0
  67. data/test/citi/fixtures/fipid-6642.xml +98 -0
  68. data/test/citi/test_credit_card_statement.rb +159 -0
  69. data/test/citi/test_financial_institution_profile.rb +231 -0
  70. data/test/citi/test_ofx_http_client.rb +71 -0
  71. data/test/citi/test_signup_account_information.rb +85 -0
  72. data/test/test_helper.rb +4 -0
  73. data/test/test_ofx_version.rb +141 -0
  74. metadata +210 -0
@@ -0,0 +1,72 @@
1
+ # Copyright © 2007 Chris Guidry <chrisguidry@gmail.com>
2
+ #
3
+ # This file is part of OFX for Ruby.
4
+ #
5
+ # OFX for Ruby is free software; you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation; either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # OFX for Ruby is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require File.dirname(__FILE__) + '/capital_one_helper'
19
+
20
+ class CapitalOneOFXHTTPClientTest < Test::Unit::TestCase
21
+
22
+ include CapitalOneHelper
23
+
24
+ def setup
25
+ setup_capital_one_credentials
26
+ end
27
+
28
+ def test_account_info_request_to_capital_one
29
+ account_info_request =
30
+ "OFXHEADER:100
31
+ DATA:OFXSGML
32
+ VERSION:102
33
+ SECURITY:NONE
34
+ ENCODING:USASCII
35
+ CHARSET:1252
36
+ COMPRESSION:NONE
37
+ OLDFILEUID:NONE
38
+ NEWFILEUID:20070518034113.000
39
+
40
+ <OFX>
41
+ <SIGNONMSGSRQV1>
42
+ <SONRQ>
43
+ <DTCLIENT>20070518034113.000
44
+ <USERID>#{@user_name}
45
+ <USERPASS>#{@password}
46
+ <LANGUAGE>ENG
47
+ <FI>
48
+ <ORG>Hibernia
49
+ <FID>1001
50
+ </FI>
51
+ <APPID>QWIN
52
+ <APPVER>1200
53
+ </SONRQ>
54
+ </SIGNONMSGSRQV1>
55
+ <SIGNUPMSGSRQV1>
56
+ <ACCTINFOTRNRQ>
57
+ <TRNUID>#{DateTime.now.to_ofx_102_s}
58
+ <CLTCOOKIE>1
59
+ <ACCTINFORQ>
60
+ <DTACCTUP>19700101
61
+ </ACCTINFORQ>
62
+ </ACCTINFOTRNRQ>
63
+ </SIGNUPMSGSRQV1>
64
+ </OFX>"
65
+
66
+ client = OFX::HTTPClient.new(URI.parse('https://onlinebanking.capitalone.com/scripts/serverext.dll'))
67
+ account_info_response = client.send(account_info_request)
68
+ assert account_info_response != nil
69
+ assert account_info_response[0..12] == 'OFXHEADER:100'
70
+ end
71
+
72
+ end
@@ -0,0 +1,100 @@
1
+ # Copyright © 2007 Chris Guidry <chrisguidry@gmail.com>
2
+ #
3
+ # This file is part of OFX for Ruby.
4
+ #
5
+ # OFX for Ruby is free software; you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation; either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # OFX for Ruby is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require File.dirname(__FILE__) + '/capital_one_helper'
19
+
20
+ class CapitalOneSignupAccountInformationTest < Test::Unit::TestCase
21
+
22
+ include CapitalOneHelper
23
+
24
+ def setup
25
+ setup_capital_one_credentials
26
+ setup_capital_one_accounts
27
+ end
28
+
29
+ def test_requesting_fresh_fi_profile_from_capital_one
30
+ financial_institution = OFX::FinancialInstitution.get_institution('Capital One')
31
+ requestDocument = financial_institution.create_request_document
32
+
33
+ client = OFX::FinancialClient.new([[OFX::FinancialInstitutionIdentification.new('Hibernia', '1001'),
34
+ OFX::UserCredentials.new(@user_name, @password)]])
35
+ requestDocument.message_sets << client.create_signon_request_message('1001')
36
+
37
+
38
+ signup_message_set = OFX::SignupMessageSet.new
39
+ account_info_request = OFX::AccountInformationRequest.new
40
+ account_info_request.transaction_identifier = OFX::TransactionUniqueIdentifier.new
41
+ account_info_request.date_of_last_account_update = DateTime.new(2001, 1, 1)
42
+ signup_message_set.requests << account_info_request
43
+ requestDocument.message_sets << signup_message_set
44
+
45
+
46
+ response_document = financial_institution.send(requestDocument)
47
+ assert response_document != nil
48
+
49
+ verify_capital_one_header response_document
50
+
51
+ assert_not_equal nil, response_document.message_sets
52
+ assert_equal 2, response_document.message_sets.length
53
+
54
+ verify_capital_one_signon_response response_document
55
+
56
+ signup_message = response_document.message_sets[1]
57
+ assert signup_message.kind_of?(OFX::SignupMessageSet)
58
+ assert_equal 1, signup_message.responses.length
59
+ account_info_response = signup_message.responses[0]
60
+ assert account_info_response.kind_of?(OFX::AccountInformationResponse)
61
+ assert_not_equal nil, account_info_response.transaction_identifier
62
+ assert_not_equal nil, account_info_response.status
63
+ assert account_info_response.status.kind_of?(OFX::Information)
64
+ assert account_info_response.status.kind_of?(OFX::Success)
65
+ assert_equal 0, account_info_response.status.code
66
+ assert_equal :information, account_info_response.status.severity
67
+ assert_not_equal nil, account_info_response.status.message
68
+
69
+ assert_not_equal nil, account_info_response.date_of_last_account_update
70
+
71
+ assert_not_equal nil, account_info_response.accounts
72
+ assert_equal 2, account_info_response.accounts.length
73
+
74
+ checking = account_info_response.accounts[0]
75
+ assert_equal 'VIP Free Interest Checking', checking.description
76
+ assert_equal nil, checking.phone_number
77
+ assert_not_equal nil, checking.account_information
78
+ assert_not_equal nil, checking.account_information.account
79
+ assert_equal '065002030', checking.account_information.account.bank_identifier
80
+ assert_equal @accounts[:checking], checking.account_information.account.account_identifier
81
+ assert_equal :checking, checking.account_information.account.account_type
82
+ assert_equal true, checking.account_information.supports_transaction_detail_downloads
83
+ assert_equal true, checking.account_information.transfer_source
84
+ assert_equal true, checking.account_information.transfer_destination
85
+ assert_equal :active, checking.account_information.status
86
+
87
+ savings = account_info_response.accounts[1]
88
+ assert_equal 'Regular Savings', savings.description
89
+ assert_equal nil, savings.phone_number
90
+ assert_not_equal nil, savings.account_information
91
+ assert_not_equal nil, savings.account_information.account
92
+ assert_equal '065002030', savings.account_information.account.bank_identifier
93
+ assert_equal @accounts[:savings], savings.account_information.account.account_identifier
94
+ assert_equal :savings, savings.account_information.account.account_type
95
+ assert_equal true, savings.account_information.supports_transaction_detail_downloads
96
+ assert_equal true, savings.account_information.transfer_source
97
+ assert_equal true, savings.account_information.transfer_destination
98
+ assert_equal :active, savings.account_information.status
99
+ end
100
+ end
@@ -0,0 +1,77 @@
1
+ # Copyright © 2007 Chris Guidry <chrisguidry@gmail.com>
2
+ #
3
+ # This file is part of OFX for Ruby.
4
+ #
5
+ # OFX for Ruby is free software; you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation; either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # OFX for Ruby is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require File.dirname(__FILE__) + '/../test_helper'
19
+
20
+ require 'uri'
21
+
22
+ module CitiHelper
23
+
24
+ def setup_citi_credentials()
25
+ File.open(File.dirname(__FILE__) + '/fixtures/citi-credentials') do |file|
26
+ @user_name, @password = file.gets.split(',')
27
+ end
28
+ end
29
+
30
+ def setup_citi_accounts()
31
+ File.open(File.dirname(__FILE__) + '/fixtures/citi-accounts') do |file|
32
+ @accounts = {}
33
+ file.each_line do |line|
34
+ type, account = line.split(',')
35
+ @accounts[type.chomp.to_sym] = account.chomp
36
+ end
37
+ end
38
+ end
39
+
40
+ def verify_citi_header(response_document)
41
+ assert_not_equal(nil, response_document.header)
42
+ assert_equal(OFX::Version.new("1.0.0"), response_document.header.header_version)
43
+ assert_equal('OFXSGML', response_document.header.content_type)
44
+ assert_equal(OFX::Version.new("1.0.2"), response_document.header.document_version)
45
+ assert_equal('NONE', response_document.header.security)
46
+ assert_equal('USASCII', response_document.header.content_encoding)
47
+ assert_equal('1252', response_document.header.content_character_set)
48
+ assert_equal('NONE', response_document.header.compression)
49
+ assert_not_equal(nil, response_document.header.unique_identifier)
50
+ assert_not_equal(nil, response_document.header.previous_unique_identifier)
51
+ end
52
+
53
+ def verify_citi_signon_response(response_document)
54
+ signon_message = response_document.message_sets[0]
55
+ assert signon_message.kind_of?(OFX::SignonMessageSet)
56
+ assert_equal(1, signon_message.responses.length)
57
+
58
+ signon_response = signon_message.responses[0]
59
+ assert signon_response.kind_of?(OFX::SignonResponse)
60
+ assert_not_equal(nil, signon_response.status)
61
+ assert signon_response.status.kind_of?(OFX::Information)
62
+ assert signon_response.status.kind_of?(OFX::Success)
63
+ assert_equal(0, signon_response.status.code)
64
+ assert_equal(:information, signon_response.status.severity)
65
+ assert_equal(nil, signon_response.status.message)
66
+ assert_not_equal(nil, signon_response.date)
67
+ assert_equal(nil, signon_response.user_key)
68
+ assert_equal('ENG', signon_response.language)
69
+ assert_not_equal(nil, signon_response.date_of_last_profile_update)
70
+ assert_equal(nil, signon_response.date_of_last_account_update)
71
+ assert_not_equal(nil, signon_response.financial_institution_identification)
72
+ assert_equal('Citigroup', signon_response.financial_institution_identification.organization)
73
+ assert_equal('24909', signon_response.financial_institution_identification.financial_institution_identifier)
74
+ assert_equal(nil, signon_response.session_cookie)
75
+ end
76
+
77
+ end
@@ -0,0 +1,9 @@
1
+ If you want to run tests for CitiCards, you will need to place two files here called citi-accounts and citi-credentials. These
2
+ should contain valid CitiCards account numbers and logins.
3
+
4
+ Examples:
5
+ citi-accounts:
6
+ credit_card,XXXXXXXXXXXX0000
7
+
8
+ citi-credentials:
9
+ my_user_name,my_password
@@ -0,0 +1,98 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <MSNOnlSvcInfo Version="2.0" xmlns:msxml="urn:schemas-microsoft-com:xslt">
3
+ <ProviderSettings>
4
+ <FIPID>6642</FIPID>
5
+ <Name>Citi Cards</Name>
6
+ <Address1>8787 Baypine Road</Address1>
7
+ <Address2></Address2>
8
+ <Address3></Address3>
9
+ <City>Jacksonville</City>
10
+ <State>FL</State>
11
+ <Zip>32256</Zip>
12
+ <Country>USA</Country>
13
+ <Phone>(800) 950-5114</Phone>
14
+ <InternetMail></InternetMail>
15
+ <Website1>http://www.citicards.com/</Website1>
16
+ <hfi>{DB65F1ED-7ECF-4B27-BC41-EDFD407DAAF7}</hfi>
17
+ <hfisvc>{0D806019-7EC0-4241-A596-0D586854B3E9}</hfisvc>
18
+ <DriverType>O</DriverType>
19
+ <StandAlone>0</StandAlone>
20
+ <Org>Citigroup</Org>
21
+ <FID>24909</FID>
22
+ <AcctListAvail>1</AcctListAvail>
23
+ <ClientActReq>0</ClientActReq>
24
+ <BrokerID></BrokerID>
25
+ <OFXHeaderVer>102</OFXHeaderVer>
26
+ <FullSyncSupp>0</FullSyncSupp>
27
+ <DisallowUSASCIIEncoding>0</DisallowUSASCIIEncoding>
28
+ <DisallowUNICODEEncoding>1</DisallowUNICODEEncoding>
29
+ <DisallowUTF8Encoding>1</DisallowUTF8Encoding>
30
+ <DisallowGenMail>1</DisallowGenMail>
31
+ <DisallowPinChange>1</DisallowPinChange>
32
+ <Min>6</Min>
33
+ <Max>32</Max>
34
+ <Alpha>1</Alpha>
35
+ <Numeric>1</Numeric>
36
+ <Special>1</Special>
37
+ <Spaces>1</Spaces>
38
+ <ChangePin>0</ChangePin>
39
+ <TANRequired>0</TANRequired>
40
+ <ProviderURL>https://secureofx2.bankhost.com/citi/cgi-forte/ofx_rt?servicename=ofx_rt&amp;pagename=ofx</ProviderURL>
41
+ <ServiceUpdateURL></ServiceUpdateURL>
42
+ <SmallLogoURL>https://www.microsoft.com/Money/Money2005/USA/6642.bmp</SmallLogoURL>
43
+ <ProvUpdateDescURL></ProvUpdateDescURL>
44
+ <CommentsTXT>Download your monthly statements by signing on to Cardmember Central at http://www.citicards.com.\r\n \r\nOr, download your account activity from within Money by following these steps:\r\n1) Select "Go to Citi Cards" under the "Common Tasks" heading on the left hand side of this page.\r\n2) From the "What would you like to do with Citi Cards?" page, select "Connect to online services" located under the "Use online services" section.\r\n</CommentsTXT>
45
+ <UserIDString>User ID</UserIDString>
46
+ <PasswordString>Password</PasswordString>
47
+ <ServiceVersion>1</ServiceVersion>
48
+ <StatementLogonURL>http://www.citicards.com/</StatementLogonURL>
49
+ <PaymentLogonURL></PaymentLogonURL>
50
+ <WebServicesURL>http://www.citicards.com/</WebServicesURL>
51
+ <BrandingDate>7/24/2003</BrandingDate>
52
+ </ProviderSettings>
53
+ <BankingCapabilities>
54
+ <Bank>1</Bank>
55
+ <BankMail>0</BankMail>
56
+ <IntraXferCanSched>0</IntraXferCanSched>
57
+ <CreditCard>1</CreditCard>
58
+ <DfltDays>0</DfltDays>
59
+ <IntraXferSupp>0</IntraXferSupp>
60
+ <IntraSyncSupp>0</IntraSyncSupp>
61
+ </BankingCapabilities>
62
+ <BillPayCapabilities>
63
+ <Pay>0</Pay>
64
+ <BillPayMail>0</BillPayMail>
65
+ <DfltDaysWith>0</DfltDaysWith>
66
+ <DfltDaysToPay>0</DfltDaysToPay>
67
+ <XferDfltDaysWith>0</XferDfltDaysWith>
68
+ <XferDfltDaysToPay>0</XferDfltDaysToPay>
69
+ <IdDfltDaysWith>0</IdDfltDaysWith>
70
+ <IdDfltDaysToPay>0</IdDfltDaysToPay>
71
+ <CountNonBusDays>0</CountNonBusDays>
72
+ <PmtByAddr>0</PmtByAddr>
73
+ <PmtByXfer>0</PmtByXfer>
74
+ <PmtByPayeeID>0</PmtByPayeeID>
75
+ <DisallowRecPmt>1</DisallowRecPmt>
76
+ <DisallowCreditCardPmt>1</DisallowCreditCardPmt>
77
+ <UseProcessDateModel>0</UseProcessDateModel>
78
+ <BillPay2AddrLines>0</BillPay2AddrLines>
79
+ </BillPayCapabilities>
80
+ <InvestmentCapabilities>
81
+ <BrkStmt>0</BrkStmt>
82
+ <InvMail>0</InvMail>
83
+ <DisallowInvTranDownload>1</DisallowInvTranDownload>
84
+ <DisallowOODownload>1</DisallowOODownload>
85
+ <DisallowPositionDownload>1</DisallowPositionDownload>
86
+ <DisallowInvBalanceDownload>1</DisallowInvBalanceDownload>
87
+ </InvestmentCapabilities>
88
+ <PinWiz>
89
+ <SignupType>2</SignupType>
90
+ <URLPin></URLPin>
91
+ <PhonePin>800-347-4934</PhonePin>
92
+ <Charge>0.0000</Charge>
93
+ <ChargeFrq>1</ChargeFrq>
94
+ <ConnectionSurchargeLimit>0</ConnectionSurchargeLimit>
95
+ <UsesWebPwd>1</UsesWebPwd>
96
+ <SeparateEnroll>0</SeparateEnroll>
97
+ </PinWiz>
98
+ </MSNOnlSvcInfo>
@@ -0,0 +1,159 @@
1
+ # Copyright © 2007 Chris Guidry <chrisguidry@gmail.com>
2
+ #
3
+ # This file is part of OFX for Ruby.
4
+ #
5
+ # OFX for Ruby is free software; you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation; either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # OFX for Ruby is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require File.dirname(__FILE__) + '/citi_helper'
19
+
20
+ class CitiCreditCardStatmentTest < Test::Unit::TestCase
21
+
22
+ include CitiHelper
23
+
24
+ def setup
25
+ setup_citi_credentials
26
+ setup_citi_accounts
27
+ end
28
+
29
+ def test_requesting_last_seven_days_statement_from_citi
30
+ financial_institution = OFX::FinancialInstitution.get_institution('Citi')
31
+ requestDocument = financial_institution.create_request_document
32
+
33
+ client = OFX::FinancialClient.new([[OFX::FinancialInstitutionIdentification.new('Citigroup', '24909'),
34
+ OFX::UserCredentials.new(@user_name, @password)]])
35
+ requestDocument.message_sets << client.create_signon_request_message('24909')
36
+
37
+ cc_message_set = OFX::CreditCardStatementMessageSet.new
38
+ statement_request = OFX::CreditCardStatementRequest.new
39
+
40
+ statement_request.transaction_identifier = OFX::TransactionUniqueIdentifier.new
41
+ statement_request.account = OFX::CreditCardAccount.new
42
+ statement_request.account.account_identifier = @accounts[:credit_card]
43
+
44
+ statement_request.include_transactions = true
45
+ statement_request.included_range = nil
46
+
47
+ cc_message_set.requests << statement_request
48
+ requestDocument.message_sets << cc_message_set
49
+
50
+ response_document = financial_institution.send(requestDocument)
51
+ assert response_document != nil
52
+
53
+ verify_citi_header response_document
54
+
55
+ assert_not_equal nil, response_document.message_sets
56
+ assert_equal 2, response_document.message_sets.length
57
+
58
+ verify_citi_signon_response response_document
59
+
60
+ cc_message_set = response_document.message_sets[1]
61
+ assert_not_equal nil, cc_message_set
62
+ assert cc_message_set.kind_of?(OFX::CreditCardStatementMessageSet)
63
+ assert_equal 1, cc_message_set.responses.length
64
+ statement = cc_message_set.responses[0]
65
+ assert_not_equal nil, statement
66
+ assert_equal 'USD', statement.default_currency
67
+ assert_not_equal nil, statement.account
68
+ assert_equal @accounts[:credit_card], statement.account.account_identifier
69
+
70
+ assert_equal nil, statement.marketing_information
71
+
72
+ assert_not_equal nil, statement.ledger_balance
73
+ assert_not_equal nil, statement.ledger_balance.amount
74
+ assert_not_equal nil, statement.ledger_balance.as_of
75
+
76
+ assert_not_equal nil, statement.available_balance
77
+ assert_not_equal nil, statement.available_balance.amount
78
+ assert_not_equal nil, statement.available_balance.as_of
79
+
80
+ assert_not_equal nil, statement.transaction_range
81
+ assert_not_equal nil, statement.transaction_range.begin
82
+ assert_not_equal nil, statement.transaction_range.end
83
+ assert_not_equal nil, statement.transactions
84
+
85
+ statement.transactions.each do |transaction|
86
+ assert_not_equal nil, transaction.transaction_type
87
+ assert_not_equal nil, transaction.date_posted
88
+ assert_not_equal nil, transaction.amount
89
+ assert transaction.amount != 0.0.to_d
90
+ assert_not_equal nil, transaction.financial_institution_transaction_identifier
91
+ assert_not_equal nil, transaction.standard_industrial_code
92
+ end
93
+ end
94
+
95
+ def test_requesting_closing_statement_from_citi
96
+ financial_institution = OFX::FinancialInstitution.get_institution('Citi')
97
+ requestDocument = financial_institution.create_request_document
98
+
99
+ client = OFX::FinancialClient.new([[OFX::FinancialInstitutionIdentification.new('Citigroup', '24909'),
100
+ OFX::UserCredentials.new(@user_name, @password)]])
101
+ requestDocument.message_sets << client.create_signon_request_message('24909')
102
+
103
+ cc_message_set = OFX::CreditCardStatementMessageSet.new
104
+ statement_request = OFX::CreditCardClosingStatementRequest.new
105
+
106
+ statement_request.transaction_identifier = OFX::TransactionUniqueIdentifier.new
107
+ statement_request.account = OFX::CreditCardAccount.new
108
+ statement_request.account.account_identifier = @accounts[:credit_card]
109
+
110
+ cc_message_set.requests << statement_request
111
+ requestDocument.message_sets << cc_message_set
112
+
113
+ response_document = financial_institution.send(requestDocument)
114
+ assert response_document != nil
115
+
116
+ verify_citi_header response_document
117
+
118
+ assert_not_equal nil, response_document.message_sets
119
+ assert_equal 2, response_document.message_sets.length
120
+
121
+ verify_citi_signon_response response_document
122
+
123
+ cc_message_set = response_document.message_sets[1]
124
+ assert_not_equal nil, cc_message_set
125
+ assert_equal 1, cc_message_set.responses.length
126
+ statement = cc_message_set.responses[0]
127
+ assert_not_equal nil, statement
128
+ assert_equal 'USD', statement.default_currency
129
+ assert_not_equal nil, statement.account
130
+ assert_equal @accounts[:credit_card], statement.account.account_identifier
131
+
132
+ assert_not_equal nil, statement.statements
133
+ assert_not_equal 0, statement.statements.length
134
+ statement.statements.each do |closing|
135
+ assert_equal 'USD', closing.currency
136
+
137
+ assert_not_equal nil, closing.finanical_institution_transaction_identifier
138
+ assert_not_equal nil, closing.statement_range
139
+ assert_equal nil, closing.next_statement_close
140
+
141
+ assert_equal nil, closing.opening_balance
142
+ assert_not_equal nil, closing.closing_balance
143
+
144
+ assert_not_equal nil, closing.payment_due_date
145
+ assert_not_equal nil, closing.minimum_payment_due
146
+
147
+ assert_equal nil, closing.finance_charge
148
+ assert_equal nil, closing.total_of_payments_and_charges
149
+ assert_equal nil, closing.total_of_purchases_and_advances
150
+ assert_equal nil, closing.debit_adjustements
151
+ assert_not_equal nil, closing.credit_limit
152
+ assert_not_equal 0.0.to_d, closing.credit_limit
153
+
154
+ assert_not_equal nil, closing.transaction_range
155
+
156
+ assert_equal nil, closing.marketing_information
157
+ end
158
+ end
159
+ end