mirror of
https://github.com/aclindsa/ofxgo.git
synced 2025-06-30 19:28:39 -04:00
Omit end tags for encoding OFX 100-series requests
Closes https://github.com/aclindsa/ofxgo/issues/18
This commit is contained in:
26
bank_test.go
26
bank_test.go
@ -87,29 +87,29 @@ NEWFILEUID:NONE
|
|||||||
<OFX>
|
<OFX>
|
||||||
<SIGNONMSGSRQV1>
|
<SIGNONMSGSRQV1>
|
||||||
<SONRQ>
|
<SONRQ>
|
||||||
<DTCLIENT>20060115112300.000[-5:EST]</DTCLIENT>
|
<DTCLIENT>20060115112300.000[-5:EST]
|
||||||
<USERID>myusername</USERID>
|
<USERID>myusername
|
||||||
<USERPASS>Pa$$word</USERPASS>
|
<USERPASS>Pa$$word
|
||||||
<LANGUAGE>ENG</LANGUAGE>
|
<LANGUAGE>ENG
|
||||||
<FI>
|
<FI>
|
||||||
<ORG>BNK</ORG>
|
<ORG>BNK
|
||||||
<FID>1987</FID>
|
<FID>1987
|
||||||
</FI>
|
</FI>
|
||||||
<APPID>OFXGO</APPID>
|
<APPID>OFXGO
|
||||||
<APPVER>0001</APPVER>
|
<APPVER>0001
|
||||||
</SONRQ>
|
</SONRQ>
|
||||||
</SIGNONMSGSRQV1>
|
</SIGNONMSGSRQV1>
|
||||||
<BANKMSGSRQV1>
|
<BANKMSGSRQV1>
|
||||||
<STMTTRNRQ>
|
<STMTTRNRQ>
|
||||||
<TRNUID>123</TRNUID>
|
<TRNUID>123
|
||||||
<STMTRQ>
|
<STMTRQ>
|
||||||
<BANKACCTFROM>
|
<BANKACCTFROM>
|
||||||
<BANKID>318398732</BANKID>
|
<BANKID>318398732
|
||||||
<ACCTID>78346129</ACCTID>
|
<ACCTID>78346129
|
||||||
<ACCTTYPE>CHECKING</ACCTTYPE>
|
<ACCTTYPE>CHECKING
|
||||||
</BANKACCTFROM>
|
</BANKACCTFROM>
|
||||||
<INCTRAN>
|
<INCTRAN>
|
||||||
<INCLUDE>Y</INCLUDE>
|
<INCLUDE>Y
|
||||||
</INCTRAN>
|
</INCTRAN>
|
||||||
</STMTRQ>
|
</STMTRQ>
|
||||||
</STMTTRNRQ>
|
</STMTTRNRQ>
|
||||||
|
2
go.mod
2
go.mod
@ -1,7 +1,7 @@
|
|||||||
module github.com/aclindsa/ofxgo
|
module github.com/aclindsa/ofxgo
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/aclindsa/xml v0.0.0-20171002130543-5d4402bb4a20
|
github.com/aclindsa/xml v0.0.0-20190614100215-564dc705a222
|
||||||
github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c
|
github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c
|
||||||
golang.org/x/crypto v0.0.0-20181001203147-e3636079e1a4 // indirect
|
golang.org/x/crypto v0.0.0-20181001203147-e3636079e1a4 // indirect
|
||||||
golang.org/x/sys v0.0.0-20180928133829-e4b3c5e90611 // indirect
|
golang.org/x/sys v0.0.0-20180928133829-e4b3c5e90611 // indirect
|
||||||
|
2
go.sum
2
go.sum
@ -1,5 +1,7 @@
|
|||||||
github.com/aclindsa/xml v0.0.0-20171002130543-5d4402bb4a20 h1:wN3KlzWq56AIgOqFzYLYVih4zVyPDViCUeG5uZxJHq4=
|
github.com/aclindsa/xml v0.0.0-20171002130543-5d4402bb4a20 h1:wN3KlzWq56AIgOqFzYLYVih4zVyPDViCUeG5uZxJHq4=
|
||||||
github.com/aclindsa/xml v0.0.0-20171002130543-5d4402bb4a20/go.mod h1:DiEHtTD+e6zS3+R95F05Bfbcsfv13wZTi2M4LfAFLBE=
|
github.com/aclindsa/xml v0.0.0-20171002130543-5d4402bb4a20/go.mod h1:DiEHtTD+e6zS3+R95F05Bfbcsfv13wZTi2M4LfAFLBE=
|
||||||
|
github.com/aclindsa/xml v0.0.0-20190614100215-564dc705a222 h1:KF5DYtOrl6QZ/vlVZPzHGRr7xLakO8Ye0I+JoiV3PNg=
|
||||||
|
github.com/aclindsa/xml v0.0.0-20190614100215-564dc705a222/go.mod h1:GjqOUT8xlg5+T19lFv6yAGNrtMKkZ839Gt4e16mBXlY=
|
||||||
github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c h1:kQWxfPIHVLbgLzphqk3QUflDy9QdksZR4ygR807bpy0=
|
github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c h1:kQWxfPIHVLbgLzphqk3QUflDy9QdksZR4ygR807bpy0=
|
||||||
github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs=
|
github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs=
|
||||||
golang.org/x/crypto v0.0.0-20181001203147-e3636079e1a4 h1:Vk3wNqEZwyGyei9yq5ekj7frek2u7HUfffJ1/opblzc=
|
golang.org/x/crypto v0.0.0-20181001203147-e3636079e1a4 h1:Vk3wNqEZwyGyei9yq5ekj7frek2u7HUfffJ1/opblzc=
|
||||||
|
@ -172,6 +172,7 @@ var ofxLeafElements = []string{
|
|||||||
"IDSCOPE",
|
"IDSCOPE",
|
||||||
"INCBAL",
|
"INCBAL",
|
||||||
"INCIMAGES",
|
"INCIMAGES",
|
||||||
|
"INCLUDE",
|
||||||
"INCOMETYPE",
|
"INCOMETYPE",
|
||||||
"INCOO",
|
"INCOO",
|
||||||
"INITIALAMT",
|
"INITIALAMT",
|
||||||
|
@ -85,6 +85,10 @@ func (oq *Request) Marshal() (*bytes.Buffer, error) {
|
|||||||
if oq.indent {
|
if oq.indent {
|
||||||
encoder.Indent("", " ")
|
encoder.Indent("", " ")
|
||||||
}
|
}
|
||||||
|
if oq.Version < OfxVersion200 {
|
||||||
|
// OFX 100 series versions should avoid element close tags for compatibility
|
||||||
|
encoder.SetDisableAutoClose(ofxLeafElements...)
|
||||||
|
}
|
||||||
|
|
||||||
ofxElement := xml.StartElement{Name: xml.Name{Local: "OFX"}}
|
ofxElement := xml.StartElement{Name: xml.Name{Local: "OFX"}}
|
||||||
|
|
||||||
|
@ -7,9 +7,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ignoreSpacesRe = regexp.MustCompile(">[ \t\r\n]+<")
|
// match leading and trailing whitespace on each line
|
||||||
|
var ignoreSpacesRe = regexp.MustCompile("(?m)^[ \t]+|$[\r\n]+")
|
||||||
|
|
||||||
func marshalCheckRequest(t *testing.T, request *ofxgo.Request, expected string) {
|
func marshalCheckRequest(t *testing.T, request *ofxgo.Request, expected string) {
|
||||||
|
t.Helper()
|
||||||
buf, err := request.Marshal()
|
buf, err := request.Marshal()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("%s: Unexpected error marshalling request: %s\n", t.Name(), err)
|
t.Fatalf("%s: Unexpected error marshalling request: %s\n", t.Name(), err)
|
||||||
@ -17,8 +19,8 @@ func marshalCheckRequest(t *testing.T, request *ofxgo.Request, expected string)
|
|||||||
actualString := buf.String()
|
actualString := buf.String()
|
||||||
|
|
||||||
// Ignore spaces between XML elements
|
// Ignore spaces between XML elements
|
||||||
expectedString := ignoreSpacesRe.ReplaceAllString(expected, "><")
|
expectedString := ignoreSpacesRe.ReplaceAllString(expected, "")
|
||||||
actualString = ignoreSpacesRe.ReplaceAllString(actualString, "><")
|
actualString = ignoreSpacesRe.ReplaceAllString(actualString, "")
|
||||||
|
|
||||||
if expectedString != actualString {
|
if expectedString != actualString {
|
||||||
compareLength := len(expectedString)
|
compareLength := len(expectedString)
|
||||||
|
Reference in New Issue
Block a user