ofx-data 0.2.4 → 0.3.0
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.
- checksums.yaml +4 -4
- data/lib/ofx/data/banking/transaction.rb +1 -0
- data/lib/ofx/data/declaration.rb +4 -2
- data/lib/ofx/data/serialization/document.rb +2 -46
- data/lib/ofx/data/serialization/document/sgml.rb +84 -0
- data/lib/ofx/data/serialization/document/xml.rb +48 -0
- data/lib/ofx/data/serialization/ofx102.rb +38 -0
- data/lib/ofx/data/serialization/ofx203.rb +1 -1
- data/lib/ofx/data/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f486a042e7de701a31e4e273df30279f3dec571
|
4
|
+
data.tar.gz: 9caa33a6385589f1fa13c58755142a726077da75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9af406ea33317f3193283d9f46351d1f4a2625c390b590ec4ffd55cf004c3d7431a8dca5223472b650e11e957f1d7057b5f51636a12b1af8234686a077abe6a5
|
7
|
+
data.tar.gz: d70724569ee5e327711b79998a2a3d01c6a5577e7a95289c5a0e12902365680c4d4ae3add1cf548a4fa6074bfb8db3f59f2f7ce9ec42f4367fd9e4c32ad3e3c4
|
@@ -37,6 +37,7 @@ module OFX
|
|
37
37
|
@payee_id = opts.fetch(:payee_id, nil)
|
38
38
|
raise ArgumentError, ":payee_id must be 1-12 characters long" if @payee_id && @payee_id.length > 12
|
39
39
|
@memo = opts.fetch(:memo, nil)
|
40
|
+
raise ArgumentError, ":memo must be 1-255 characters long" if @memo && @memo.length > 255
|
40
41
|
end
|
41
42
|
|
42
43
|
def ofx_type
|
data/lib/ofx/data/declaration.rb
CHANGED
@@ -2,7 +2,8 @@ module OFX
|
|
2
2
|
module Data
|
3
3
|
class Declaration
|
4
4
|
DEFAULTS = {
|
5
|
-
:"2.0.3" => {ofxheader: "200", version: "203"}
|
5
|
+
:"2.0.3" => {ofxheader: "200", version: "203"},
|
6
|
+
:"1.0.2" => {ofxheader: "100", version: "102"}
|
6
7
|
}
|
7
8
|
|
8
9
|
def self.[](key)
|
@@ -13,12 +14,13 @@ module OFX
|
|
13
14
|
self[:"2.0.3"]
|
14
15
|
end
|
15
16
|
|
16
|
-
attr_reader :ofxheader, :version, :security, :oldfileuid, :newfileuid
|
17
|
+
attr_reader :ofxheader, :version, :security, :encoding, :oldfileuid, :newfileuid
|
17
18
|
|
18
19
|
def initialize(opts)
|
19
20
|
@ofxheader = opts.fetch(:ofxheader, "NONE")
|
20
21
|
@version = opts.fetch(:version, "NONE")
|
21
22
|
@security = opts.fetch(:security, "NONE")
|
23
|
+
@encoding = opts.fetch(:encoding, "UTF-8")
|
22
24
|
@oldfileuid = opts.fetch(:oldfileuid, "NONE")
|
23
25
|
@newfileuid = opts.fetch(:newfileuid, "NONE")
|
24
26
|
end
|
@@ -1,46 +1,2 @@
|
|
1
|
-
require "ofx/data/serialization"
|
2
|
-
require "ofx/data/serialization/
|
3
|
-
|
4
|
-
module OFX
|
5
|
-
module Data
|
6
|
-
module Serialization
|
7
|
-
class Document
|
8
|
-
include Common
|
9
|
-
|
10
|
-
def self.register_with(registry)
|
11
|
-
serializer = new(registry)
|
12
|
-
registry.register(serializer.registry_entry)
|
13
|
-
end
|
14
|
-
|
15
|
-
attr_reader :registry
|
16
|
-
|
17
|
-
def initialize(registry)
|
18
|
-
@registry = registry
|
19
|
-
end
|
20
|
-
|
21
|
-
def default_registry_entry_args
|
22
|
-
[:document, nil]
|
23
|
-
end
|
24
|
-
|
25
|
-
def registry_entry
|
26
|
-
Registry::Entry.new(self, *default_registry_entry_args)
|
27
|
-
end
|
28
|
-
|
29
|
-
def serialize(document, builder)
|
30
|
-
decl = document.declaration
|
31
|
-
builder.instruct!
|
32
|
-
builder.instruct!(:OFX, {
|
33
|
-
OFXHEADER: decl.ofxheader,
|
34
|
-
VERSION: decl.version,
|
35
|
-
SECURITY: decl.security,
|
36
|
-
OLDFILEUID: decl.oldfileuid,
|
37
|
-
NEWFILEUID: decl.newfileuid
|
38
|
-
})
|
39
|
-
builder.OFX do |builder|
|
40
|
-
serialize_object(document.message_sets, builder)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
1
|
+
require "ofx/data/serialization/document/xml"
|
2
|
+
require "ofx/data/serialization/document/sgml"
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require "ofx/data/serialization/common"
|
2
|
+
|
3
|
+
module OFX
|
4
|
+
module Data
|
5
|
+
module Serialization
|
6
|
+
module Document
|
7
|
+
class SGML
|
8
|
+
include Common
|
9
|
+
|
10
|
+
def self.register_with(registry)
|
11
|
+
serializer = new(registry)
|
12
|
+
registry.register(serializer.registry_entry)
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :registry
|
16
|
+
|
17
|
+
def initialize(registry)
|
18
|
+
@registry = registry
|
19
|
+
end
|
20
|
+
|
21
|
+
def default_registry_entry_args
|
22
|
+
[:document, nil]
|
23
|
+
end
|
24
|
+
|
25
|
+
def registry_entry
|
26
|
+
Registry::Entry.new(self, *default_registry_entry_args)
|
27
|
+
end
|
28
|
+
|
29
|
+
def serialize(document, builder)
|
30
|
+
write_headers(builder, document.declaration)
|
31
|
+
builder.OFX do |builder|
|
32
|
+
serialize_object(document.message_sets, builder)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def write_headers(builder, declaration)
|
39
|
+
{
|
40
|
+
OFXHEADER: declaration.ofxheader,
|
41
|
+
DATA: "OFXSGML",
|
42
|
+
VERSION: declaration.version,
|
43
|
+
SECURITY: declaration.security,
|
44
|
+
ENCODING: encoding(declaration),
|
45
|
+
CHARSET: charset(declaration),
|
46
|
+
COMPRESSION: "NONE",
|
47
|
+
OLDFILEUID: declaration.oldfileuid,
|
48
|
+
NEWFILEUID: declaration.newfileuid
|
49
|
+
}.each do |name, value|
|
50
|
+
write_header(builder, name, value)
|
51
|
+
end
|
52
|
+
builder << "\r\n"
|
53
|
+
end
|
54
|
+
|
55
|
+
def write_header(builder, name, value)
|
56
|
+
builder << "#{name}:#{value}\r\n"
|
57
|
+
end
|
58
|
+
|
59
|
+
def encoding(declaration)
|
60
|
+
case Encoding.find(declaration.encoding)
|
61
|
+
when Encoding::UTF_8
|
62
|
+
"UTF-8"
|
63
|
+
else
|
64
|
+
"USASCII"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def charset(declaration)
|
69
|
+
case Encoding.find(declaration.encoding)
|
70
|
+
when Encoding::UTF_8
|
71
|
+
"NONE"
|
72
|
+
when Encoding::Windows_1252
|
73
|
+
"1252"
|
74
|
+
when Encoding::ISO_8859_1
|
75
|
+
"ISO-8859-1"
|
76
|
+
else
|
77
|
+
raise ArgumentError, "Declaration encoding (#{declaration.encoding}) is not one of (or equivalent to) UTF-8, ISO-8859-1, or Windows-1252"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "ofx/data/serialization"
|
2
|
+
require "ofx/data/serialization/common"
|
3
|
+
|
4
|
+
module OFX
|
5
|
+
module Data
|
6
|
+
module Serialization
|
7
|
+
module Document
|
8
|
+
class XML
|
9
|
+
include Common
|
10
|
+
|
11
|
+
def self.register_with(registry)
|
12
|
+
serializer = new(registry)
|
13
|
+
registry.register(serializer.registry_entry)
|
14
|
+
end
|
15
|
+
|
16
|
+
attr_reader :registry
|
17
|
+
|
18
|
+
def initialize(registry)
|
19
|
+
@registry = registry
|
20
|
+
end
|
21
|
+
|
22
|
+
def default_registry_entry_args
|
23
|
+
[:document, nil]
|
24
|
+
end
|
25
|
+
|
26
|
+
def registry_entry
|
27
|
+
Registry::Entry.new(self, *default_registry_entry_args)
|
28
|
+
end
|
29
|
+
|
30
|
+
def serialize(document, builder)
|
31
|
+
decl = document.declaration
|
32
|
+
builder.instruct!
|
33
|
+
builder.instruct!(:OFX, {
|
34
|
+
OFXHEADER: decl.ofxheader,
|
35
|
+
VERSION: decl.version,
|
36
|
+
SECURITY: decl.security,
|
37
|
+
OLDFILEUID: decl.oldfileuid,
|
38
|
+
NEWFILEUID: decl.newfileuid
|
39
|
+
})
|
40
|
+
builder.OFX do |builder|
|
41
|
+
serialize_object(document.message_sets, builder)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "builder"
|
2
|
+
require "ofx/data/serialization/registry"
|
3
|
+
require "ofx/data/serialization"
|
4
|
+
|
5
|
+
module OFX
|
6
|
+
module Data
|
7
|
+
module Serialization
|
8
|
+
module OFX102
|
9
|
+
SERIALIZER_CLASSES = [
|
10
|
+
Document::SGML, Transaction::Status,
|
11
|
+
MessageSets, MessageSets::Banking::Response,
|
12
|
+
MessageSets::Signon::Response, Signon::Response,
|
13
|
+
Banking::Balance, Banking::BankAccount,
|
14
|
+
Banking::Transaction, Banking::Statement::Response,
|
15
|
+
Banking::Statement::Transaction::Response
|
16
|
+
]
|
17
|
+
|
18
|
+
def self.registry
|
19
|
+
Registry.build { |r|
|
20
|
+
SERIALIZER_CLASSES.each do |klass|
|
21
|
+
klass.register_with(r)
|
22
|
+
end
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.builder
|
27
|
+
Builder::XmlMarkup.new
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.serialize(object)
|
31
|
+
output = builder
|
32
|
+
registry.serializer_for(object.ofx_type).serialize(object, output)
|
33
|
+
output.target!
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -7,7 +7,7 @@ module OFX
|
|
7
7
|
module Serialization
|
8
8
|
module OFX203
|
9
9
|
SERIALIZER_CLASSES = [
|
10
|
-
Document, Transaction::Status,
|
10
|
+
Document::XML, Transaction::Status,
|
11
11
|
MessageSets, MessageSets::Banking::Response,
|
12
12
|
MessageSets::Signon::Response, Signon::Response,
|
13
13
|
Banking::Balance, Banking::BankAccount,
|
data/lib/ofx/data/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ofx-data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Patterson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
@@ -124,9 +124,12 @@ files:
|
|
124
124
|
- lib/ofx/data/serialization/banking/transaction.rb
|
125
125
|
- lib/ofx/data/serialization/common.rb
|
126
126
|
- lib/ofx/data/serialization/document.rb
|
127
|
+
- lib/ofx/data/serialization/document/sgml.rb
|
128
|
+
- lib/ofx/data/serialization/document/xml.rb
|
127
129
|
- lib/ofx/data/serialization/message_sets.rb
|
128
130
|
- lib/ofx/data/serialization/message_sets/banking.rb
|
129
131
|
- lib/ofx/data/serialization/message_sets/signon.rb
|
132
|
+
- lib/ofx/data/serialization/ofx102.rb
|
130
133
|
- lib/ofx/data/serialization/ofx203.rb
|
131
134
|
- lib/ofx/data/serialization/registry.rb
|
132
135
|
- lib/ofx/data/serialization/registry/entry.rb
|