ofx_for_ruby 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,7 +27,7 @@ module OFX
27
27
  @ofx_uri = ofx_uri
28
28
  end
29
29
 
30
- def send(ofx_body)
30
+ def send(ofx_body, ssl_version=nil, do_print_request=false, do_print_response=false)
31
31
  http_request = Net::HTTP::Post.new(@ofx_uri.request_uri)
32
32
 
33
33
  http_request['User-Agent'] = "OFX for Ruby #{OFX::VERSION.to_dotted_s}"
@@ -37,9 +37,18 @@ module OFX
37
37
 
38
38
  http_request.body = ofx_body.gsub("\n", "\r\n")
39
39
 
40
- # print_request http_request
40
+ if (do_print_request)
41
+ print_request http_request
42
+ end
41
43
 
42
44
  http = Net::HTTP.new(@ofx_uri.host, @ofx_uri.port)
45
+
46
+ if (ssl_version)
47
+ # supported in Ruby 1.9 or patched into 1.8
48
+ if (Net::HTTP.method_defined?(:ssl_version=))
49
+ http.ssl_version=ssl_version
50
+ end
51
+ end
43
52
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
44
53
  http.ca_file = File.join(File.dirname(__FILE__), "cacert.pem")
45
54
  http.use_ssl = true
@@ -47,12 +56,12 @@ module OFX
47
56
  http.request(http_request)
48
57
  end
49
58
 
50
- #print_response http_response
51
-
52
59
  case http_response
53
60
  when Net::HTTPSuccess
61
+ print_response http_response if do_print_response
54
62
  http_response.body
55
63
  else
64
+ print_response http_response
56
65
  http_response.error!
57
66
  end
58
67
  end
@@ -81,4 +90,4 @@ module OFX
81
90
  puts http_response.body
82
91
  end
83
92
  end
84
- end
93
+ end
data/lib/ofx/version.rb CHANGED
@@ -82,5 +82,5 @@ module OFX
82
82
  end
83
83
  end
84
84
 
85
- VERSION = Version.new('0.1.3')
85
+ VERSION = Version.new('0.1.5')
86
86
  end
@@ -0,0 +1,60 @@
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 'active_support'
19
+ require 'uri'
20
+ require 'cgi'
21
+
22
+ require 'bigdecimal'
23
+ require 'bigdecimal/util'
24
+
25
+ require 'ofx/version'
26
+ require 'ofx/status'
27
+ require 'ofx/file_unique_identifier'
28
+ require 'ofx/transaction_unique_identifier'
29
+ require 'ofx/header'
30
+ require 'ofx/message_set'
31
+ require 'ofx/document'
32
+ require 'ofx/statements'
33
+
34
+ require 'ofx/financial_institution'
35
+ require 'ofx/financial_client'
36
+
37
+ require 'ofx/signon_message_set'
38
+ require 'ofx/signup_message_set'
39
+ require 'ofx/banking_message_set'
40
+ require 'ofx/credit_card_statement_message_set'
41
+ require 'ofx/investment_statement_message_set'
42
+ require 'ofx/interbank_funds_transfer_message_set'
43
+ require 'ofx/wire_funds_transfer_message_set'
44
+ require 'ofx/payment_message_set'
45
+ require 'ofx/email_message_set'
46
+ require 'ofx/investment_security_list_message_set'
47
+ require 'ofx/financial_institution_profile_message_set'
48
+
49
+ require 'ofx/serializer'
50
+
51
+ require 'ofx/http/ofx_http_client.rb'
52
+
53
+ # = Summary
54
+ # An implementation of the OFX specification for financial systems
55
+ # integration.
56
+ #
57
+ # = Specifications
58
+ # OFX 1.0.2:: http://www.ofx.net/ofx/downloads/ofx102spec.zip
59
+ module OFX
60
+ end
data/ofx_for_ruby.gemspec CHANGED
@@ -19,7 +19,8 @@ Gem::Specification.new do |s|
19
19
 
20
20
  s.add_dependency "activesupport"
21
21
 
22
- s.add_development_dependency "racc"
23
- s.add_development_dependency "rexical"
22
+ s.add_development_dependency "racc", "1.4.6"
23
+ s.add_development_dependency "rexical", "1.0.5"
24
24
  s.add_development_dependency "pry"
