ofx died 3y ago

This commit is contained in:
Bel LaPointe
2025-05-23 18:59:39 -06:00
parent e581b7835c
commit f5d82fc6aa
96 changed files with 33152 additions and 0 deletions

1
src/bank/ofx/ofx.go Normal file
View File

@@ -0,0 +1 @@
package ofx

View File

@@ -0,0 +1,87 @@
////go:build integration
package ofx_test
import (
"net/http"
"strconv"
"testing"
"time"
"github.com/aclindsa/ofxgo"
"github.com/google/uuid"
)
func TestIntegrationChaseCredit(t *testing.T) {
http.DefaultClient = &http.Client{
Timeout: time.Minute,
Transport: &http.Transport{
DisableKeepAlives: true,
},
}
client := ofxgo.BasicClient{
AppVer: "2700",
SpecVersion: 220,
}
query := ofxgo.Request{
URL: "https://ofx.chase.com",
Signon: ofxgo.SignonRequest{
Org: ofxgo.String("B1"),
Fid: ofxgo.String("10898"),
UserID: ofxgo.String("squeaky2x3"),
UserPass: ofxgo.String("ZFpdwiMzvb9ZWGTQa@"),
ClientUID: ofxgo.UID("FAACF8BA-E7E6-43F8-A76D-9CC69219DE14"),
},
Bank: []ofxgo.Message{&ofxgo.StatementRequest{
TrnUID: ofxgo.UID(uuid.New().String()),
BankAcctFrom: ofxgo.BankAcct{
BankID: ofxgo.String("14720"), // routing
AcctID: ofxgo.String("257826587"), // acc
AcctType: ofxgo.AcctTypeCreditLine, // ofxgo.AcctTypeChecking,
},
Include: true, // transactions
}},
}
response, err := client.Request(&query)
if err != nil {
t.Fatal(err)
} else if code := response.Signon.Status.Code; code != 0 {
body, _ := response.Signon.Status.CodeMeaning()
t.Fatalf("failed to sign in: (%d) %s", code, body)
}
if len(response.Bank) < 1 {
t.Fatalf("no banking messages")
}
for i, bank := range response.Bank {
i, bank := strconv.Itoa(i), bank
t.Run(i, func(t *testing.T) {
statement, ok := bank.(*ofxgo.StatementResponse)
if !ok {
t.Fatalf("not a statement response: %T", bank)
}
for j, xaction := range statement.BankTranList.Transactions {
j, xaction := strconv.Itoa(j), xaction
t.Run(j, func(t *testing.T) {
currency := statement.CurDef
if ok, _ := xaction.Currency.Valid(); ok {
currency = xaction.Currency.CurSym
}
t.Logf("%s %-15s %-11s %s%s%s\n",
xaction.DtPosted,
xaction.TrnAmt.String()+" "+currency.String(),
xaction.TrnType,
xaction.Name,
xaction.Payee.Name,
xaction.Memo,
)
t.Errorf("%+v", xaction)
})
}
})
}
}