intuit

package module
v0.0.0-...-1b7dd89 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2016 License: MIT Imports: 22 Imported by: 0

README

intuit-cad

Go client for Intuit's Financial Data API

Note

This library only implements calls for a few endpoints, and due to the upcoming EOL of the APIs in question will likely never be finished.

Documentation

godoc

Documentation

Index

Constants

View Source
const (
	AccountStatusActive   = "ACTIVE"
	AccountStatusInactive = "INACTIVE"
)

Constants representing account status

View Source
const (
	AggrStatusOK                        string = "0"
	AggrStatusUnknown                          = "100"
	AggrStatusGeneralError                     = "101"
	AggrStatusAggrError                        = "102"
	AggrStatusLoginError                       = "103"
	AggrStatusJSONParsingError                 = "104"
	AggrStatusUnavailable                      = "105"
	AggrStatusAccountMismatch                  = "106"
	AggrStatusEndUserActionRequired            = "108"
	AggrStatusPasswordChangeRequired           = "109"
	AggrStatusFinancialInstitutionError        = "155"
	AggrStatusApplicationError                 = "163"
	AggrStatusMultipleLogins                   = "179"
	AggrStatusMFARequired                      = "185"
	AggrStatusIncorrectMFAAnswer               = "187"
	AggrStatusInvalidPersonalAccessCode        = "199"
	AggrStatusDuplicateAccount                 = "323"
	AggrStatusAccountNumberChanged             = "324"
)

Constants representing aggregation status codes. See https://developer.intuit.com/docs/0020_customeraccountdata/0000_api/0700_error_codes#/Error_Code_and_Messages_with_Resolution

View Source
const (
	AccessTokenEndpoint = "https://oauth.intuit.com/oauth/v1/get_access_token_by_saml"
	BaseURL             = "https://financialdatafeed.platform.intuit.com/v1"
)

Intuit CAD API constants

View Source
const (
	C14N      = "http://www.w3.org/2001/10/xml-exc-c14n#"
	RSASHA1   = "http://www.w3.org/2000/09/xmldsig#rsa-sha1"
	XMLDSIGNS = "http://www.w3.org/2000/09/xmldsig#enveloped-signature"
	SHA1      = "http://www.w3.org/2000/09/xmldsig#sha1"
)

Constants for xmldsig

Variables

View Source
var (
	DefaultHTTPClient     = http.DefaultClient
	DefaultConsumerKey    = ""
	DefaultConsumerSecret = ""
	DefaultSAMLProviderID = ""
	DefaultPrivateKey     *rsa.PrivateKey
)

Default values for clients

Functions

func SetDefaultCredentials

func SetDefaultCredentials(consumerKey, consumerSecret, samlProviderID string)

SetDefaultCredentials sets default for clients from the given arguments

func SetDefaultPrivateKeyFromPEM

func SetDefaultPrivateKeyFromPEM(pemData io.Reader) error

SetDefaultPrivateKeyFromPEM decodes a PEM-encoded RSA key from `pemData` and stores it in DefaultPrivateKey. Panics if any part of the process fails

Types

type Account

type Account struct {
	ID                     int64               `json:"accountId"`
	LoginID                int64               `json:"institutionLoginId"`
	Name                   string              `json:"accountNickname"`
	Balance                float64             `json:"balanceAmount"`
	BalanceDate            unixTimestampMillis `json:"balanceDate"`
	Status                 string              `json:"status"`
	AggrSuccessDate        unixTimestampMillis `json:"aggrSuccessDate"`
	AggrAttemptDate        unixTimestampMillis `json:"aggrAttemptDate"`
	AggrStatusCode         string              `json:"aggrStatusCode"`
	Currency               string              `json:"currencyCode"`
	FinancialInstitutionID int64               `json:"institutionId"`
}

Account is an account at a financial institution

func (Account) IsActive

func (a Account) IsActive() bool

IsActive returns true if the account status is active

type Assertion

type Assertion struct {
	XMLName xml.Name `xml:"urn:oasis:names:tc:SAML:2.0:assertion Assertion"`

	RefID        string    `xml:"ID,attr"`
	IssueInstant time.Time `xml:"IssueInstant,attr"`
	Version      string    `xml:"Version,attr"`

	Issuer         string         `xml:"Issuer"`
	Signature      *signature     `xml:"http://www.w3.org/2000/09/xmldsig# Signature,omitempty"`
	Subject        subject        `xml:"Subject"`
	Conditions     conditions     `xml:"Conditions"`
	AuthnStatement authnStatement `xml:"AuthnStatement"`
}

