Make example compile

This commit is contained in:
Nick Snyder 2018-04-14 09:06:32 -04:00 committed by GitHub
parent 06de7e2af6
commit 2fbb276a22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 11 deletions

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
var currency ofxgo.CurrSymbol
if ok, _ := tran.Currency.Valid(); ok {
currency = tran.Currency.CurSym
}