mirror of https://github.com/aclindsa/ofxgo.git
Omit end tags for encoding OFX 100-series requests
Closes https://github.com/aclindsa/ofxgo/issues/18
This commit is contained in:
parent
f41286cac7
commit
a3f4f625f7
26
bank_test.go
26
bank_test.go
|
@ -87,29 +87,29 @@ NEWFILEUID:NONE
|
|||
<OFX>
|
||||
<SIGNONMSGSRQV1>
|
||||
<SONRQ>
|
||||
<DTCLIENT>20060115112300.000[-5:EST]</DTCLIENT>
|
||||
<USERID>myusername</USERID>
|
||||
<USERPASS>Pa$$word</USERPASS>
|
||||
<LANGUAGE>ENG</LANGUAGE>
|
||||
<DTCLIENT>20060115112300.000[-5:EST]
|
||||
<USERID>myusername
|
||||
<USERPASS>Pa$$word
|
||||
<LANGUAGE>ENG
|
||||
<FI>
|
||||
<ORG>BNK</ORG>
|
||||
<FID>1987</FID>
|
||||
<ORG>BNK
|
||||
<FID>1987
|
||||
</FI>
|
||||
<APPID>OFXGO</APPID>
|
||||
<APPVER>0001</APPVER>
|
||||
<APPID>OFXGO
|
||||
<APPVER>0001
|
||||
</SONRQ>
|
||||
</SIGNONMSGSRQV1>
|
||||
<BANKMSGSRQV1>
|
||||
<STMTTRNRQ>
|
||||
<TRNUID>123</TRNUID>
|
||||
<TRNUID>123
|
||||
<STMTRQ>
|
||||
<BANKACCTFROM>
|
||||
<BANKID>318398732</BANKID>
|
||||
<ACCTID>78346129</ACCTID>
|
||||
<ACCTTYPE>CHECKING</ACCTTYPE>
|
||||
<BANKID>318398732
|
||||
<ACCTID>78346129
|
||||
<ACCTTYPE>CHECKING
|
||||
</BANKACCTFROM>
|
||||
<INCTRAN>
|
||||
<INCLUDE>Y</INCLUDE>
|
||||
<INCLUDE>Y
|
||||
</INCTRAN>
|
||||
</STMTRQ>
|
||||
</STMTTRNRQ>
|
||||
|
|
2
go.mod
2
go.mod
|
@ -1,7 +1,7 @@
|
|||
module github.com/aclindsa/ofxgo
|
||||
|
||||
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
|
||||
golang.org/x/crypto v0.0.0-20181001203147-e3636079e1a4 // 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/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/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs=
|
||||
golang.org/x/crypto v0.0.0-20181001203147-e3636079e1a4 h1:Vk3wNqEZwyGyei9yq5ekj7frek2u7HUfffJ1/opblzc=
|
||||
|
|
|
@ -172,6 +172,7 @@ var ofxLeafElements = []string{
|
|||
"IDSCOPE",
|
||||
"INCBAL",
|
||||
"INCIMAGES",
|
||||
"INCLUDE",
|
||||
"INCOMETYPE",
|
||||
"INCOO",
|
||||
"INITIALAMT",
|
||||
|
|
|
@ -85,6 +85,10 @@ func (oq *Request) Marshal() (*bytes.Buffer, error) {
|
|||
if oq.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"}}
|
||||
|
||||
|
|
|
@ -7,9 +7,11 @@ import (
|
|||
"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) {
|
||||
t.Helper()
|
||||
buf, err := request.Marshal()
|
||||
if err != nil {
|
||||
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()
|
||||
|
||||
// Ignore spaces between XML elements
|
||||
expectedString := ignoreSpacesRe.ReplaceAllString(expected, "><")
|
||||
actualString = ignoreSpacesRe.ReplaceAllString(actualString, "><")
|
||||
expectedString := ignoreSpacesRe.ReplaceAllString(expected, "")
|
||||
actualString = ignoreSpacesRe.ReplaceAllString(actualString, "")
|
||||
|
||||
if expectedString != actualString {
|
||||
compareLength := len(expectedString)
|
||||
|
|
Loading…
Reference in New Issue