Assertion is a Go representation of a SAML 2.0 Assertion

func NewAssertion

func NewAssertion(issuer, customerID string, lifetime time.Duration) Assertion

NewAssertion creates a new SAML assertion

func (*Assertion) Sign

func (a *Assertion) Sign(key *rsa.PrivateKey) error

Sign populates the assertion's xmldisg signature based on the assertion's current state.

type Client

type Client struct {
	CustomerID string

	ConsumerKey    string
	ConsumerSecret string

	SAMLProviderID string
	PrivateKey     *rsa.PrivateKey

	HTTPClient *http.Client
	// contains filtered or unexported fields
}

Client is an interface for accessing the Intuit CAD API

func NewClient

func NewClient(customerID string) (*Client, error)

NewClient returns a client that uses the default settings. The client will be initialized automatically. Clients will be cached for 30 minutes using customerID as the key.

func (*Client) AccountTransactions

func (c *Client) AccountTransactions(accountID int64, startDate time.Time, endDate *time.Time) (TransactionList, error)

func (*Client) GetCustomerAccounts

func (c *Client) GetCustomerAccounts() ([]Account, error)

GetCustomerAccounts returns all accounts for a customer across all of their logins

func (*Client) GetLoginAccounts

func (c *Client) GetLoginAccounts(loginID int64) ([]Account, error)

GetLoginAccounts returns all accounts for a login

func (*Client) Init

func (c *Client) Init() error

Init prepares the client for use by loading OAuth tokens from the Intuit API. It should be only be called once per client, and it should be called before any other method.

func (*Client) InstitutionDetails

func (c *Client) InstitutionDetails(institutionID int64) (*InstitutionDetails, error)

type InstitutionDetails

type InstitutionDetails struct {
	ID           int64  `json:"institutionId"`
	Name         string `json:"institutionName"`
	HomeURL      string `json:"homeUrl"`
	PhoneNumber  string `json:"phoneNumber"`
	EmailAddress string `json:"emailAddress"`
	SpecialText  string `json:"specialText"`
	CurrencyCode string `json:"currencyCode"`
	Virtual      bool   `json:"virtual"`

	Address struct {
		AddressLine1 string `json:"address1"`
		AddressLine2 string `json:"address2"`
		AddressLine3 string `json:"address3"`
		City         string `json:"city"`
		State        string `json:"state"`
		PostalCode   string `json:"postalCode"`
		Country      string `json:"country"`
	} `json:"address"`

	Keys institutionKeys `json:"keys"`
}

type InstitutionKey

type InstitutionKey struct {
	Name          string `json:"name"`
	Value         string `json:"val"`
	Status        string `json:"status"`
	MinLength     int    `json:"valueLengthMin"`
	MaxLength     int    `json:"valueLengthMax"`
	DisplayToUser bool   `json:"displayFlag"`
	DisplayOrder  int    `json:"displayOrder"`
	MaskValue     bool   `json:"mask"`
	Instructions  string `json:"instructions"`
	Description   string `json:"description"`
}

type Transaction

type Transaction struct {
	ID                       int64               `json:"id"`
	InstitutionTransactionID string              `json:"institutionTransactionId"`
	UserDate                 unixTimestampMillis `json:"userDate"`
	PostedDate               unixTimestampMillis `json:"postedDate"`
	CurrencyType             string              `json:"currencyType"`
	PayeeName                string              `json:"payeeName"`
	Amount                   float64             `json:"amount"`
	Pending                  bool                `json:"pending"`

	Categorization struct {
		Common struct {
			NormalizedPayeeName string `json:"normalizedPayeeName"`
		} `json:"common"`

		Context []struct {
			Source       string `json:"source"`
			CategoryName string `json:"categoryName"`
			ScheduleC    string `json:"scheduleC"`
		} `json:"context"`
	} `json:"categorization"`
}

Transaction represents an individual transaction in a financial institution account.

type TransactionList

type TransactionList map[string][]Transaction

TransactionList is a map of transaction types to a slice of transactions

func (TransactionList) UnmarshalJSON

func (t TransactionList) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json Unmarshaler interface. It will inspect all of the top-level JSON object keys in the object. If a key ends with "Transactions" (e.g. bankingTransactions), the key will be included in the TransactionList and its value will be unmarshaled into a []Transaction

TODO: this payload can contain an error key. Providing this back to the user (without returning an error from UnmarshalJSON) will likely require breaking changes to the TransactionList type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL