Documentation ¶
Index ¶
- Constants
- Variables
- func DumpResponse(resp *http.Response)
- func LoadSession(cookies *[]*http.Cookie, fileName string) (err error)
- func PCHoldingsToIHoldings(h []HoldingsType) []providers.IHolding
- func SaveSession(inClient *http.Client, baseURL string, fileName string) (err error)
- type APIClient
- type AccountType
- type Accounts
- type AddHoldingResponse
- type AuthenticateWithPasswordParams
- type AuthenticateWithPasswordResponse
- type Authentication
- func (a *Authentication) AuthenticateWithPassword(ctx context.Context, params AuthenticateWithPasswordParams) error
- func (a *Authentication) CredentialChallenge(ctx context.Context, params CredentialChallengeParams) (*http.Response, error)
- func (a *Authentication) Login(ctx context.Context, params LoginParams) (*LoginResponse, error)
- func (a *Authentication) TwoFactorAuthentication(ctx context.Context, params TwoFactorAuthenticationParams) (*http.Response, error)
- type ChallengeType
- type Configuration
- type CredentialChallengeParams
- type GetAccountsRequest
- type GetAccountsResponse
- type GetHoldingsParams
- type GetHoldingsResponse
- type GetHoldingsResponseExpecting
- type HoldingAddRequest
- type Holdings
- func (h *Holdings) AddHolding(ctx context.Context, holding *HoldingAddRequest) (*AddHoldingResponse, error)
- func (h *Holdings) GetHoldings(ctx context.Context, params *GetHoldingsParams) (*GetHoldingsResponse, error)
- func (h *Holdings) UpdateCashAmount(ctx context.Context, cashAmount string, userAccountId int) (*UpdateHoldingsResponse, error)
- func (h *Holdings) UpdateHoldings(ctx context.Context, holding HoldingsUpdateRequest) (*UpdateHoldingsResponse, error)
- type HoldingsType
- type HoldingsUpdateRequest
- type LoginParams
- type LoginResponse
- type SpData
- type SpHeader
- type TwoFactorAuthenticationParams
- type UpdateHoldingsResponse
Constants ¶
const ( AuthenticateWithPasswordEndpoint = "/api/credential/authenticatePassword" SessionAuthenticated = "SESSION_AUTHENTICATED" UserRemembered = "USER_REMEMBERED" )
const ( EmailAuthenticateEndpoint = "/api/credential/authenticateEmailByCode" SmsAuthenticateEndpoint = "/api/credential/authenticateSms" )
const ( SMS ChallengeType = "sms" Email ChallengeType = "email" EmailChallengeEndpoint = "/api/credential/challengeEmail" SmsChallengeEndpoint = "/api/credential/challengeSms" )
const (
AddHoldingEndpoint = `/api/account/addHolding`
)
const (
GetAccountsEndpoint = `/api/newaccount/getAccounts2`
)
const (
GetHoldingsEndpoint = "/api/invest/getHoldings"
)
const (
IdentifyUserEndpoint = "/api/login/identifyUser"
)
const (
UpdateHoldingsEndpoint = `/api/account/updateHolding`
)
Variables ¶
var (
TwoFactorAuthenticationRequired = errors.New("Two Factor Authentication is Required")
)
Functions ¶
func DumpResponse ¶
func LoadSession ¶
LoadSession loads the cookies from a previously saved session file.
func PCHoldingsToIHoldings ¶
func PCHoldingsToIHoldings(h []HoldingsType) []providers.IHolding
Types ¶
type APIClient ¶
type APIClient struct { // CSRF use this once authenticated CSRF *string // APIs Authentication *Authentication Holdings *Holdings Accounts *Accounts // contains filtered or unexported fields }
func NewAPIClient ¶
func NewAPIClient(cfg *Configuration) *APIClient
NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.
type AccountType ¶
type AccountType struct { AvailableCash string `json:"availableCash"` IsOnUs bool `json:"isOnUs"` UserProductID int `json:"userProductId"` IsHome bool `json:"isHome"` NextAction struct { IconType string `json:"iconType"` Action string `json:"action"` Prompts []interface{} `json:"prompts"` AggregationErrorType string `json:"aggregationErrorType"` } `json:"nextAction"` IsIAVEligible bool `json:"isIAVEligible"` LoginFields []struct { IsUsername bool `json:"isUsername,omitempty"` IsRequired bool `json:"isRequired"` Parts []struct { Size int `json:"size"` Name string `json:"name"` ID string `json:"id"` Type string `json:"type"` MaxLength int `json:"maxLength"` } `json:"parts"` Label string `json:"label"` IsPassword bool `json:"isPassword,omitempty"` } `json:"loginFields"` EnrollmentConciergeRequested int `json:"enrollmentConciergeRequested"` IsCrypto bool `json:"isCrypto"` IsPartner bool `json:"isPartner"` PriorBalance float64 `json:"priorBalance"` IsCustomManual bool `json:"isCustomManual"` OriginalName string `json:"originalName"` IsIAVAccountNumberValid bool `json:"isIAVAccountNumberValid"` IsExcludeFromHousehold bool `json:"isExcludeFromHousehold"` IsAsset bool `json:"isAsset"` Aggregating bool `json:"aggregating"` Balance float64 `json:"balance"` IsStatementDownloadEligible bool `json:"isStatementDownloadEligible"` Is401KEligible bool `json:"is401KEligible"` IsAccountUsedInFunding bool `json:"isAccountUsedInFunding"` IsTransferPending bool `json:"isTransferPending"` IsOnUs401K bool `json:"isOnUs401K"` AdvisoryFeePercentage float64 `json:"advisoryFeePercentage"` LastRefreshed int64 `json:"lastRefreshed"` ProductID int `json:"productId"` UserSiteID int `json:"userSiteId"` Is365DayTransactionEligible bool `json:"is365DayTransactionEligible"` IsManual bool `json:"isManual"` LogoPath string `json:"logoPath"` CurrentBalance float64 `json:"currentBalance"` AccountType string `json:"accountType"` PaymentFromStatus bool `json:"paymentFromStatus"` IsRefetchTransactionEligible bool `json:"isRefetchTransactionEligible"` AccountID string `json:"accountId"` IsManualPortfolio bool `json:"isManualPortfolio"` ExcludeFromProposal bool `json:"excludeFromProposal"` UserAccountID int `json:"userAccountId"` Name string `json:"name"` FirmName string `json:"firmName"` AccountTypeGroup string `json:"accountTypeGroup"` PaymentToStatus bool `json:"paymentToStatus"` AdditionalAttributes struct { Trust struct { KindOfTrust string `json:"kindOfTrust"` KindOfTrustSecondary string `json:"kindOfTrustSecondary"` } `json:"trust"` } `json:"additionalAttributes"` IsOnUsBank bool `json:"isOnUsBank"` DisbursementType string `json:"disbursementType"` IsPaymentToCapable bool `json:"isPaymentToCapable"` ClosedComment string `json:"closedComment"` IsTaxDeferredOrNonTaxable bool `json:"isTaxDeferredOrNonTaxable"` Currency string `json:"currency"` FundFees float64 `json:"fundFees"` ProductType string `json:"productType"` IsAccountNumberValidated bool `json:"isAccountNumberValidated"` AccountTypeNew string `json:"accountTypeNew"` IsRoutingNumberValidated bool `json:"isRoutingNumberValidated"` IsLiability bool `json:"isLiability"` IsTransferEligible bool `json:"isTransferEligible"` InfoSource string `json:"infoSource"` DefaultAdvisoryFee float64 `json:"defaultAdvisoryFee"` IsAdvised bool `json:"isAdvised"` FeesPerYear string `json:"feesPerYear"` IsEsog bool `json:"isEsog"` CreatedDate int64 `json:"createdDate"` ClosedDate string `json:"closedDate"` TotalFee float64 `json:"totalFee"` IsPaymentFromCapable bool `json:"isPaymentFromCapable"` SiteID int `json:"siteId"` OriginalFirmName string `json:"originalFirmName"` }
type Accounts ¶
type Accounts service
func (*Accounts) GetAccounts ¶
func (a *Accounts) GetAccounts(ctx context.Context, request *GetAccountsRequest) (*GetAccountsResponse, error)
GetAccounts will obtains all accounts for a user's account. request parameter may be nil
type AddHoldingResponse ¶
type AddHoldingResponse struct { SpHeader SpHeader `json:"spHeader"` SpData struct { Holding struct { SourceAssetID string `json:"sourceAssetId"` Ticker string `json:"ticker"` External string `json:"external"` Quantity float64 `json:"quantity"` AccountName string `json:"accountName"` HoldingType string `json:"holdingType"` Price float64 `json:"price"` PriceSource string `json:"priceSource"` UserAccountID int `json:"userAccountId"` Description string `json:"description"` Source string `json:"source"` Value float64 `json:"value"` } `json:"holding"` } `json:"spData"` }
type Authentication ¶
type Authentication service
func (*Authentication) AuthenticateWithPassword ¶
func (a *Authentication) AuthenticateWithPassword(ctx context.Context, params AuthenticateWithPasswordParams) error
AuthenticateWithPassword signs a user in with their password
func (*Authentication) CredentialChallenge ¶
func (a *Authentication) CredentialChallenge(ctx context.Context, params CredentialChallengeParams) (*http.Response, error)
CredentialChallenge starts a two factor authentication challenge
func (*Authentication) Login ¶
func (a *Authentication) Login(ctx context.Context, params LoginParams) (*LoginResponse, error)
func (*Authentication) TwoFactorAuthentication ¶
func (a *Authentication) TwoFactorAuthentication(ctx context.Context, params TwoFactorAuthenticationParams) (*http.Response, error)
TwoFactorAuthentication is required if the user has setup 2FA and doesn't have a saved session. "sms" and "email" 2FA can be used.
type ChallengeType ¶
type ChallengeType string
ChallengeType used to indicate which Two Factor Authentication Method to use
func (ChallengeType) AsPCChallengeType ¶ added in v0.3.1
func (c ChallengeType) AsPCChallengeType() string
type Configuration ¶
type Configuration struct { Host string `json:"host,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` Debug bool `json:"debug,omitempty"` HTTPClient *http.Client Logger *zap.Logger }
func NewConfiguration ¶
func NewConfiguration() *Configuration
NewConfiguration returns a new Configuration object
type CredentialChallengeParams ¶
type CredentialChallengeParams struct { CSRF string ChallengeType ChallengeType }
type GetAccountsRequest ¶
type GetAccountsResponse ¶
type GetAccountsResponse struct { SpHeader SpHeader `json:"spHeader"` SpData struct { CreditCardAccountsTotal float64 `json:"creditCardAccountsTotal"` Assets float64 `json:"assets"` OtherLiabilitiesAccountsTotal float64 `json:"otherLiabilitiesAccountsTotal"` CashAccountsTotal float64 `json:"cashAccountsTotal"` Liabilities float64 `json:"liabilities"` Networth float64 `json:"networth"` InvestmentAccountsTotal float64 `json:"investmentAccountsTotal"` MortgageAccountsTotal float64 `json:"mortgageAccountsTotal"` LoanAccountsTotal float64 `json:"loanAccountsTotal"` Accounts []AccountType `json:"accounts"` OtherAssetAccountsTotal float64 `json:"otherAssetAccountsTotal"` } `json:"spData"` }
type GetHoldingsParams ¶
type GetHoldingsResponse ¶
type GetHoldingsResponse struct {
SpData
}
type HoldingAddRequest ¶
type HoldingAddRequest struct { // userAccountId=80828031&ticker=Stellar+Lumens&cusip=&description=XML&quantity=965.08&price=0.06&value=57.9048&source=USER&costBasis=&lastServerChangeId=152&csrf=3c19636c-175f-447c-9cc7-f56a5be07f0d&apiClient=WEB Ticker string `url:"ticker"` Quantity string `url:"quantity"` Description string `url:"description"` Source string `url:"source"` Price string `url:"price"` UserAccountId int `url:"userAccountId"` CostBasis string `url:"costBasis"` Value string `url:"value"` LastServerChangeId string `url:"lastServerChangeId"` Csrf string `url:"csrf"` ApiClient string `url:"apiClient"` }
type Holdings ¶
type Holdings service
func (*Holdings) AddHolding ¶
func (h *Holdings) AddHolding(ctx context.Context, holding *HoldingAddRequest) (*AddHoldingResponse, error)
func (*Holdings) GetHoldings ¶
func (h *Holdings) GetHoldings(ctx context.Context, params *GetHoldingsParams) (*GetHoldingsResponse, error)
func (*Holdings) UpdateCashAmount ¶ added in v0.2.0
func (h *Holdings) UpdateCashAmount(ctx context.Context, cashAmount string, userAccountId int) (*UpdateHoldingsResponse, error)
UpdateCashAmount this is a special Add/Update Holding because this one is built into personal capital for all manual investments accounts.
func (*Holdings) UpdateHoldings ¶
func (h *Holdings) UpdateHoldings(ctx context.Context, holding HoldingsUpdateRequest) (*UpdateHoldingsResponse, error)
type HoldingsType ¶
type HoldingsType struct { Cusip string `json:"cusip,omitempty"` AccountName string `json:"accountName"` Description string `json:"description"` Source string `json:"source"` MarketType int `json:"marketType"` OriginalTicker string `json:"originalTicker,omitempty"` OriginalCusip string `json:"originalCusip,omitempty"` HoldingType string `json:"holdingType"` Price float64 `json:"price"` HoldingPercentage float64 `json:"holdingPercentage"` Value float64 `json:"value"` OriginalDescription string `json:"originalDescription,omitempty"` Ticker string `json:"ticker,omitempty"` Quantity float64 `json:"quantity"` ManualClassification string `json:"manualClassification"` IsMarketMover bool `json:"isMarketMover"` OneDayPercentChangeSortIndex int `json:"oneDayPercentChangeSortIndex"` OneDayValueChange float64 `json:"oneDayValueChange"` Change float64 `json:"change"` ChangeSortIndex int `json:"changeSortIndex"` OneDayValueChangeSortIndex int `json:"oneDayValueChangeSortIndex"` SourceAssetID string `json:"sourceAssetId"` External string `json:"external"` UserAccountID int `json:"userAccountId"` PriceSource string `json:"priceSource"` ValueSortIndex int `json:"valueSortIndex"` Exchange string `json:"exchange,omitempty"` OneDayPercentChange float64 `json:"oneDayPercentChange"` TradingRatio float64 `json:"tradingRatio,omitempty"` Type string `json:"type,omitempty"` TaxCost float64 `json:"taxCost,omitempty"` FundFees float64 `json:"fundFees,omitempty"` FeesPerYear float64 `json:"feesPerYear,omitempty"` CostBasis float64 `json:"costBasis,omitempty"` Currency string `json:"currency,omitempty"` }
func FilterHoldsByAccountName ¶
func FilterHoldsByAccountName(holdings []HoldingsType, accountName string) []HoldingsType
func FilterHoldsFromUser ¶
func FilterHoldsFromUser(holdings []HoldingsType) []HoldingsType
func (HoldingsType) CurrencyName ¶
func (h HoldingsType) CurrencyName() string
func (HoldingsType) CurrencySymbolName ¶
func (h HoldingsType) CurrencySymbolName() string
func (HoldingsType) TotalSharesString ¶
func (h HoldingsType) TotalSharesString() string
type HoldingsUpdateRequest ¶
type HoldingsUpdateRequest struct { Ticker string `url:"ticker"` Quantity string `url:"quantity"` ManualClassification string `url:"manualClassification"` IsMarketMover bool `url:"isMarketMover"` AccountName string `url:"accountName"` OneDayPercentChangeSortIndex int `url:"oneDayPercentChangeSortIndex"` OneDayValueChange float64 `url:"oneDayValueChange"` Change float64 `url:"change"` Description string `url:"description"` Source string `url:"source"` ChangeSortIndex int `url:"changeSortIndex"` OneDayValueChangeSortIndex int `url:"oneDayValueChangeSortIndex"` MarketType int `url:"marketType"` SourceAssetId string `url:"sourceAssetId"` External string `url:"external"` HoldingType string `url:"holdingType"` Price string `url:"price"` HoldingPercentage float64 `url:"holdingPercentage"` UserAccountId int `url:"userAccountId"` PriceSource string `url:"priceSource"` ValueSortIndex int `url:"valueSortIndex"` CostBasis string `url:"costBasis"` Value string `url:"value"` OneDayPercentChange float64 `url:"oneDayPercentChange"` LastServerChangeId string `url:"lastServerChangeId"` Csrf string `url:"csrf"` ApiClient string `url:"apiClient"` }
userAccountId=80828031&priceSource=USER&valueSortIndex=1&costBasis=0&value=44.35&oneDayPercentChange=0&lastServerChangeId=21&csrf=7e23adfc-8058-408a-bb39-d7ee428a0dbb&apiClient=WEB
type LoginParams ¶
type LoginParams struct {
Username, Password string
}
type LoginResponse ¶
type LoginResponse struct {
CRSF string
}
type SpData ¶
type SpData struct { Classifications []interface{} `json:"classifications"` Holdings []HoldingsType `json:"holdings"` HoldingsTotalValue float64 `json:"holdingsTotalValue"` }
type SpHeader ¶
type SpHeader struct { SPHEADERVERSION int `json:"SP_HEADER_VERSION"` UserStage string `json:"userStage"` IsDelegate bool `json:"isDelegate"` UserGUID string `json:"userGuid"` DeviceName string `json:"deviceName"` BetaTester bool `json:"betaTester"` AccountsMetaData []string `json:"accountsMetaData"` Success bool `json:"success"` QualifiedLead bool `json:"qualifiedLead"` Developer bool `json:"developer"` PersonID int `json:"personId"` AuthLevel string `json:"authLevel"` Username string `json:"username"` Status string `json:"status"` Errors []struct { Code int `json:"code"` Details struct { FieldName string `json:"fieldName"` } `json:"details"` Message string `json:"message"` } `json:"errors"` Csrf string `json:"csrf"` SPDATACHANGES []struct { ServerChangeID int `json:"serverChangeId"` Details struct { ID int `json:"id"` } `json:"details"` EventType string `json:"eventType"` } `json:"SP_DATA_CHANGES"` }
type TwoFactorAuthenticationParams ¶ added in v0.3.1
type TwoFactorAuthenticationParams struct { Code string CSRF string ChallengeType ChallengeType }
type UpdateHoldingsResponse ¶
type UpdateHoldingsResponse struct { SpHeader SpHeader `json:"spHeader"` SpData struct { Holding struct { Ticker string `json:"ticker"` Quantity float64 `json:"quantity"` AccountName string `json:"accountName"` Description string `json:"description"` Source string `json:"source"` SourceAssetID string `json:"sourceAssetId"` External string `json:"external"` HoldingType string `json:"holdingType"` Price float64 `json:"price"` PriceSource string `json:"priceSource"` UserAccountID int `json:"userAccountId"` CostBasis float64 `json:"costBasis"` Value float64 `json:"value"` } `json:"holding"` } `json:"spData"` }