25
+ s.add_development_dependency "rake"
25
26
  end
@@ -0,0 +1,192 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/test_helper')
2
+
3
+ class OFXParserTest < Minitest::Test
4
+ def test_parse_with_no_newline_after_header
5
+ body = <<-EOS
6
+
7
+ OFXHEADER:100
8
+ DATA:OFXSGML
9
+ VERSION:102
10
+ SECURITY:NONE
11
+ ENCODING:USASCII
12
+ CHARSET:1252
13
+ COMPRESSION:NONE
14
+ OLDFILEUID:NONE
15
+ NEWFILEUID:NONE
16
+ <OFX>
17
+ <SIGNONMSGSRSV1>
18
+ <SONRS>
19
+ <STATUS>
20
+ <CODE>0
21
+ <SEVERITY>INFO
22
+ </STATUS>
23
+ <DTSERVER>20221013120000[0:GMT]
24
+ <LANGUAGE>ENG
25
+ <FI>
26
+ <ORG>B1
27
+ <FID>10898
28
+ </FI>
29
+ <INTU.BID>10898
30
+ </SONRS>
31
+ </SIGNONMSGSRSV1>
32
+ <BANKMSGSRSV1>
33
+ <STMTTRNRS>
34
+ <TRNUID>1
35
+ <STATUS>
36
+ <CODE>0
37
+ <SEVERITY>INFO
38
+ <MESSAGE>Success
39
+ </STATUS>
40
+ <STMTRS>
41
+ <CURDEF>USD
42
+ <BANKACCTFROM>
43
+ <BANKID>0713456513
44
+ <ACCTID>123456788
45
+ <ACCTTYPE>CHECKING
46
+ </BANKACCTFROM>
47
+ <BANKTRANLIST>
48
+ <DTSTART>20221003120000[0:GMT]
49
+ <DTEND>20221012120000[0:GMT]
50
+ <STMTTRN>
51
+ <TRNTYPE>DEBIT
52
+ <DTPOSTED>20221012120000[0:GMT]
53
+ <TRNAMT>-100.01
54
+ <FITID>202210120
55
+ <NAME>CAPITAL ONE N.A. CAPITALONE 0000
56
+ <MEMO>0234345d WEB ID: 15234563
57
+ </STMTTRN>
58
+ </BANKTRANLIST>
59
+ <LEDGERBAL>
60
+ <BALAMT>29.03
61
+ <DTASOF>20221013120000[0:GMT]
62
+ </LEDGERBAL>
63
+ <AVAILBAL>
64
+ <BALAMT>30.06
65
+ <DTASOF>20221013120000[0:GMT]
66
+ </AVAILBAL>
67
+ </STMTRS>
68
+ </STMTTRNRS>
69
+ </BANKMSGSRSV1>
70
+ </OFX>
71
+ EOS
72
+
73
+ serializer = OFX::OFX102::Serializer.new
74
+ document = serializer.from_http_response_body(body)
75
+
76
+ signon_message_set = document.message_sets[0]
77
+ signon_response = signon_message_set.responses[0]
78
+
79
+ banking_statement_message_set = document.message_sets[1]
80
+ banking_statement_response = banking_statement_message_set.responses[0]
81
+
82
+ assert_equal '123456788', banking_statement_response.account.account_identifier
83
+ assert_equal '0713456513', banking_statement_response.account.bank_identifier
84
+ assert_equal '30.06', banking_statement_response.available_balance.amount
85
+ assert_equal '29.03', banking_statement_response.ledger_balance.amount
86
+
87
+ transactions = banking_statement_response.transactions
88
+ assert_equal 1, transactions.size
89
+
90
+ transaction = transactions.first
91
+ assert_equal '-100.01', transaction.amount.to_f.to_s
92
+ assert_equal 'CAPITAL ONE N.A. CAPITALONE 0000', transaction.payee
93
+ assert_equal :debit, transaction.transaction_type
94
+ end
95
+
96
+ def test_with_newline_after_header
97
+ body =
98
+ "OFXHEADER:100
99
+ DATA:OFXSGML
100
+ VERSION:102
101
+ SECURITY:NONE
102
+ ENCODING:USASCII
103
+ CHARSET:1252
104
+ COMPRESSION:NONE
105
+ OLDFILEUID:NONE
106
+ NEWFILEUID:NONE
107
+
108
+ <OFX>
109
+ <SIGNONMSGSRSV1>
110
+ <SONRS>
111
+ <STATUS>
112
+ <CODE>0
113
+ <SEVERITY>INFO
114
+ </STATUS>
115
+ <DTSERVER>20221013120000[0:GMT]
116
+ <LANGUAGE>ENG
117
+ <FI>
118
+ <ORG>B1
119
+ <FID>10898
120
+ </FI>
121
+ <INTU.BID>10898
122
+ </SONRS>
123
+ </SIGNONMSGSRSV1>
124
+ <BANKMSGSRSV1>
125
+ <STMTTRNRS>
126
+ <TRNUID>1
127
+ <STATUS>
128
+ <CODE>0
129
+ <SEVERITY>INFO
130
+ <MESSAGE>Success
131
+ </STATUS>
132
+ <STMTRS>
133
+ <CURDEF>USD
134
+ <BANKACCTFROM>
135
+ <BANKID>0713456513
136
+ <ACCTID>123456788
137
+ <ACCTTYPE>CHECKING
138
+ </BANKACCTFROM>
139
+ <BANKTRANLIST>
140
+ <DTSTART>20221003120000[0:GMT]
141
+ <DTEND>20221012120000[0:GMT]
142
+ <STMTTRN>
143
+ <TRNTYPE>DEBIT
144
+ <DTPOSTED>20221012120000[0:GMT]
145
+ <TRNAMT>-100.01
146
+ <FITID>202210120
147
+ <NAME>CAPITAL ONE N.A. CAPITALONE 0000
148
+ <MEMO>0234345d WEB ID: 15234563
149
+ </STMTTRN>
150
+ </BANKTRANLIST>
151
+ <LEDGERBAL>
152
+ <BALAMT>29.03
153
+ <DTASOF>20221013120000[0:GMT]
154
+ </LEDGERBAL>
155
+ <AVAILBAL>
156
+ <BALAMT>30.06
157
+ <DTASOF>20221013120000[0:GMT]
158
+ </AVAILBAL>
159
+ </STMTRS>
160
+ </STMTTRNRS>
161
+ </BANKMSGSRSV1>
162
+ </OFX>"
163
+
164
+ serializer = OFX::OFX102::Serializer.new
165
+ document = serializer.from_http_response_body(body)
166
+
167
+ # require 'pp'
168
+ # pp document
169
+
170
+ signon_message_set = document.message_sets[0]
171
+ signon_response = signon_message_set.responses[0]
172
+
173
+ signon_message_set = document.message_sets[0]
174
+ signon_response = signon_message_set.responses[0]
175
+
176
+ banking_statement_message_set = document.message_sets[1]
177
+ banking_statement_response = banking_statement_message_set.responses[0]
178
+
179
+ assert_equal '123456788', banking_statement_response.account.account_identifier
180
+ assert_equal '0713456513', banking_statement_response.account.bank_identifier
181
+ assert_equal '30.06', banking_statement_response.available_balance.amount
182
+ assert_equal '29.03', banking_statement_response.ledger_balance.amount
183
+
184
+ transactions = banking_statement_response.transactions
185
+ assert_equal 1, transactions.size
186
+
187
+ transaction = transactions.first
188
+ assert_equal '-100.01', transaction.amount.to_f.to_s
189
+ assert_equal 'CAPITAL ONE N.A. CAPITALONE 0000', transaction.payee
190
+ assert_equal :debit, transaction.transaction_type
191
+ end
192
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ofx_for_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Guidry
@@ -9,62 +9,76 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-12-24 00:00:00.000000000 Z
12
+ date: 2022-10-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: racc
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - '='
33
33
  - !ruby/object:Gem::Version
