From c1777df3df432048e95ec495b2782dac2f59d9fb Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Thu, 30 Mar 2017 10:24:26 -0400 Subject: [PATCH] Standardize transaction wrapper fields --- banking.go | 15 ++++++++++----- cmd/ofx/get_accounts.go | 5 ++--- creditcards.go | 27 ++++++++++++++++----------- investments.go | 2 +- profile.go | 19 ++++++++++++------- securities.go | 10 ++++++---- signup.go | 14 +++++++++----- 7 files changed, 56 insertions(+), 36 deletions(-) diff --git a/banking.go b/banking.go index 99909ad..49ab8e4 100644 --- a/banking.go +++ b/banking.go @@ -6,8 +6,11 @@ import ( ) type StatementRequest struct { - XMLName xml.Name `xml:"STMTTRNRQ"` - TrnUID UID `xml:"TRNUID"` + XMLName xml.Name `xml:"STMTTRNRQ"` + TrnUID UID `xml:"TRNUID"` + CltCookie String `xml:"CLTCOOKIE,omitempty"` + TAN String `xml:"TAN,omitempty"` // Transaction authorization number + // TODO `xml:"OFXEXTENSION,omitempty"` BankAcctFrom BankAcct `xml:"STMTRQ>BANKACCTFROM"` DtStart *Date `xml:"STMTRQ>INCTRAN>DTSTART,omitempty"` DtEnd *Date `xml:"STMTRQ>INCTRAN>DTEND,omitempty"` @@ -124,9 +127,11 @@ type Balance struct { } type StatementResponse struct { - XMLName xml.Name `xml:"STMTTRNRS"` - TrnUID UID `xml:"TRNUID"` - Status Status `xml:"STATUS"` + XMLName xml.Name `xml:"STMTTRNRS"` + TrnUID UID `xml:"TRNUID"` + Status Status `xml:"STATUS"` + CltCookie String `xml:"CLTCOOKIE,omitempty"` + // TODO `xml:"OFXEXTENSION,omitempty"` CurDef String `xml:"STMTRS>CURDEF"` BankAcctFrom BankAcct `xml:"STMTRS>BANKACCTFROM"` BankTranList *TransactionList `xml:"STMTRS>BANKTRANLIST,omitempty"` diff --git a/cmd/ofx/get_accounts.go b/cmd/ofx/get_accounts.go index 1b99ef4..34bb796 100644 --- a/cmd/ofx/get_accounts.go +++ b/cmd/ofx/get_accounts.go @@ -30,9 +30,8 @@ func getAccounts() { } acctInfo := ofxgo.AcctInfoRequest{ - TrnUID: *uid, - DtAcctUp: ofxgo.Date(time.Unix(0, 0)), - CltCookie: 1, + TrnUID: *uid, + DtAcctUp: ofxgo.Date(time.Unix(0, 0)), } query.Signup = append(query.Signup, &acctInfo) diff --git a/creditcards.go b/creditcards.go index 913c3e6..77e3f09 100644 --- a/creditcards.go +++ b/creditcards.go @@ -6,14 +6,17 @@ import ( ) type CCStatementRequest struct { - XMLName xml.Name `xml:"CCSTMTTRNRQ"` - TrnUID UID `xml:"TRNUID"` - CCAcctFrom CCAcct `xml:"CCSTMTRQ>CCACCTFROM"` - DtStart *Date `xml:"CCSTMTRQ>INCTRAN>DTSTART,omitempty"` - DtEnd *Date `xml:"CCSTMTRQ>INCTRAN>DTEND,omitempty"` - Include Boolean `xml:"CCSTMTRQ>INCTRAN>INCLUDE"` // Include transactions (instead of just balance) - IncludePending Boolean `xml:"CCSTMTRQ>INCLUDEPENDING,omitempty"` // Include pending transactions - IncTranImg Boolean `xml:"CCSTMTRQ>INCTRANIMG,omitempty"` // Include transaction images + XMLName xml.Name `xml:"CCSTMTTRNRQ"` + TrnUID UID `xml:"TRNUID"` + CltCookie String `xml:"CLTCOOKIE,omitempty"` + TAN String `xml:"TAN,omitempty"` + // TODO OFXEXTENSION + CCAcctFrom CCAcct `xml:"CCSTMTRQ>CCACCTFROM"` + DtStart *Date `xml:"CCSTMTRQ>INCTRAN>DTSTART,omitempty"` + DtEnd *Date `xml:"CCSTMTRQ>INCTRAN>DTEND,omitempty"` + Include Boolean `xml:"CCSTMTRQ>INCTRAN>INCLUDE"` // Include transactions (instead of just balance) + IncludePending Boolean `xml:"CCSTMTRQ>INCLUDEPENDING,omitempty"` // Include pending transactions + IncTranImg Boolean `xml:"CCSTMTRQ>INCTRANIMG,omitempty"` // Include transaction images } func (r *CCStatementRequest) Name() string { @@ -26,9 +29,11 @@ func (r *CCStatementRequest) Valid() (bool, error) { } type CCStatementResponse struct { - XMLName xml.Name `xml:"CCSTMTTRNRS"` - TrnUID UID `xml:"TRNUID"` - Status Status `xml:"STATUS"` + XMLName xml.Name `xml:"CCSTMTTRNRS"` + TrnUID UID `xml:"TRNUID"` + Status Status `xml:"STATUS"` + CltCookie String `xml:"CLTCOOKIE,omitempty"` + // TODO `xml:"OFXEXTENSION,omitempty"` CurDef String `xml:"CCSTMTRS>CURDEF"` CCAcctFrom CCAcct `xml:"CCSTMTRS>CCACCTFROM"` BankTranList *TransactionList `xml:"CCSTMTRS>BANKTRANLIST,omitempty"` diff --git a/investments.go b/investments.go index 128d092..6f09f6f 100644 --- a/investments.go +++ b/investments.go @@ -794,7 +794,7 @@ type InvStatementResponse struct { TrnUID UID `xml:"TRNUID"` Status Status `xml:"STATUS"` CltCookie String `xml:"CLTCOOKIE,omitempty"` - // TODO OFXEXTENSION + // TODO `xml:"OFXEXTENSION,omitempty"` DtAsOf Date `xml:"INVSTMTRS>DTASOF"` CurDef String `xml:"INVSTMTRS>CURDEF"` InvAcctFrom InvAcct `xml:"INVSTMTRS>INVACCTFROM"` diff --git a/profile.go b/profile.go index 4e0a5e8..331fb9f 100644 --- a/profile.go +++ b/profile.go @@ -6,10 +6,13 @@ import ( ) type ProfileRequest struct { - XMLName xml.Name `xml:"PROFTRNRQ"` - TrnUID UID `xml:"TRNUID"` - ClientRouting String `xml:"PROFRQ>CLIENTROUTING"` // Forced to NONE - DtProfUp Date `xml:"PROFRQ>DTPROFUP"` + XMLName xml.Name `xml:"PROFTRNRQ"` + TrnUID UID `xml:"TRNUID"` + CltCookie String `xml:"CLTCOOKIE,omitempty"` + TAN String `xml:"TAN,omitempty"` // Transaction authorization number + // TODO `xml:"OFXEXTENSION,omitempty"` + ClientRouting String `xml:"PROFRQ>CLIENTROUTING"` // Forced to NONE + DtProfUp Date `xml:"PROFRQ>DTPROFUP"` } func (r *ProfileRequest) Name() string { @@ -95,9 +98,11 @@ func (msl *MessageSetList) UnmarshalXML(d *xml.Decoder, start xml.StartElement) } type ProfileResponse struct { - XMLName xml.Name `xml:"PROFTRNRS"` - TrnUID UID `xml:"TRNUID"` - Status Status `xml:"STATUS"` + XMLName xml.Name `xml:"PROFTRNRS"` + TrnUID UID `xml:"TRNUID"` + Status Status `xml:"STATUS"` + CltCookie String `xml:"CLTCOOKIE,omitempty"` + // TODO `xml:"OFXEXTENSION,omitempty"` MessageSetList MessageSetList `xml:"PROFRS>MSGSETLIST"` SignonInfoList []SignonInfo `xml:"PROFRS>SIGNONINFOLIST>SIGNONINFO"` DtProfUp Date `xml:"PROFRS>DTPROFUP"` diff --git a/securities.go b/securities.go index 312b4a3..02aa09c 100644 --- a/securities.go +++ b/securities.go @@ -20,10 +20,11 @@ type SecurityRequest struct { } type SecListRequest struct { - XMLName xml.Name `xml:"SECLISTTRNRQ"` - TrnUID UID `xml:"TRNUID"` - CltCookie String `xml:"CLTCOOKIE,omitempty"` - TAN String `xml:"TAN,omitempty"` // Transaction authorization number + XMLName xml.Name `xml:"SECLISTTRNRQ"` + TrnUID UID `xml:"TRNUID"` + CltCookie String `xml:"CLTCOOKIE,omitempty"` + TAN String `xml:"TAN,omitempty"` // Transaction authorization number + // TODO `xml:"OFXEXTENSION,omitempty"` Securities []SecurityRequest `xml:"SECLISTRQ>SECRQ,omitempty"` } @@ -41,6 +42,7 @@ type SecListResponse struct { TrnUID UID `xml:"TRNUID"` Status Status `xml:"STATUS"` CltCookie String `xml:"CLTCOOKIE,omitempty"` + // TODO `xml:"OFXEXTENSION,omitempty"` // SECLISTRS is always empty, so we don't parse it here. The actual securities list will be in a top-level element parallel to SECLISTTRNRS } diff --git a/signup.go b/signup.go index ae150dc..0dfa8d6 100644 --- a/signup.go +++ b/signup.go @@ -9,8 +9,10 @@ import ( type AcctInfoRequest struct { XMLName xml.Name `xml:"ACCTINFOTRNRQ"` TrnUID UID `xml:"TRNUID"` - CltCookie Int `xml:"CLTCOOKIE"` - DtAcctUp Date `xml:"ACCTINFORQ>DTACCTUP"` + CltCookie String `xml:"CLTCOOKIE,omitempty"` + TAN String `xml:"TAN,omitempty"` // Transaction authorization number + // TODO `xml:"OFXEXTENSION,omitempty"` + DtAcctUp Date `xml:"ACCTINFORQ>DTACCTUP"` } func (r *AcctInfoRequest) Name() string { @@ -105,9 +107,11 @@ type AcctInfo struct { } type AcctInfoResponse struct { - XMLName xml.Name `xml:"ACCTINFOTRNRS"` - TrnUID UID `xml:"TRNUID"` - Status Status `xml:"STATUS"` + XMLName xml.Name `xml:"ACCTINFOTRNRS"` + TrnUID UID `xml:"TRNUID"` + Status Status `xml:"STATUS"` + CltCookie String `xml:"CLTCOOKIE,omitempty"` + // TODO `xml:"OFXEXTENSION,omitempty"` DtAcctUp Date `xml:"ACCTINFORS>DTACCTUP"` AcctInfo []AcctInfo `xml:"ACCTINFORS>ACCTINFO,omitempty"` }