1
0
mirror of https://github.com/aclindsa/ofxgo.git synced 2024-12-26 06:53:21 -05:00

Merge pull request #5 from nicksnyder/patch-1

Make README example compile
This commit is contained in:
Aaron Lindsay 2018-04-15 07:21:52 -04:00 committed by GitHub
commit c6a806399a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,32 +44,32 @@ The following code snippet demonstrates how to use OFXGo to query and parse
OFX code from a checking account, printing the balance and returned transactions:
```go
client := ofxgo.Client{} # Accept the default Client settings
client := ofxgo.Client{} // Accept the default Client settings
# These values are specific to your bank
// These values are specific to your bank
var query ofxgo.Request
query.URL = "https://secu.example.com/ofx"
query.Signon.Org = ofxgo.String("SECU")
query.Signon.Fid = ofxgo.String("1234")
# Set your username/password
// Set your username/password
query.Signon.UserID = ofxgo.String("username")
query.Signon.UserPass = ofxgo.String("hunter2")
uid, _ := ofxgo.RandomUID() # Handle error in real code
query.Bank = append(query.bank, &ofxgo.StatementRequest{
uid, _ := ofxgo.RandomUID() // Handle error in real code
query.Bank = append(query.Bank, &ofxgo.StatementRequest{
TrnUID: *uid,
BankAcctFrom: ofxgo.BankAcct{
BankID: ofxgo.String("123456789"), # Possibly your routing number
AcctID: ofxgo.String("00011122233"), # Possibly your account number
BankID: ofxgo.String("123456789"), // Possibly your routing number
AcctID: ofxgo.String("00011122233"), // Possibly your account number
AcctType: ofxgo.AcctTypeChecking,
},
Include: true, # Include transactions (instead of only balance information)
Include: true, // Include transactions (instead of only balance information)
})
response, _ := client.Request(query) # Handle error in real code
response, _ := client.Request(&query) // Handle error in real code
# Was there an OFX error while processing our request?
// Was there an OFX error while processing our request?
if response.Signon.Status.Code != 0 {
meaning, _ := response.Signon.Status.CodeMeaning()
fmt.Printf("Nonzero signon status (%d: %s) with message: %s\n", response.Signon.Status.Code, meaning, response.Signon.Status.Message)
@ -85,7 +85,7 @@ if stmt, ok := response.Bank[0].(*ofxgo.StatementResponse); 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 {
currency := defCurrency
currency := stmt.CurDef
if ok, _ := tran.Currency.Valid(); ok {
currency = tran.Currency.CurSym
}