mirror of
https://github.com/aclindsa/ofxgo.git
synced 2025-07-01 19:58:37 -04:00
Generalize response parsing code
This removes the many decodeXXXMessageSet() functions and replaces them with a large map and a single generic decodeMessageSet() function. Also change Responses to satisfy the Message interface as pointer types (instead of the raw types), add the full set of top-level message sets (though most of them still lack any message-parsing ability), adjust the message set names to more closely mirror their OFX names, and fixup tests and the command-line client to match the above changes.
This commit is contained in:
@ -36,7 +36,7 @@ func ccTransactions() {
|
||||
},
|
||||
Include: true,
|
||||
}
|
||||
query.CreditCards = append(query.CreditCards, &statementRequest)
|
||||
query.CreditCard = append(query.CreditCard, &statementRequest)
|
||||
|
||||
response, err := client.Request(query)
|
||||
if err != nil {
|
||||
@ -50,12 +50,12 @@ func ccTransactions() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(response.CreditCards) < 1 {
|
||||
if len(response.CreditCard) < 1 {
|
||||
fmt.Println("No banking messages received")
|
||||
return
|
||||
}
|
||||
|
||||
if stmt, ok := response.CreditCards[0].(ofxgo.CCStatementResponse); ok {
|
||||
if stmt, ok := response.CreditCard[0].(*ofxgo.CCStatementResponse); ok {
|
||||
fmt.Printf("Balance: %s %s (as of %s)\n", stmt.BalAmt, stmt.CurDef, stmt.DtAsOf)
|
||||
fmt.Println("Transactions:")
|
||||
for _, tran := range stmt.BankTranList.Transactions {
|
||||
|
Reference in New Issue
Block a user