Class: OFX::OFX102::Serializer
- Inherits:
-
Object
- Object
- OFX::OFX102::Serializer
- Defined in:
- lib/ofx/1.0.2/serializer.rb
Instance Method Summary collapse
Instance Method Details
#from_http_response_body(body) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/ofx/1.0.2/serializer.rb', line 57 def from_http_response_body(body) # puts "Raw response:\n#{body}" #header_pattern = /(\w+\:.*\n)+\n/ header_pattern = /(\w+\:.*\r*\n)+\r*\n/ header_match = header_pattern.match(body) if header_match.nil? raise NotImplementedError, "OFX server returned unmatched ASCII" return body end body = header_match.post_match header = Header.from_ofx_102_s(header_match[0].strip) parser = OFX::OFX102::Parser.new parser.scan_str body if parser.documents.length > 1 raise NotImplementedError, "Multiple response documents" end # require 'pp' # pp parser.ofx_hashes[0] document = parser.documents[0] document.header = header document end |
#to_http_post_body(document) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ofx/1.0.2/serializer.rb', line 41 def to_http_post_body(document) body = "" body += document.header.to_ofx_102_s body += "\n" body += "<OFX>\n" document..each do || body += .to_ofx_102_s end body += "</OFX>\n" # puts body body end |