Class: OFX::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/ofx/header.rb,
lib/ofx/1.0.2/header.rb

Overview

Summary

The OFX headers for one message. The headers provide metadata about the OFX request/response, including message versioning, security, and encoding.

Specifications

OFX 1.0.2

2.2 (pp. 12-14)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHeader

Returns a new instance of Header.



29
30
31
# File 'lib/ofx/header.rb', line 29

def initialize
    @headers = {}
end

Class Method Details

.from_ofx_102_s(header_string) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ofx/1.0.2/header.rb', line 36

def self.from_ofx_102_s(header_string)
    header = OFX::Header.new

    header_pattern = /^(\w+)\:(.*)$/
    header_string.split(%r{\r*\n}).each do |this_header|
        header_match = header_pattern.match(this_header)
        header[header_match[1]] = header_match[2]
   end
    
    header
end

Instance Method Details

#[](key) ⇒ Object



33
34
35
# File 'lib/ofx/header.rb', line 33

def [](key)
    @headers[key]
end

#[]=(key, value) ⇒ Object



37
38
39
# File 'lib/ofx/header.rb', line 37

def []=(key, value)
    @headers[key] = value
end

#compressionObject

OFX 1.0.2

2.2.6



92
93
94
# File 'lib/ofx/header.rb', line 92

def compression
    @headers['COMPRESSION']
end

#compression=(value) ⇒ Object



95
96
97
# File 'lib/ofx/header.rb', line 95

def compression=(value)
    @headers['COMPRESSION'] = value
end

#content_character_setObject

OFX 1.0.2

2.2.5



84
85
86
# File 'lib/ofx/header.rb', line 84

def content_character_set
    @headers['CHARSET']
end

#content_character_set=(value) ⇒ Object



87
88
89
# File 'lib/ofx/header.rb', line 87

def content_character_set=(value)
    @headers['CHARSET'] = value
end

#content_encodingObject

OFX 1.0.2

2.2.5



76
77
78
# File 'lib/ofx/header.rb', line 76

def content_encoding
    @headers['ENCODING']
end

#content_encoding=(value) ⇒ Object



79
80
81
# File 'lib/ofx/header.rb', line 79

def content_encoding=(value)
    @headers['ENCODING'] = value
end

#content_typeObject

OFX 1.0.2

2.2.2



52
53
54
# File 'lib/ofx/header.rb', line 52

def content_type
    @headers['DATA']
end

#content_type=(value) ⇒ Object



55
56
57
# File 'lib/ofx/header.rb', line 55

def content_type=(value)
    @headers['DATA'] = value
end

#document_versionObject

OFX 1.0.2

2.2.3



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

def document_version
    OFX::Version.new(@headers['VERSION'])
end

#document_version=(value) ⇒ Object



63
64
65
# File 'lib/ofx/header.rb', line 63

def document_version=(value)
    @headers['VERSION'] = value
end

#header_versionObject

The version of this OFX header

OFX 1.0.2

2.2.1

OFX 1.0.3

2.2.1



44
45
46
# File 'lib/ofx/header.rb', line 44

def header_version
    OFX::Version.new(@headers['OFXHEADER'])
end

#header_version=(value) ⇒ Object



47
48
49
# File 'lib/ofx/header.rb', line 47

def header_version=(value)
    @headers['OFXHEADER'] = value
end

#previous_unique_identifierObject

OFX 1.0.2

2.2.7



108
109
110
# File 'lib/ofx/header.rb', line 108

def previous_unique_identifier
    @headers['OLDFILEUID']
end

#previous_unique_identifier=(value) ⇒ Object



111
112
113
# File 'lib/ofx/header.rb', line 111

def previous_unique_identifier=(value)
    @headers['OLDFILEUID'] = value
end

#securityObject

OFX 1.0.2

2.2.4



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

def security
    @headers['SECURITY']
end

#security=(value) ⇒ Object



71
72
73
# File 'lib/ofx/header.rb', line 71

def security=(value)
    @headers['SECURITY'] = value
end

#to_ofx_102_sObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ofx/1.0.2/header.rb', line 20

def to_ofx_102_s
    headers = ""

    headers += "OFXHEADER:" + self.header_version.to_compact_s + "\n"
    headers += "DATA:" + self.content_type.to_s + "\n"
    headers += "VERSION:" + self.document_version.to_compact_s + "\n"
    headers += "SECURITY:" + self.security.to_s + "\n"
    headers += "ENCODING:" + self.content_encoding.to_s + "\n"
    headers += "CHARSET:" + self.content_character_set.to_s + "\n"
    headers += "COMPRESSION:" + self.compression.to_s + "\n"
    headers += "OLDFILEUID:" + self.previous_unique_identifier.to_s + "\n"
    headers += "NEWFILEUID:" + self.unique_identifier.to_s + "\n"

    headers
end

#unique_identifierObject

OFX 1.0.2

2.2.7



100
101
102
# File 'lib/ofx/header.rb', line 100

def unique_identifier
    @headers['NEWFILEUID']
end

#unique_identifier=(value) ⇒ Object



103
104
105
# File 'lib/ofx/header.rb', line 103

def unique_identifier=(value)
    @headers['NEWFILEUID'] = value
end