mirror of
https://github.com/aclindsa/ofxgo.git
synced 2024-11-24 04:00:04 -05:00
Omit end tags for encoding OFX 100-series requests
Closes https://github.com/aclindsa/ofxgo/issues/18
This commit is contained in:
parent
66dd37781f
commit
212fdc731b
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>
|
||||
|
@ -172,6 +172,7 @@ var ofxLeafElements = []string{
|
||||
"IDSCOPE",
|
||||
"INCBAL",
|
||||
"INCIMAGES",
|
||||
"INCLUDE",
|
||||
"INCOMETYPE",
|
||||
"INCOO",
|
||||
"INITIALAMT",
|
||||
|
@ -90,6 +90,10 @@ func (oq *Request) Marshal() (*bytes.Buffer, error) {
|
||||
if oq.carriageReturn {
|
||||
encoder.CarriageReturn(true)
|
||||
}
|
||||
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,7 +7,8 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
var ignoreSpacesRe = regexp.MustCompile(">[ \t\r\n]+<")
|
||||
// match leading and trailing whitespace on each line
|
||||
var ignoreSpacesRe = regexp.MustCompile("(?m)^[ \t]+|[ \t]*$[\r\n]+")
|
||||
|
||||
func marshalCheckRequest(t *testing.T, request *ofxgo.Request, expected string) {
|
||||
t.Helper()
|
||||
@ -18,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
Block a user