2017-03-11 21:13:06 -05:00
|
|
|
package ofxgo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2017-03-22 20:59:40 -04:00
|
|
|
"github.com/aclindsa/go/src/encoding/xml"
|
2017-03-11 21:13:06 -05:00
|
|
|
)
|
|
|
|
|
2017-04-13 10:18:07 -04:00
|
|
|
// AcctInfoRequest represents a request for the server to provide information
|
|
|
|
// for all of the user's available accounts at this FI
|
2017-03-11 21:13:06 -05:00
|
|
|
type AcctInfoRequest struct {
|
|
|
|
XMLName xml.Name `xml:"ACCTINFOTRNRQ"`
|
|
|
|
TrnUID UID `xml:"TRNUID"`
|
2017-03-30 10:24:26 -04:00
|
|
|
CltCookie String `xml:"CLTCOOKIE,omitempty"`
|
|
|
|
TAN String `xml:"TAN,omitempty"` // Transaction authorization number
|
|
|
|
// TODO `xml:"OFXEXTENSION,omitempty"`
|
|
|
|
DtAcctUp Date `xml:"ACCTINFORQ>DTACCTUP"`
|
2017-03-11 21:13:06 -05:00
|
|
|
}
|
|
|
|
|
2017-04-13 10:18:07 -04:00
|
|
|
// Name returns the name of the top-level transaction XML/SGML element
|
2017-03-11 21:13:06 -05:00
|
|
|
func (r *AcctInfoRequest) Name() string {
|
|
|
|
return "ACCTINFOTRNRQ"
|
|
|
|
}
|
|
|
|
|
2017-04-13 10:18:07 -04:00
|
|
|
// Valid returns (true, nil) if this struct would be valid OFX if marshalled
|
|
|
|
// into XML/SGML
|
2017-03-11 21:13:06 -05:00
|
|
|
func (r *AcctInfoRequest) Valid() (bool, error) {
|
2017-03-29 05:41:28 -04:00
|
|
|
// TODO implement
|
2017-03-11 21:13:06 -05:00
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
|
2017-04-13 10:18:07 -04:00
|
|
|
// Type returns which message set this message belongs to (which Request
|
|
|
|
// element of type []Message it should appended to)
|
2017-03-31 09:25:07 -04:00
|
|
|
func (r *AcctInfoRequest) Type() messageType {
|
|
|
|
return SignupRq
|
|
|
|
}
|
|
|
|
|
2017-04-13 10:18:07 -04:00
|
|
|
// HolderInfo contains the information a FI has about an account-holder
|
2017-03-11 21:13:06 -05:00
|
|
|
type HolderInfo struct {
|
|
|
|
XMLName xml.Name
|
2017-04-06 05:58:22 -04:00
|
|
|
FirstName String `xml:"FIRSTNAME"`
|
|
|
|
MiddleName String `xml:"MIDDLENAME,omitempty"`
|
|
|
|
LastName String `xml:"LASTNAME"`
|
|
|
|
Addr1 String `xml:"ADDR1"`
|
|
|
|
Addr2 String `xml:"ADDR2,omitempty"`
|
|
|
|
Addr3 String `xml:"ADDR3,omitempty"`
|
|
|
|
City String `xml:"CITY"`
|
|
|
|
State String `xml:"STATE"`
|
|
|
|
PostalCode String `xml:"POSTALCODE"`
|
|
|
|
Country String `xml:"COUNTRY,omitempty"`
|
|
|
|
DayPhone String `xml:"DAYPHONE,omitempty"`
|
|
|
|
EvePhone String `xml:"EVEPHONE,omitempty"`
|
|
|
|
Email String `xml:"EMAIL,omitempty"`
|
|
|
|
HolderType holderType `xml:"HOLDERTYPE,omitempty"` // One of INDIVIDUAL, JOINT, CUSTODIAL, TRUST, OTHER
|
2017-03-11 21:13:06 -05:00
|
|
|
}
|
|
|
|
|
2017-04-13 10:18:07 -04:00
|
|
|
// BankAcctInfo contains information about a bank account, including how to
|
|
|
|
// access it (BankAcct), and whether it supports downloading transactions
|
|
|
|
// (SupTxDl).
|
2017-03-11 21:13:06 -05:00
|
|
|
type BankAcctInfo struct {
|
2017-04-06 05:58:22 -04:00
|
|
|
XMLName xml.Name `xml:"BANKACCTINFO"`
|
|
|
|
BankAcctFrom BankAcct `xml:"BANKACCTFROM"`
|
|
|
|
SupTxDl Boolean `xml:"SUPTXDL"` // Supports downloading transactions (as opposed to balance only)
|
|
|
|
XferSrc Boolean `xml:"XFERSRC"` // Enabled as source for intra/interbank transfer
|
|
|
|
XferDest Boolean `xml:"XFERDEST"` // Enabled as destination for intra/interbank transfer
|
|
|
|
MaturityDate Date `xml:"MATURITYDATE,omitempty"` // Maturity date for CD, if CD
|
|
|
|
MaturityAmt Amount `xml:"MATURITYAMOUNT,omitempty"` // Maturity amount for CD, if CD
|
|
|
|
MinBalReq Amount `xml:"MINBALREQ,omitempty"` // Minimum balance required to avoid service fees
|
|
|
|
AcctClassification acctClassification `xml:"ACCTCLASSIFICATION,omitempty"` // One of PERSONAL, BUSINESS, CORPORATE, OTHER
|
|
|
|
OverdraftLimit Amount `xml:"OVERDRAFTLIMIT,omitempty"`
|
|
|
|
SvcStatus svcStatus `xml:"SVCSTATUS"` // One of AVAIL (available, but not yet requested), PEND (requested, but not yet available), ACTIVE
|
2017-03-11 21:13:06 -05:00
|
|
|
}
|
|
|
|
|
2017-04-13 10:18:07 -04:00
|
|
|
// String makes pointers to BankAcctInfo structs print nicely
|
2017-03-11 21:13:06 -05:00
|
|
|
func (bai *BankAcctInfo) String() string {
|
|
|
|
return fmt.Sprintf("%+v", *bai)
|
|
|
|
}
|
|
|
|
|
2017-04-13 10:18:07 -04:00
|
|
|
// CCAcctInfo contains information about a credit card account, including how
|
|
|
|
// to access it (CCAcct), and whether it supports downloading transactions
|
|
|
|
// (SupTxDl).
|
2017-03-11 21:13:06 -05:00
|
|
|
type CCAcctInfo struct {
|
2017-04-06 05:58:22 -04:00
|
|
|
XMLName xml.Name `xml:"CCACCTINFO"`
|
|
|
|
CCAcctFrom CCAcct `xml:"CCACCTFROM"`
|
|
|
|
SupTxDl Boolean `xml:"SUPTXDL"` // Supports downloading transactions (as opposed to balance only)
|
|
|
|
XferSrc Boolean `xml:"XFERSRC"` // Enabled as source for intra/interbank transfer
|
|
|
|
XferDest Boolean `xml:"XFERDEST"` // Enabled as destination for intra/interbank transfer
|
|
|
|
AcctClassification acctClassification `xml:"ACCTCLASSIFICATION,omitempty"` // One of PERSONAL, BUSINESS, CORPORATE, OTHER
|
|
|
|
SvcStatus svcStatus `xml:"SVCSTATUS"` // One of AVAIL (available, but not yet requested), PEND (requested, but not yet available), ACTIVE
|
2017-03-11 21:13:06 -05:00
|
|
|
}
|
|
|
|
|
2017-04-13 10:18:07 -04:00
|
|
|
// String makes pointers to CCAcctInfo structs print nicely
|
2017-03-11 21:13:06 -05:00
|
|
|
func (ci *CCAcctInfo) String() string {
|
|
|
|
return fmt.Sprintf("%+v", *ci)
|
|
|
|
}
|
|
|
|
|
2017-04-13 10:18:07 -04:00
|
|
|
// InvAcctInfo contains information about an investment account, including how
|
|
|
|
// to access it (InvAcct), and whether it supports downloading transactions
|
|
|
|
// (SupTxDl).
|
2017-03-11 21:13:06 -05:00
|
|
|
type InvAcctInfo struct {
|
2017-04-06 20:30:51 -04:00
|
|
|
XMLName xml.Name `xml:"INVACCTINFO"`
|
|
|
|
InvAcctFrom InvAcct `xml:"INVACCTFROM"`
|
|
|
|
UsProductType usProductType `xml:"USPRODUCTTYPE"` // One of 401K, 403B, IRA, KEOGH, OTHER, SARSEP, SIMPLE, NORMAL, TDA, TRUST, UGMA
|
|
|
|
Checking Boolean `xml:"CHECKING"` // Has check-writing privileges
|
|
|
|
SvcStatus svcStatus `xml:"SVCSTATUS"` // One of AVAIL (available, but not yet requested), PEND (requested, but not yet available), ACTIVE
|
|
|
|
InvAcctType holderType `xml:"INVACCTTYPE,omitempty"` // One of INDIVIDUAL, JOINT, TRUST, CORPORATE
|
|
|
|
OptionLevel String `xml:"OPTIONLEVEL,omitempty"` // Text desribing option trading privileges
|
2017-03-11 21:13:06 -05:00
|
|
|
}
|
|
|
|
|
2017-04-13 10:18:07 -04:00
|
|
|
// String makes pointers to InvAcctInfo structs print nicely
|
2017-03-11 21:13:06 -05:00
|
|
|
func (iai *InvAcctInfo) String() string {
|
|
|
|
return fmt.Sprintf("%+v", *iai)
|
|
|
|
}
|
|
|
|
|
2017-04-13 10:18:07 -04:00
|
|
|
// AcctInfo represents generic account information. It should contain one (and
|
|
|
|
// only one) *AcctInfo element corresponding to the tyep of account it
|
|
|
|
// represents.
|
2017-03-11 21:13:06 -05:00
|
|
|
type AcctInfo struct {
|
|
|
|
XMLName xml.Name `xml:"ACCTINFO"`
|
|
|
|
Name String `xml:"NAME,omitempty"`
|
|
|
|
Desc String `xml:"DESC,omitempty"`
|
|
|
|
Phone String `xml:"PHONE,omitempty"`
|
|
|
|
PrimaryHolder HolderInfo `xml:"HOLDERINFO>PRIMARYHOLDER,omitempty"`
|
|
|
|
SecondaryHolder HolderInfo `xml:"HOLDERINFO>SECONDARYHOLDER,omitempty"`
|
2017-04-13 10:18:07 -04:00
|
|
|
|
2017-03-11 21:13:06 -05:00
|
|
|
// Only one of the rest of the fields will be valid for any given AcctInfo
|
|
|
|
BankAcctInfo *BankAcctInfo `xml:"BANKACCTINFO,omitempty"`
|
|
|
|
CCAcctInfo *CCAcctInfo `xml:"CCACCTINFO,omitempty"`
|
|
|
|
InvAcctInfo *InvAcctInfo `xml:"INVACCTINFO,omitempty"`
|
|
|
|
// TODO LOANACCTINFO
|
|
|
|
// TODO BPACCTINFO?
|
|
|
|
}
|
|
|
|
|
2017-04-13 10:18:07 -04:00
|
|
|
// AcctInfoResponse contains the information about all a user's accounts
|
|
|
|
// accessible from this FI
|
2017-03-11 21:13:06 -05:00
|
|
|
type AcctInfoResponse struct {
|
2017-03-30 10:24:26 -04:00
|
|
|
XMLName xml.Name `xml:"ACCTINFOTRNRS"`
|
|
|
|
TrnUID UID `xml:"TRNUID"`
|
|
|
|
Status Status `xml:"STATUS"`
|
|
|
|
CltCookie String `xml:"CLTCOOKIE,omitempty"`
|
|
|
|
// TODO `xml:"OFXEXTENSION,omitempty"`
|
2017-03-11 21:13:06 -05:00
|
|
|
DtAcctUp Date `xml:"ACCTINFORS>DTACCTUP"`
|
|
|
|
AcctInfo []AcctInfo `xml:"ACCTINFORS>ACCTINFO,omitempty"`
|
|
|
|
}
|
|
|
|
|
2017-04-13 10:18:07 -04:00
|
|
|
// Name returns the name of the top-level transaction XML/SGML element
|
2017-03-31 11:54:43 -04:00
|
|
|
func (air *AcctInfoResponse) Name() string {
|
|
|
|
return "ACCTINFOTRNRS"
|
2017-03-11 21:13:06 -05:00
|
|
|
}
|
|
|
|
|
2017-04-13 10:18:07 -04:00
|
|
|
// Valid returns (true, nil) if this struct was valid OFX when unmarshalled
|
2017-03-31 11:54:43 -04:00
|
|
|
func (air *AcctInfoResponse) Valid() (bool, error) {
|
2017-03-11 21:13:06 -05:00
|
|
|
//TODO implement
|
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
|
2017-04-13 10:18:07 -04:00
|
|
|
// Type returns which message set this message belongs to (which Response
|
|
|
|
// element of type []Message it belongs to)
|
2017-03-31 11:54:43 -04:00
|
|
|
func (air *AcctInfoResponse) Type() messageType {
|
2017-03-31 09:25:07 -04:00
|
|
|
return SignupRs
|
|
|
|
}
|