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,84 @@
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
+ module OFX
19
+ class SignupMessageSet < MessageSet
20
+ def precedence
21
+ 2
22
+ end
23
+ def version
24
+ 1
25
+ end
26
+ end
27
+
28
+ class SignupMessageSetProfile < MessageSetProfile
29
+ def self.message_set_class
30
+ SignupMessageSet
31
+ end
32
+
33
+ attr_accessor :enrollment
34
+ attr_accessor :user_information_changes_allowed
35
+ def user_information_changes_allowed?
36
+ user_information_changes_allowed
37
+ end
38
+ attr_accessor :available_account_requests_allowed
39
+ def available_account_requests_allowed?
40
+ available_account_requests_allowed
41
+ end
42
+ attr_accessor :service_activation_requests_allowed
43
+ def service_activation_requests_allowed?
44
+ service_activation_requests_allowed
45
+ end
46
+ end
47
+ class Enrollment
48
+ end
49
+ class ClientEnrollment < Enrollment
50
+ attr_accessor :account_number_required
51
+ def account_number_required?
52
+ @account_number_required
53
+ end
54
+ def initialize(account_number_required)
55
+ @account_number_required = account_number_required
56
+ end
57
+ end
58
+ class WebEnrollment < Enrollment
59
+ attr_accessor :url
60
+ def initialize(url)
61
+ @url = url
62
+ end
63
+ end
64
+ class OtherEnrollment < Enrollment
65
+ attr_accessor :message
66
+ def initialize(message)
67
+ @message = message
68
+ end
69
+ end
70
+
71
+ class AccountInformationRequest < TransactionalRequest
72
+ attr_accessor :date_of_last_account_update
73
+ end
74
+ class AccountInformationResponse < TransactionalResponse
75
+ attr_accessor :date_of_last_account_update
76
+ attr_accessor :accounts
77
+ end
78
+
79
+ class AccountInformation
80
+ attr_accessor :description
81
+ attr_accessor :phone_number
82
+ attr_accessor :account_information
83
+ end
84
+ end
@@ -0,0 +1,49 @@
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
+ module OFX
19
+ class Balance
20
+ attr_accessor :amount
21
+ attr_accessor :as_of
22
+ end
23
+
24
+ class Transaction
25
+ attr_accessor :transaction_type
26
+
27
+ attr_accessor :date_posted
28
+ attr_accessor :date_initiated
29
+ attr_accessor :date_available
30
+
31
+ attr_accessor :amount
32
+ attr_accessor :currency
33
+
34
+ attr_accessor :financial_institution_transaction_identifier
35
+ attr_accessor :corrected_financial_institution_transaction_identifier
36
+ attr_accessor :correction_action
37
+ attr_accessor :server_transaction_identifier
38
+ attr_accessor :check_number
39
+ attr_accessor :reference_number
40
+
41
+ attr_accessor :standard_industrial_code
42
+
43
+ attr_accessor :payee_identifier
44
+ attr_accessor :payee
45
+ attr_accessor :transfer_destination_account
46
+
47
+ attr_accessor :memo
48
+ end
49
+ end
data/lib/ofx/status.rb ADDED
@@ -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
+ module OFX
19
+ class Status
20
+ attr_accessor :code
21
+ attr_accessor :severity
22
+ attr_accessor :message
23
+
24
+ def initialize(code, severity, message)
25
+ @code = code
26
+ @severity = severity
27
+ @message = message
28
+ end
29
+
30
+ def self.from_numerical_code_severity_and_message(code, severity, message)
31
+ status_class = CODES_TO_OFX_STATUS[code] || SEVERITIES_TO_UNKNOWN_OFX_STATUS[severity]
32
+ raise unless status_class
33
+
34
+ status_class.new(code, severity, message)
35
+ end
36
+ end
37
+
38
+ class Information < Status
39
+ end
40
+ class Warning < Status
41
+ end
42
+ class Error < Status
43
+ end
44
+
45
+ class UnknownInformation < Information
46
+ end
47
+ class UnknownWarning < Warning
48
+ end
49
+ class UnknownError < Error
50
+ end
51
+
52
+ # general statuses
53
+ class Success < Information
54
+ end
55
+ class GeneralError < Error
56
+ end
57
+ class UnsupportedVersion < Error
58
+ end
59
+
60
+ # signon message set
61
+ class MustChangePassword < Information
62
+ end
63
+ class SignonInvalid < Error
64
+ end
65
+ class CustomerAccountAlreadyInUse < Error
66
+ end
67
+ class AccountLockedOut < Error
68
+ end
69
+
70
+ # financial institution profile message set
71
+ class ClientUpToDate < Information
72
+ end
73
+
74
+ # build tables of the status subclasses
75
+ class Status
76
+ private
77
+ SEVERITIES_TO_UNKNOWN_OFX_STATUS =
78
+ {
79
+ :information => UnknownInformation,
80
+ :warning => UnknownWarning,
81
+ :error => UnknownError
82
+ }
83
+ CODES_TO_OFX_STATUS =
84
+ {
85
+ # general codes
86
+ 0 => Success,
87
+ 2000 => GeneralError,
88
+ 2021 => UnsupportedVersion,
89
+
90
+ # signon message set
91
+ 15000 => MustChangePassword,
92
+ 15500 => SignonInvalid,
93
+ 15501 => CustomerAccountAlreadyInUse,
94
+ 15502 => AccountLockedOut,
95
+
96
+ # financial institution profile message set
97
+ 1 => ClientUpToDate
98
+ }
99
+ end
100
+ end
@@ -0,0 +1,28 @@
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
+ module OFX
19
+ class TransactionUniqueIdentifier
20
+ def initialize
21
+ @timestamp = DateTime.now
22
+ end
23
+
24
+ def to_s
25
+ @timestamp.strftime('%Y%m%d%H%M%S')
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,82 @@
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
+ module OFX
19
+ class Version
20
+ include Comparable
21
+
22
+ def initialize(version)
23
+ @version = [0, 0, 0]
24
+
25
+ version = version.to_a if version.kind_of?(Version)
26
+
27
+ @version[0] = version if version.kind_of?(Integer)
28
+ return unless version.respond_to?(:length)
29
+
30
+ @version[0] = version[0..0].to_s.to_i if (version.length >= 1)
31
+
32
+ if (version.length == 3)
33
+ @version[1] = version[1..1].to_s.to_i
34
+ @version[2] = version[2..2].to_s.to_i
35
+ elsif (version.length == 5)
36
+ @version[1] = version[2..2].to_s.to_i
37
+ @version[2] = version[4..4].to_s.to_i
38
+ end
39
+ end
40
+
41
+ def major
42
+ @version[0]
43
+ end
44
+
45
+ def minor
46
+ @version[1]
47
+ end
48
+
49
+ def revision
50
+ @version[2]
51
+ end
52
+
53
+ def to_dotted_s
54
+ @version.join('.')
55
+ end
56
+ def to_compact_s
57
+ @version.join('')
58
+ end
59
+
60
+ def to_a
61
+ @version.dup
62
+ end
63
+
64
+ def empty?
65
+ @version == [0, 0, 0]
66
+ end
67
+
68
+ def <=> (other)
69
+ @version <=> other.to_a
70
+ end
71
+ def eql?(other)
72
+ other_a = other.to_a
73
+
74
+ return @version[0] == other_a[0] && @version[1] == other_a[1] && @version[2] == other_a[2]
75
+ end
76
+ def hash()
77
+ return @version.hash
78
+ end
79
+ end
80
+
81
+ VERSION = Version.new('0.1.1')
82
+ end
@@ -0,0 +1,33 @@
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
+ module OFX
19
+ class WireFundsTransferMessageSet < MessageSet
20
+ def precedence
21
+ 7
22
+ end
23
+ def version
24
+ 1
25
+ end
26
+ end
27
+
28
+ class WireFundsTransferMessageSetProfile < MessageSetProfile
29
+ def self.message_set_class
30
+ WireFundsTransferMessageSet
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "ofx/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ofx_for_ruby"
7
+ s.version = OFX::VERSION.to_dotted_s
8
+ s.platform = Gem::Platform::RUBY
9
+
10
+ s.authors = ["Chris Guidry"]
11
+ s.description = "OFX for Ruby is a pure Ruby implementation of Open Financial Exchange specifications (1.0.2 through 2.1.1) for building both financial clients and servers, providing parsers/serializers for each version, and a uniform object model across all versions."
12
+ s.email = ["chrisguidry@gmail.com"]
13
+ s.summary = "Pure Ruby implementation of Open Financial Exchange specifications"
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+ s.homepage = "http://github.com/baconpat/ofx_for_ruby"
19
+
20
+ s.add_dependency "activesupport"
21
+
22
+ s.add_development_dependency "racc"
23
+ s.add_development_dependency "rex"
24
+ s.add_development_dependency "rcov"
25
+ 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 CapitalOneHelper
23
+
24
+ def setup_capital_one_credentials()
25
+ File.open(File.dirname(__FILE__) + '/fixtures/capital-one-credentials') do |file|
26
+ @user_name, @password = file.gets.split(',')
27
+ end
28
+ end
29
+
30
+ def setup_capital_one_accounts()
31
+ File.open(File.dirname(__FILE__) + '/fixtures/capital-one-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_capital_one_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_capital_one_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_not_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_not_equal(nil, signon_response.date_of_last_account_update)
71
+ assert_not_equal(nil, signon_response.financial_institution_identification)
72
+ assert_equal('Hibernia', signon_response.financial_institution_identification.organization)
73
+ assert_equal('1001', signon_response.financial_institution_identification.financial_institution_identifier)
74
+ assert_equal(nil, signon_response.session_cookie)
75
+ end
76
+
77
+ end