34
- version: '0'
34
+ version: 1.4.6
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - '='
40
40
  - !ruby/object:Gem::Version
41
- version: '0'
41
+ version: 1.4.6
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rexical
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - '='
47
+ - !ruby/object:Gem::Version
48
+ version: 1.0.5
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '='
54
+ - !ruby/object:Gem::Version
55
+ version: 1.0.5
56
+ - !ruby/object:Gem::Dependency
57
+ name: pry
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
47
61
  - !ruby/object:Gem::Version
48
62
  version: '0'
49
63
  type: :development
50
64
  prerelease: false
51
65
  version_requirements: !ruby/object:Gem::Requirement
52
66
  requirements:
53
- - - '>='
67
+ - - ">="
54
68
  - !ruby/object:Gem::Version
55
69
  version: '0'
56
70
  - !ruby/object:Gem::Dependency
57
- name: pry
71
+ name: rake
58
72
  requirement: !ruby/object:Gem::Requirement
59
73
  requirements:
60
- - - '>='
74
+ - - ">="
61
75
  - !ruby/object:Gem::Version
62
76
  version: '0'
63
77
  type: :development
64
78
  prerelease: false
65
79
  version_requirements: !ruby/object:Gem::Requirement
66
80
  requirements:
67
- - - '>='
81
+ - - ">="
68
82
  - !ruby/object:Gem::Version
