mirror of
https://github.com/aclindsa/ofxgo.git
synced 2025-06-13 21:48:38 -04:00
Use named constants instead of strings for enum-like OFX fields
This adds a python script to generate constants.go when `go generate` is called, and updates the structs, tests, and command-line client to all use the new named constants.
This commit is contained in:
@ -40,6 +40,12 @@ func downloadCheckFlags() bool {
|
||||
func download() {
|
||||
client, query := NewRequest()
|
||||
|
||||
acctTypeEnum, err := ofxgo.NewAcctType(acctType)
|
||||
if err != nil {
|
||||
fmt.Println("Error parsing accttype:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
uid, err := ofxgo.RandomUID()
|
||||
if err != nil {
|
||||
fmt.Println("Error creating uid for transaction:", err)
|
||||
@ -51,10 +57,11 @@ func download() {
|
||||
BankAcctFrom: ofxgo.BankAcct{
|
||||
BankId: ofxgo.String(bankId),
|
||||
AcctId: ofxgo.String(acctId),
|
||||
AcctType: ofxgo.String(acctType),
|
||||
AcctType: acctTypeEnum,
|
||||
},
|
||||
Include: true,
|
||||
}
|
||||
|
||||
query.Bank = append(query.Bank, &statementRequest)
|
||||
|
||||
response, err := client.RequestNoParse(query)
|
||||
|
@ -25,6 +25,12 @@ func init() {
|
||||
func bankTransactions() {
|
||||
client, query := NewRequest()
|
||||
|
||||
acctTypeEnum, err := ofxgo.NewAcctType(acctType)
|
||||
if err != nil {
|
||||
fmt.Println("Error parsing accttype:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
uid, err := ofxgo.RandomUID()
|
||||
if err != nil {
|
||||
fmt.Println("Error creating uid for transaction:", err)
|
||||
@ -36,10 +42,11 @@ func bankTransactions() {
|
||||
BankAcctFrom: ofxgo.BankAcct{
|
||||
BankId: ofxgo.String(bankId),
|
||||
AcctId: ofxgo.String(acctId),
|
||||
AcctType: ofxgo.String(acctType),
|
||||
AcctType: acctTypeEnum,
|
||||
},
|
||||
Include: true,
|
||||
}
|
||||
|
||||
query.Bank = append(query.Bank, &statementRequest)
|
||||
|
||||
response, err := client.Request(query)
|
||||
|
Reference in New Issue
Block a user