-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bc0198
commit e332585
Showing
5 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<?OFX OFXHEADER="200" VERSION="211" SECURITY="NONE" OLDFILEUID="NONE" NEWFILEUID="12345678901234567890123456789012"?> | ||
<OFX> | ||
<SIGNONMSGSRSV1> | ||
<SONRS> | ||
<STATUS> | ||
<CODE>0</CODE> | ||
<SEVERITY>INFO</SEVERITY> | ||
<MESSAGE>Successful Sign On</MESSAGE> | ||
</STATUS> | ||
<DTSERVER>20230510120000</DTSERVER> | ||
<LANGUAGE>ENG</LANGUAGE> | ||
<FI> | ||
<ORG>BANK NAME</ORG> | ||
<FID>123456789</FID> | ||
</FI> | ||
</SONRS> | ||
</SIGNONMSGSRSV1> | ||
<BANKMSGSRSV1> | ||
<STMTTRNRS> | ||
<TRNUID>1000000001</TRNUID> | ||
<STATUS> | ||
<CODE>0</CODE> | ||
<SEVERITY>INFO</SEVERITY> | ||
<MESSAGE>Successful Transaction</MESSAGE> | ||
</STATUS> | ||
<STMTRS> | ||
<CURDEF>USD</CURDEF> | ||
<BANKACCTFROM> | ||
<BANKID>987654321</BANKID> | ||
<ACCTID>123456789</ACCTID> | ||
<ACCTTYPE>CHECKING</ACCTTYPE> | ||
</BANKACCTFROM> | ||
<BANKTRANLIST> | ||
<DTSTART>20230501000000</DTSTART> | ||
<DTEND>20230510000000</DTEND> | ||
<STMTTRN> | ||
<TRNTYPE>DEBIT</TRNTYPE> | ||
<DTPOSTED>20230503000000</DTPOSTED> | ||
<TRNAMT>-100.00</TRNAMT> | ||
<FITID>1000000001</FITID> | ||
<NAME>Grocery Store</NAME> | ||
</STMTTRN> | ||
<STMTTRN> | ||
<TRNTYPE>CREDIT</TRNTYPE> | ||
<DTPOSTED>20230505000000</DTPOSTED> | ||
<TRNAMT>2000.00</TRNAMT> | ||
<FITID>1000000002</FITID> | ||
<NAME>Paycheck</NAME> | ||
</STMTTRN> | ||
</BANKTRANLIST> | ||
<LEDGERBAL> | ||
<BALAMT>5000.00</BALAMT> | ||
<DTASOF>20230510000000</DTASOF> | ||
</LEDGERBAL> | ||
</STMTRS> | ||
</STMTTRNRS> | ||
</BANKMSGSRSV1> | ||
</OFX> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
module github.com/elliotcourant/gofx | ||
|
||
go 1.21.1 | ||
|
||
require github.com/stretchr/testify v1.8.4 | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package gofx | ||
|
||
import ( | ||
"embed" | ||
"path" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
//go:embed fixtures/*.xml | ||
var fixtureData embed.FS | ||
|
||
func GetFixtures(t *testing.T, name string) []byte { | ||
data, err := fixtureData.ReadFile(path.Join("fixtures", name)) | ||
require.NoError(t, err, "must be able to load fixture data for parsing") | ||
return data | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package gofx | ||
|
||
import ( | ||
"encoding/xml" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestParse(t *testing.T) { | ||
data := GetFixtures(t, "sample.xml") | ||
var ofx OFX | ||
err := xml.Unmarshal(data, &ofx) | ||
assert.NoError(t, err, "must be able to unmarshal from xml") | ||
assert.Nil(t, ofx.EMAILMSGSRSV1, "email message response should be nil") | ||
assert.NotNil(t, ofx.SIGNONMSGSRSV1, "sign on message response should not be nil") | ||
} | ||
|