69
83
  version: '0'
70
84
  description: OFX for Ruby is a pure Ruby implementation of Open Financial Exchange
@@ -77,16 +91,17 @@ executables: []
77
91
  extensions: []
78
92
  extra_rdoc_files: []
79
93
  files:
80
- - .externalToolBuilders/Rebuild parsers.launch
81
- - .gitignore
82
- - .loadpath
83
- - .project
84
- - .ruby-version
94
+ - ".externalToolBuilders/Rebuild parsers.launch"
95
+ - ".gitignore"
96
+ - ".loadpath"
97
+ - ".project"
98
+ - ".ruby-version"
85
99
  - COPYING
86
100
  - Gemfile
87
101
  - README
88
102
  - RELEASE_NOTES
89
103
  - Rakefile
104
+ - USAGE
90
105
  - lib/ofx.rb
91
106
  - lib/ofx/1.0.2/banking_message_set.rb
92
107
  - lib/ofx/1.0.2/credit_card_statement_message_set.rb
@@ -133,6 +148,7 @@ files:
133
148
  - lib/ofx/transaction_unique_identifier.rb
134
149
  - lib/ofx/version.rb
135
150
  - lib/ofx/wire_funds_transfer_message_set.rb
151
+ - lib/ofx_for_ruby.rb
136
152
  - ofx_for_ruby.gemspec
137
153
  - planning/OFX Specification completion.ods
138
154
  - test/capital_one/capital_one_helper.rb
@@ -152,6 +168,7 @@ files:
152
168
  - test/test_helper.rb
153
169
  - test/test_ofx_version.rb
154
170
  - test/test_parser.rb
171
+ - test/test_serializer.rb
155
172
  homepage: http://github.com/baconpat/ofx_for_ruby
156
173
  licenses: []
157
174
  metadata: {}
@@ -161,35 +178,18 @@ require_paths:
161
178
  - lib
162
179
  required_ruby_version: !ruby/object:Gem::Requirement
163
180
  requirements:
164
- - - '>='
181
+ - - ">="
165
182
  - !ruby/object:Gem::Version
166
183
  version: '0'
167
184
  required_rubygems_version: !ruby/object:Gem::Requirement
168
185
  requirements:
169
- - - '>='
186
+ - - ">="
170
187
  - !ruby/object:Gem::Version
171
188
  version: '0'
172
189
  requirements: []
173
190
  rubyforge_project:
174
- rubygems_version: 2.0.3
191
+ rubygems_version: 2.6.12
175
192
  signing_key:
176
193
  specification_version: 4
177
194
  summary: Pure Ruby implementation of Open Financial Exchange specifications
178
- test_files:
179
- - test/capital_one/capital_one_helper.rb
180
- - test/capital_one/fixtures/README
181
- - test/capital_one/fixtures/fipid-5599.xml
182
- - test/capital_one/test_banking_statement.rb
183
- - test/capital_one/test_financial_institution_profile.rb
184
- - test/capital_one/test_ofx_http_client.rb
185
- - test/capital_one/test_signup_account_information.rb
186
- - test/citi/citi_helper.rb
187
- - test/citi/fixtures/README
188
- - test/citi/fixtures/fipid-6642.xml
189
- - test/citi/test_credit_card_statement.rb
190
- - test/citi/test_financial_institution_profile.rb
191
- - test/citi/test_ofx_http_client.rb
192
- - test/citi/test_signup_account_information.rb
193
- - test/test_helper.rb
194
- - test/test_ofx_version.rb
195
- - test/test_parser.rb
195
+ test_files: []