1
0
mirror of https://github.com/aclindsa/ofxgo.git synced 2025-07-01 19:58:37 -04:00

Support carriage returns on new lines

This commit is contained in:
John Starich
2019-06-14 00:40:22 -05:00
committed by Aaron Lindsay
parent f41286cac7
commit 67e527c855
8 changed files with 39 additions and 9 deletions

View File

@ -31,7 +31,8 @@ type Request struct {
Prof []Message //<PROFMSGSETV1>
Image []Message //<IMAGEMSGSETV1>
indent bool // Whether to indent the marshaled XML
indent bool // Whether to indent the marshaled XML
carriageReturn bool // Whether to user carriage returns in new lines for marshaled XML
}
func encodeMessageSet(e *xml.Encoder, requests []Message, set messageType, version ofxVersion) error {
@ -70,6 +71,7 @@ func (oq *Request) SetClientFields(c Client) {
oq.Signon.AppID = c.ID()
oq.Signon.AppVer = c.Version()
oq.indent = c.IndentRequests()
oq.carriageReturn = c.CarriageReturnNewLines()
}
// Marshal this Request into its SGML/XML representation held in a bytes.Buffer
@ -79,12 +81,15 @@ func (oq *Request) Marshal() (*bytes.Buffer, error) {
var b bytes.Buffer
// Write the header appropriate to our version
writeHeader(&b, oq.Version)
writeHeader(&b, oq.Version, oq.carriageReturn)
encoder := xml.NewEncoder(&b)
if oq.indent {
encoder.Indent("", " ")
}
if oq.carriageReturn {
encoder.CarriageReturn(true)
}
ofxElement := xml.StartElement{Name: xml.Name{Local: "OFX"}}