quickbooks

package module
v0.0.0-...-14f9559 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: BSD-2-Clause Imports: 17 Imported by: 0

README

quickbooks-go

Build GoDoc Go Report Card

quickbooks-go is a Go library that provides access to Intuit's QuickBooks Online API.

NOTE: This library is incomplete. I implemented the minimum for my use case. Pull requests welcome :)

Example

Authorization flow

Before you can initialize the client, you'll need to obtain an authorization code. You can see an example of this from QuickBooks' OAuth Playground.

See auth_flow_test.go

clientId     := "<your-client-id>"
clientSecret := "<your-client-secret>"
realmId      := "<realm-id>"

qbClient, err := quickbooks.NewClient(clientId, clientSecret, realmId, false, "", nil)
if err != nil {
	log.Fatalln(err)
}

// To do first when you receive the authorization code from quickbooks callback
authorizationCode := "<received-from-callback>"
redirectURI := "https://developer.intuit.com/v2/OAuth2Playground/RedirectUrl"

bearerToken, err := qbClient.RetrieveBearerToken(authorizationCode, redirectURI)
if err != nil {
	log.Fatalln(err)
}
// Save the bearer token inside a db

// When the token expire, you can use the following function
bearerToken, err = qbClient.RefreshToken(bearerToken.RefreshToken)
if err != nil {
	log.Fatalln(err)
}

// Make a request!
info, err := qbClient.FindCompanyInfo()
if err != nil {
	log.Fatalln(err)
}

fmt.Println(info)

// Revoke the token, this should be done only if a user unsubscribe from your app
qbClient.RevokeToken(bearerToken.RefreshToken)

Re-using tokens

See reuse_token_test.go

clientId     := "<your-client-id>"
clientSecret := "<your-client-secret>"
realmId      := "<realm-id>"

token := quickbooks.BearerToken{
	RefreshToken:           "<saved-refresh-token>",
	AccessToken:            "<saved-access-token>",
}

qbClient, err := quickbooks.NewClient(clientId, clientSecret, realmId, false, "", &token)
if err != nil {
	log.Fatalln(err)
}

// Make a request!
info, err := qbClient.FindCompanyInfo()
if err != nil {
	log.Fatalln(err)
}

fmt.Println(info)

License

BSD-2-Clause

Documentation

Overview

Copyright (c) 2018, Randy Westlund. All rights reserved. This code is under the BSD-2-Clause license.

Index

Constants

View Source
const (
	BankAccountType                  = "Bank"
	OtherCurrentAssetAccountType     = "Other Current Asset"
	FixedAssetAccountType            = "Fixed Asset"
	OtherAssetAccountType            = "Other Asset"
	AccountsReceivableAccountType    = "Accounts Receivable"
	EquityAccountType                = "Equity"
	ExpenseAccountType               = "Expense"
	OtherExpenseAccountType          = "Other Expense"
	CostOfGoodsSoldAccountType       = "Cost of Goods Sold"
	AccountsPayableAccountType       = "Accounts Payable"
	CreditCardAccountType            = "Credit Card"
	LongTermLiabilityAccountType     = "Long Term Liability"
	OtherCurrentLiabilityAccountType = "Other Current Liability"
	IncomeAccountType                = "Income"
	OtherIncomeAccountType           = "Other Income"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Id                            string        `json:"Id,omitempty"`
	Name                          string        `json:",omitempty"`
	SyncToken                     string        `json:",omitempty"`
	AcctNum                       string        `json:",omitempty"`
	CurrencyRef                   ReferenceType `json:",omitempty"`
	ParentRef                     ReferenceType `json:",omitempty"`
	Description                   string        `json:",omitempty"`
	Active                        bool          `json:",omitempty"`
	MetaData                      MetaData      `json:",omitempty"`
	SubAccount                    bool          `json:",omitempty"`
	Classification                string        `json:",omitempty"`
	FullyQualifiedName            string        `json:",omitempty"`
	TxnLocationType               string        `json:",omitempty"`
	AccountType                   string        `json:",omitempty"`
	CurrentBalanceWithSubAccounts json.Number   `json:",omitempty"`
	AccountAlias                  string        `json:",omitempty"`
	TaxCodeRef                    ReferenceType `json:",omitempty"`
	AccountSubType                string        `json:",omitempty"`
	CurrentBalance                json.Number   `json:",omitempty"`
}

type AccountBasedExpenseLineDetail

type AccountBasedExpenseLineDetail struct {
	AccountRef ReferenceType
	TaxAmount  json.Number `json:",omitempty"`
}

type Attachable

type Attachable struct {
	Id                       string          `json:"Id,omitempty"`
	SyncToken                string          `json:",omitempty"`
	FileName                 string          `json:",omitempty"`
	Note                     string          `json:",omitempty"`
	Category                 string          `json:",omitempty"`
	ContentType              ContentType     `json:",omitempty"`
	PlaceName                string          `json:",omitempty"`
	AttachableRef            []AttachableRef `json:",omitempty"`
	Long                     string          `json:",omitempty"`
	Tag                      string          `json:",omitempty"`
	Lat                      string          `json:",omitempty"`
	MetaData                 MetaData        `json:",omitempty"`
	FileAccessUri            string          `json:",omitempty"`
	Size                     json.Number     `json:",omitempty"`
	ThumbnailFileAccessUri   string          `json:",omitempty"`
	TempDownloadUri          string          `json:",omitempty"`
	ThumbnailTempDownloadUri string          `json:",omitempty"`
}

type AttachableRef

type AttachableRef struct {
	IncludeOnSend bool   `json:",omitempty"`
	LineInfo      string `json:",omitempty"`
	NoRefOnly     bool   `json:",omitempty"`
	// CustomField[0..n]
	Inactive  bool          `json:",omitempty"`
	EntityRef ReferenceType `json:",omitempty"`
}

type BearerToken

type BearerToken struct {
	RefreshToken           string `json:"refresh_token"`
	AccessToken            string `json:"access_token"`
	TokenType              string `json:"token_type"`
	IdToken                string `json:"id_token"`
	ExpiresIn              int64  `json:"expires_in"`
	XRefreshTokenExpiresIn int64  `json:"x_refresh_token_expires_in"`
}

type Bill

type Bill struct {
	Id           string        `json:"Id,omitempty"`
	VendorRef    ReferenceType `json:",omitempty"`
	Line         []Line
	SyncToken    string        `json:",omitempty"`
	CurrencyRef  ReferenceType `json:",omitempty"`
	TxnDate      Date          `json:",omitempty"`
	APAccountRef ReferenceType `json:",omitempty"`
	SalesTermRef ReferenceType `json:",omitempty"`
	LinkedTxn    []LinkedTxn   `json:",omitempty"`
	// GlobalTaxCalculation
	TotalAmt                json.Number `json:",omitempty"`
	TransactionLocationType string      `json:",omitempty"`
	DueDate                 Date        `json:",omitempty"`
	MetaData                MetaData    `json:",omitempty"`
	DocNumber               string
	PrivateNote             string        `json:",omitempty"`
	TxnTaxDetail            TxnTaxDetail  `json:",omitempty"`
	ExchangeRate            json.Number   `json:",omitempty"`
	DepartmentRef           ReferenceType `json:",omitempty"`
	IncludeInAnnualTPAR     bool          `json:",omitempty"`
	HomeBalance             json.Number   `json:",omitempty"`
	RecurDataRef            ReferenceType `json:",omitempty"`
	Balance                 json.Number   `json:",omitempty"`
}

type Client

type Client struct {
	// Get this from oauth2.NewClient().
	Client *http.Client
	// contains filtered or unexported fields
}

Client is your handle to the QuickBooks API.

func NewClient

func NewClient(clientId string, clientSecret string, realmId string, isProduction bool, minorVersion string, token *BearerToken) (c *Client, err error)

NewClient initializes a new QuickBooks client for interacting with their Online API

func (*Client) CreateAccount

func (c *Client) CreateAccount(account *Account) (*Account, error)

CreateAccount creates the given account within QuickBooks

func (*Client) CreateAttachable

func (c *Client) CreateAttachable(attachable *Attachable) (*Attachable, error)

CreateAttachable creates the given Attachable on the QuickBooks server, returning the resulting Attachable object.

func (*Client) CreateBill

func (c *Client) CreateBill(bill *Bill) (*Bill, error)

CreateBill creates the given Bill on the QuickBooks server, returning the resulting Bill object.

func (*Client) CreateCreditMemo

func (c *Client) CreateCreditMemo(creditMemo *CreditMemo) (*CreditMemo, error)

CreateCreditMemo creates the given CreditMemo witin QuickBooks.

func (*Client) CreateCustomer

func (c *Client) CreateCustomer(customer *Customer) (*Customer, error)

CreateCustomer creates the given Customer on the QuickBooks server, returning the resulting Customer object.

func (*Client) CreateDeposit

func (c *Client) CreateDeposit(deposit *Deposit) (*Deposit, error)

CreateDeposit creates the given deposit within QuickBooks

func (*Client) CreateEmployee

func (c *Client) CreateEmployee(employee *Employee) (*Employee, error)

CreateEmployee creates the given employee within QuickBooks

func (*Client) CreateEstimate

func (c *Client) CreateEstimate(estimate *Estimate) (*Estimate, error)

CreateEstimate creates the given Estimate on the QuickBooks server, returning the resulting Estimate object.

func (*Client) CreateInvoice

func (c *Client) CreateInvoice(invoice *Invoice) (*Invoice, error)

CreateInvoice creates the given Invoice on the QuickBooks server, returning the resulting Invoice object.

func (*Client) CreateItem

func (c *Client) CreateItem(item *Item) (*Item, error)

func (*Client) CreatePayment

func (c *Client) CreatePayment(payment *Payment) (*Payment, error)

CreatePayment creates the given payment within QuickBooks.

func (*Client) CreateVendor

func (c *Client) CreateVendor(vendor *Vendor) (*Vendor, error)

CreateVendor creates the given Vendor on the QuickBooks server, returning the resulting Vendor object.

func (*Client) DeleteAttachable

func (c *Client) DeleteAttachable(attachable *Attachable) error

DeleteAttachable deletes the attachable

func (*Client) DeleteBill

func (c *Client) DeleteBill(bill *Bill) error

DeleteBill deletes the bill

func (*Client) DeleteCreditMemo

func (c *Client) DeleteCreditMemo(creditMemo *CreditMemo) error

DeleteCreditMemo deletes the given credit memo.

func (*Client) DeleteDeposit

func (c *Client) DeleteDeposit(deposit *Deposit) error

func (*Client) DeleteEstimate

func (c *Client) DeleteEstimate(estimate *Estimate) error

DeleteEstimate deletes the estimate

func (*Client) DeleteInvoice

func (c *Client) DeleteInvoice(invoice *Invoice) error

DeleteInvoice deletes the invoice

If the invoice was already deleted, QuickBooks returns 400 :( The response looks like this: {"Fault":{"Error":[{"Message":"Object Not Found","Detail":"Object Not Found : Something you're trying to use has been made inactive. Check the fields with accounts, invoices, items, vendors or employees.","code":"610","element":""}],"type":"ValidationFault"},"time":"2018-03-20T20:15:59.571-07:00"}

This is slightly horrifying and not documented in their API. When this happens we just return success; the goal of deleting it has been accomplished, just not by us.

func (*Client) DeletePayment

func (c *Client) DeletePayment(payment *Payment) error

DeletePayment deletes the given payment from QuickBooks.

func (*Client) DownloadAttachable

func (c *Client) DownloadAttachable(id string) (string, error)

DownloadAttachable downloads the attachable

func (*Client) FindAccountById

func (c *Client) FindAccountById(id string) (*Account, error)

FindAccountById returns an account with a given Id.

func (*Client) FindAccounts

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

FindAccounts gets the full list of Accounts in the QuickBooks account.

func (*Client) FindAttachableById

func (c *Client) FindAttachableById(id string) (*Attachable, error)

FindAttachableById finds the attachable by the given id

func (*Client) FindAttachables

func (c *Client) FindAttachables() ([]Attachable, error)

FindAttachables gets the full list of Attachables in the QuickBooks attachable.

func (*Client) FindAuthorizationUrl

func (c *Client) FindAuthorizationUrl(scope string, state string, redirectUri string) (string, error)

FindAuthorizationUrl compiles the authorization url from the discovery api's auth endpoint.

Example: qbClient.FindAuthorizationUrl("com.intuit.quickbooks.accounting", "security_token", "https://developer.intuit.com/v2/OAuth2Playground/RedirectUrl")

You can find live examples from https://developer.intuit.com/app/developer/playground

func (*Client) FindBillById

func (c *Client) FindBillById(id string) (*Bill, error)

FindBillById finds the bill by the given id

func (*Client) FindBills

func (c *Client) FindBills() ([]Bill, error)

FindBills gets the full list of Bills in the QuickBooks account.

func (*Client) FindCompanyInfo

func (c *Client) FindCompanyInfo() (*CompanyInfo, error)

FindCompanyInfo returns the QuickBooks CompanyInfo object. This is a good test to check whether you're connected.

func (*Client) FindCreditMemoById

func (c *Client) FindCreditMemoById(id string) (*CreditMemo, error)

FindCreditMemoById retrieves the given credit memo from QuickBooks.

func (*Client) FindCreditMemos

func (c *Client) FindCreditMemos() ([]CreditMemo, error)

FindCreditMemos retrieves the full list of credit memos from QuickBooks.

func (*Client) FindCustomerById

func (c *Client) FindCustomerById(id string) (*Customer, error)

FindCustomerById returns a customer with a given Id.

func (*Client) FindCustomerByName

func (c *Client) FindCustomerByName(name string) (*Customer, error)

FindCustomerByName gets a customer with a given name.

func (*Client) FindCustomerTypeById

func (c *Client) FindCustomerTypeById(id string) (*CustomerType, error)

FindCustomerTypeById returns a customerType with a given Id.

func (*Client) FindCustomers

func (c *Client) FindCustomers() ([]Customer, error)

FindCustomers gets the full list of Customers in the QuickBooks account.

func (*Client) FindDepositById

func (c *Client) FindDepositById(id string) (*Deposit, error)

FindDepositById returns an deposit with a given Id.

func (*Client) FindDeposits

func (c *Client) FindDeposits() ([]Deposit, error)

FindDeposits gets the full list of Deposits in the QuickBooks account.

func (*Client) FindEmployeeById

func (c *Client) FindEmployeeById(id string) (*Employee, error)

FindEmployeeById returns an employee with a given Id.

func (*Client) FindEmployees

func (c *Client) FindEmployees() ([]Employee, error)

FindEmployees gets the full list of Employees in the QuickBooks account.

func (*Client) FindEstimateById

func (c *Client) FindEstimateById(id string) (*Estimate, error)

FindEstimateById finds the estimate by the given id

func (*Client) FindEstimates

func (c *Client) FindEstimates() ([]Estimate, error)

FindEstimates gets the full list of Estimates in the QuickBooks account.

func (*Client) FindInvoiceById

func (c *Client) FindInvoiceById(id string) (*Invoice, error)

FindInvoiceById finds the invoice by the given id

func (*Client) FindInvoices

func (c *Client) FindInvoices() ([]Invoice, error)

FindInvoices gets the full list of Invoices in the QuickBooks account.

func (*Client) FindItemById

func (c *Client) FindItemById(id string) (*Item, error)

FindItemById returns an item with a given Id.

func (*Client) FindItems

func (c *Client) FindItems() ([]Item, error)

FindItems gets the full list of Items in the QuickBooks account.

func (*Client) FindPaymentById

func (c *Client) FindPaymentById(id string) (*Payment, error)

FindPaymentById returns an payment with a given Id.

func (*Client) FindPayments

func (c *Client) FindPayments() ([]Payment, error)

FindPayments gets the full list of Payments in the QuickBooks account.

func (*Client) FindVendorById

func (c *Client) FindVendorById(id string) (*Vendor, error)

FindVendorById finds the vendor by the given id

func (*Client) FindVendors

func (c *Client) FindVendors() ([]Vendor, error)

FindVendors gets the full list of Vendors in the QuickBooks account.

func (*Client) QueryAccounts

func (c *Client) QueryAccounts(query string) ([]Account, error)

QueryAccounts accepts an SQL query and returns all accounts found using it

func (*Client) QueryAttachables

func (c *Client) QueryAttachables(query string) ([]Attachable, error)

QueryAttachables accepts an SQL query and returns all attachables found using it

func (*Client) QueryBills

func (c *Client) QueryBills(query string) ([]Bill, error)

QueryBills accepts an SQL query and returns all bills found using it

func (*Client) QueryCreditMemos

func (c *Client) QueryCreditMemos(query string) ([]CreditMemo, error)

QueryCreditMemos accepts n SQL query and returns all credit memos found using it.

func (*Client) QueryCustomerTypes

func (c *Client) QueryCustomerTypes(query string) ([]CustomerType, error)

QueryCustomerTypes accepts an SQL query and returns all customerTypes found using it

func (*Client) QueryCustomers

func (c *Client) QueryCustomers(query string) ([]Customer, error)

QueryCustomers accepts an SQL query and returns all customers found using it

func (*Client) QueryDeposits

func (c *Client) QueryDeposits(query string) ([]Deposit, error)

QueryDeposits accepts an SQL query and returns all deposits found using it

func (*Client) QueryEmployees

func (c *Client) QueryEmployees(query string) ([]Employee, error)

QueryEmployees accepts an SQL query and returns all employees found using it

func (*Client) QueryEstimates

func (c *Client) QueryEstimates(query string) ([]Estimate, error)

QueryEstimates accepts an SQL query and returns all estimates found using it

func (*Client) QueryInvoices

func (c *Client) QueryInvoices(query string) ([]Invoice, error)

QueryInvoices accepts an SQL query and returns all invoices found using it

func (*Client) QueryItems

func (c *Client) QueryItems(query string) ([]Item, error)

QueryItems accepts an SQL query and returns all items found using it

func (*Client) QueryPayments

func (c *Client) QueryPayments(query string) ([]Payment, error)

QueryPayments accepts a SQL query and returns all payments found using it.

func (*Client) QueryVendors

func (c *Client) QueryVendors(query string) ([]Vendor, error)

QueryVendors accepts an SQL query and returns all vendors found using it

func (*Client) RefreshToken

func (c *Client) RefreshToken(refreshToken string) (*BearerToken, error)

RefreshToken Call the refresh endpoint to generate new tokens

func (*Client) RetrieveBearerToken

func (c *Client) RetrieveBearerToken(authorizationCode, redirectURI string) (*BearerToken, error)

RetrieveBearerToken Method to retrieve access token (bearer token). This method can only be called once

func (*Client) RevokeToken

func (c *Client) RevokeToken(refreshToken string) error

RevokeToken Call the revoke endpoint to revoke tokens

func (*Client) SendEstimate

func (c *Client) SendEstimate(estimateId string, emailAddress string) error

SendEstimate sends the estimate to the Estimate.BillEmail if emailAddress is left empty

func (*Client) SendInvoice

func (c *Client) SendInvoice(invoiceId string, emailAddress string) error

SendInvoice sends the invoice to the Invoice.BillEmail if emailAddress is left empty

func (*Client) UpdateAccount

func (c *Client) UpdateAccount(account *Account) (*Account, error)

UpdateAccount updates the account

func (*Client) UpdateAttachable

func (c *Client) UpdateAttachable(attachable *Attachable) (*Attachable, error)

UpdateAttachable updates the attachable

func (*Client) UpdateBill

func (c *Client) UpdateBill(bill *Bill) (*Bill, error)

UpdateBill updates the bill

func (*Client) UpdateCompanyInfo

func (c *Client) UpdateCompanyInfo(companyInfo *CompanyInfo) (*CompanyInfo, error)

UpdateCompanyInfo updates the company info

func (*Client) UpdateCreditMemo

func (c *Client) UpdateCreditMemo(creditMemo *CreditMemo) (*CreditMemo, error)

UpdateCreditMemo updates the given credit memo.

func (*Client) UpdateCustomer

func (c *Client) UpdateCustomer(customer *Customer) (*Customer, error)

UpdateCustomer updates the given Customer on the QuickBooks server, returning the resulting Customer object. It's a sparse update, as not all QB fields are present in our Customer object.

func (*Client) UpdateDeposit

func (c *Client) UpdateDeposit(deposit *Deposit) (*Deposit, error)

UpdateDeposit updates the deposit

func (*Client) UpdateEmployee

func (c *Client) UpdateEmployee(employee *Employee) (*Employee, error)

UpdateEmployee updates the employee

func (*Client) UpdateEstimate

func (c *Client) UpdateEstimate(estimate *Estimate) (*Estimate, error)

UpdateEstimate updates the estimate

func (*Client) UpdateInvoice

func (c *Client) UpdateInvoice(invoice *Invoice) (*Invoice, error)

UpdateInvoice updates the invoice

func (*Client) UpdateItem

func (c *Client) UpdateItem(item *Item) (*Item, error)

UpdateItem updates the item

func (*Client) UpdatePayment

func (c *Client) UpdatePayment(payment *Payment) (*Payment, error)

UpdatePayment updates the given payment in QuickBooks.

func (*Client) UpdateVendor

func (c *Client) UpdateVendor(vendor *Vendor) (*Vendor, error)

UpdateVendor updates the vendor

func (*Client) UploadAttachable

func (c *Client) UploadAttachable(attachable *Attachable, data io.Reader) (*Attachable, error)

UploadAttachable uploads the attachable

func (*Client) VoidEstimate

func (c *Client) VoidEstimate(estimate Estimate) error

func (*Client) VoidInvoice

func (c *Client) VoidInvoice(invoice Invoice) error

func (*Client) VoidPayment

func (c *Client) VoidPayment(payment Payment) error

VoidPayment voids the given payment in QuickBooks.

type CompanyInfo

type CompanyInfo struct {
	CompanyName string
	LegalName   string
	// CompanyAddr
	// CustomerCommunicationAddr
	// LegalAddr
	// PrimaryPhone
	// CompanyStartDate     Date
	CompanyStartDate     string
	FiscalYearStartMonth string
	Country              string
	// Email
	// WebAddr
	SupportedLanguages string
	// NameValue
	Domain    string
	Id        string
	SyncToken string
	Metadata  MetaData `json:",omitempty"`
}

CompanyInfo describes a company account.

type ContentType

type ContentType string
const (
	AI   ContentType = "application/postscript"
	CSV  ContentType = "text/csv"
	DOC  ContentType = "application/msword"
	DOCX ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
	EPS  ContentType = "application/postscript"
	GIF  ContentType = "image/gif"
	JPEG ContentType = "image/jpeg"
	JPG  ContentType = "image/jpg"
	ODS  ContentType = "application/vnd.oasis.opendocument.spreadsheet"
	PDF  ContentType = "application/pdf"
	PNG  ContentType = "image/png"
	RTF  ContentType = "text/rtf"
	TIF  ContentType = "image/tif"
	TXT  ContentType = "text/plain"
	XLS  ContentType = "application/vnd/ms-excel"
	XLSX ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
	XML  ContentType = "text/xml"
)

type CreditMemo

type CreditMemo struct {
	TotalAmt              float64         `json:",omitempty"`
	RemainingCredit       json.Number     `json:",omitempty"`
	Line                  []Line          `json:",omitempty"`
	ApplyTaxAfterDiscount bool            `json:",omitempty"`
	DocNumber             string          `json:",omitempty"`
	TxnDate               Date            `json:",omitempty"`
	Sparse                bool            `json:"sparse,omitempty"`
	CustomerMemo          MemoRef         `json:",omitempty"`
	ProjectRef            ReferenceType   `json:",omitempty"`
	Balance               json.Number     `json:",omitempty"`
	CustomerRef           ReferenceType   `json:",omitempty"`
	TxnTaxDetail          *TxnTaxDetail   `json:",omitempty"`
	SyncToken             string          `json:",omitempty"`
	CustomField           []CustomField   `json:",omitempty"`
	ShipAddr              PhysicalAddress `json:",omitempty"`
	EmailStatus           string          `json:",omitempty"`
	BillAddr              PhysicalAddress `json:",omitempty"`
	MetaData              MetaData        `json:",omitempty"`
	BillEmail             EmailAddress    `json:",omitempty"`
	Id                    string          `json:",omitempty"`
}

type CustomField

type CustomField struct {
	DefinitionId string `json:"DefinitionId,omitempty"`
	StringValue  string `json:"StringValue,omitempty"`
	Type         string `json:"Type,omitempty"`
	Name         string `json:"Name,omitempty"`
}

type Customer

type Customer struct {
	Id                 string          `json:",omitempty"`
	SyncToken          string          `json:",omitempty"`
	MetaData           MetaData        `json:",omitempty"`
	Title              string          `json:",omitempty"`
	GivenName          string          `json:",omitempty"`
	MiddleName         string          `json:",omitempty"`
	FamilyName         string          `json:",omitempty"`
	Suffix             string          `json:",omitempty"`
	DisplayName        string          `json:",omitempty"`
	FullyQualifiedName string          `json:",omitempty"`
	CompanyName        string          `json:",omitempty"`
	PrintOnCheckName   string          `json:",omitempty"`
	Active             bool            `json:",omitempty"`
	PrimaryPhone       TelephoneNumber `json:",omitempty"`
	AlternatePhone     TelephoneNumber `json:",omitempty"`
	Mobile             TelephoneNumber `json:",omitempty"`
	Fax                TelephoneNumber `json:",omitempty"`
	CustomerTypeRef    ReferenceType   `json:",omitempty"`
	PrimaryEmailAddr   *EmailAddress   `json:",omitempty"`
	WebAddr            *WebSiteAddress `json:",omitempty"`
	// DefaultTaxCodeRef
	Taxable              *bool            `json:",omitempty"`
	TaxExemptionReasonId *string          `json:",omitempty"`
	BillAddr             *PhysicalAddress `json:",omitempty"`
	ShipAddr             *PhysicalAddress `json:",omitempty"`
	Notes                string           `json:",omitempty"`
	Job                  null.Bool        `json:",omitempty"`
	BillWithParent       bool             `json:",omitempty"`
	ParentRef            ReferenceType    `json:",omitempty"`
	Level                int              `json:",omitempty"`
	// SalesTermRef
	// PaymentMethodRef
	Balance         json.Number `json:",omitempty"`
	OpenBalanceDate Date        `json:",omitempty"`
	BalanceWithJobs json.Number `json:",omitempty"`
}

Customer represents a QuickBooks Customer object.

func (*Customer) GetAddress

func (c *Customer) GetAddress() PhysicalAddress

GetAddress prioritizes the ship address, but falls back on bill address

func (*Customer) GetPrimaryEmail

func (c *Customer) GetPrimaryEmail() string

GetPrimaryEmail de-nests the PrimaryEmailAddr object

func (*Customer) GetWebsite

func (c *Customer) GetWebsite() string

GetWebsite de-nests the Website object

type CustomerType

type CustomerType struct {
	SyncToken string   `json:",omitempty"`
	Domain    string   `json:"domain,omitempty"`
	Name      string   `json:",omitempty"`
	Active    bool     `json:",omitempty"`
	Id        string   `json:",omitempty"`
	MetaData  MetaData `json:",omitempty"`
}

type Date

type Date struct {
	time.Time `json:",omitempty"`
}

Date represents a Quickbooks date

func (Date) String

func (d Date) String() string

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON removes time from parsed date

type DeliveryInfo

type DeliveryInfo struct {
	DeliveryType string
	DeliveryTime Date
}

type Deposit

type Deposit struct {
	SyncToken           string        `json:",omitempty"`
	Domain              string        `json:"domain,omitempty"`
	DepositToAccountRef ReferenceType `json:",omitempty"`
	TxnDate             Date          `json:",omitempty"`
	TotalAmt            float64       `json:",omitempty"`
	Line                []PaymentLine `json:",omitempty"`
	Id                  string        `json:",omitempty"`
	MetaData            MetaData      `json:",omitempty"`
}

type DiscountLineDetail

type DiscountLineDetail struct {
	PercentBased    bool
	DiscountPercent float32 `json:",omitempty"`
}

DiscountLineDetail ...

type DiscoveryAPI

type DiscoveryAPI struct {
	Issuer                string `json:"issuer"`
	AuthorizationEndpoint string `json:"authorization_endpoint"`
	TokenEndpoint         string `json:"token_endpoint"`
	UserinfoEndpoint      string `json:"userinfo_endpoint"`
	RevocationEndpoint    string `json:"revocation_endpoint"`
	JwksUri               string `json:"jwks_uri"`
}

type EmailAddress

type EmailAddress struct {
	Address string `json:",omitempty"`
}

EmailAddress represents a QuickBooks email address.

type Employee

type Employee struct {
	SyncToken        string          `json:",omitempty"`
	Domain           string          `json:"domain,omitempty"`
	DisplayName      string          `json:",omitempty"`
	PrimaryPhone     TelephoneNumber `json:",omitempty"`
	PrintOnCheckName string          `json:",omitempty"`
	FamilyName       string          `json:",omitempty"`
	Active           bool            `json:",omitempty"`
	SSN              string          `json:",omitempty"`
	PrimaryAddr      PhysicalAddress `json:",omitempty"`
	BillableTime     bool            `json:",omitempty"`
	GivenName        string          `json:",omitempty"`
	Id               string          `json:",omitempty"`
	MetaData         MetaData        `json:",omitempty"`
}

type EndpointUrl

type EndpointUrl string

EndpointUrl specifies the endpoint to connect to

const (
	// DiscoveryProductionEndpoint is for live apps.
	DiscoveryProductionEndpoint EndpointUrl = "https://developer.api.intuit.com/.well-known/openid_configuration"
	// DiscoverySandboxEndpoint is for testing.
	DiscoverySandboxEndpoint EndpointUrl = "https://developer.api.intuit.com/.well-known/openid_sandbox_configuration"
	// ProductionEndpoint is for live apps.
	ProductionEndpoint EndpointUrl = "https://quickbooks.api.intuit.com"
	// SandboxEndpoint is for testing.
	SandboxEndpoint EndpointUrl = "https://sandbox-quickbooks.api.intuit.com"
)

func (EndpointUrl) String

func (u EndpointUrl) String() string

type Estimate

type Estimate struct {
	DocNumber             string          `json:",omitempty"`
	SyncToken             string          `json:",omitempty"`
	Domain                string          `json:"domain,omitempty"`
	TxnStatus             string          `json:",omitempty"`
	BillEmail             EmailAddress    `json:",omitempty"`
	TxnDate               Date            `json:",omitempty"`
	TotalAmt              float64         `json:",omitempty"`
	CustomerRef           ReferenceType   `json:",omitempty"`
	CustomerMemo          MemoRef         `json:",omitempty"`
	ShipAddr              PhysicalAddress `json:",omitempty"`
	PrintStatus           string          `json:",omitempty"`
	BillAddr              PhysicalAddress `json:",omitempty"`
	EmailStatus           string          `json:",omitempty"`
	Line                  []Line          `json:",omitempty"`
	ApplyTaxAfterDiscount bool            `json:",omitempty"`
	CustomField           []CustomField   `json:",omitempty"`
	Id                    string          `json:",omitempty"`
	TxnTaxDetail          TxnTaxDetail    `json:",omitempty"`
	MetaData              MetaData        `json:",omitempty"`
}

type Failure

type Failure struct {
	Fault struct {
		Error []struct {
			Message string
			Detail  string
			Code    string `json:"code"`
			Element string `json:"element"`
		}
		Type string `json:"type"`
	}
	Time Date `json:"time"`
}

Failure is the outermost struct that holds an error response.

func (Failure) Error

func (f Failure) Error() string

Error implements the error interface.

type Invoice

type Invoice struct {
	Id            string        `json:"Id,omitempty"`
	SyncToken     string        `json:",omitempty"`
	MetaData      MetaData      `json:",omitempty"`
	CustomField   []CustomField `json:",omitempty"`
	DocNumber     string        `json:",omitempty"`
	TxnDate       Date          `json:",omitempty"`
	DepartmentRef ReferenceType `json:",omitempty"`
	PrivateNote   string        `json:",omitempty"`
	LinkedTxn     []LinkedTxn   `json:"LinkedTxn"`
	Line          []Line
	TxnTaxDetail  TxnTaxDetail `json:",omitempty"`
	CustomerRef   ReferenceType
	CustomerMemo  MemoRef         `json:",omitempty"`
	BillAddr      PhysicalAddress `json:",omitempty"`
	ShipAddr      PhysicalAddress `json:",omitempty"`
	ClassRef      ReferenceType   `json:",omitempty"`
	SalesTermRef  ReferenceType   `json:",omitempty"`
	DueDate       Date            `json:",omitempty"`
	// GlobalTaxCalculation
	ShipMethodRef                ReferenceType `json:",omitempty"`
	ShipDate                     Date          `json:",omitempty"`
	TrackingNum                  string        `json:",omitempty"`
	TotalAmt                     json.Number   `json:",omitempty"`
	CurrencyRef                  ReferenceType `json:",omitempty"`
	ExchangeRate                 json.Number   `json:",omitempty"`
	HomeAmtTotal                 json.Number   `json:",omitempty"`
	HomeBalance                  json.Number   `json:",omitempty"`
	ApplyTaxAfterDiscount        bool          `json:",omitempty"`
	PrintStatus                  string        `json:",omitempty"`
	EmailStatus                  string        `json:",omitempty"`
	BillEmail                    EmailAddress  `json:",omitempty"`
	BillEmailCC                  EmailAddress  `json:"BillEmailCc,omitempty"`
	BillEmailBCC                 EmailAddress  `json:"BillEmailBcc,omitempty"`
	DeliveryInfo                 *DeliveryInfo `json:",omitempty"`
	Balance                      json.Number   `json:",omitempty"`
	TxnSource                    string        `json:",omitempty"`
	AllowOnlineCreditCardPayment bool          `json:",omitempty"`
	AllowOnlineACHPayment        bool          `json:",omitempty"`
	Deposit                      json.Number   `json:",omitempty"`
	DepositToAccountRef          ReferenceType `json:",omitempty"`
}

Invoice represents a QuickBooks Invoice object.

type Item

type Item struct {
	Id          string   `json:"Id,omitempty"`
	SyncToken   string   `json:",omitempty"`
	MetaData    MetaData `json:",omitempty"`
	Name        string
	SKU         string `json:"Sku,omitempty"`
	Description string `json:",omitempty"`
	Active      bool   `json:",omitempty"`
	// SubItem
	// ParentRef
	// Level
	// FullyQualifiedName
	Taxable             bool        `json:",omitempty"`
	SalesTaxIncluded    bool        `json:",omitempty"`
	UnitPrice           json.Number `json:",omitempty"`
	Type                string
	IncomeAccountRef    ReferenceType
	ExpenseAccountRef   ReferenceType
	PurchaseDesc        string      `json:",omitempty"`
	PurchaseTaxIncluded bool        `json:",omitempty"`
	PurchaseCost        json.Number `json:",omitempty"`
	AssetAccountRef     ReferenceType
	TrackQtyOnHand      bool `json:",omitempty"`
	// InvStartDate Date
	QtyOnHand          json.Number   `json:",omitempty"`
	SalesTaxCodeRef    ReferenceType `json:",omitempty"`
	PurchaseTaxCodeRef ReferenceType `json:",omitempty"`
}

Item represents a QuickBooks Item object (a product type).

type Line

type Line struct {
	Id                            string `json:",omitempty"`
	LineNum                       int    `json:",omitempty"`
	Description                   string `json:",omitempty"`
	Amount                        json.Number
	DetailType                    string
	AccountBasedExpenseLineDetail AccountBasedExpenseLineDetail `json:",omitempty"`
	SalesItemLineDetail           SalesItemLineDetail           `json:",omitempty"`
	DiscountLineDetail            DiscountLineDetail            `json:",omitempty"`
	TaxLineDetail                 TaxLineDetail                 `json:",omitempty"`
}

type LinkedTxn

type LinkedTxn struct {
	TxnID   string `json:"TxnId"`
	TxnType string `json:"TxnType"`
}

type MemoRef

type MemoRef struct {
	Value string `json:"value,omitempty"`
}

MemoRef represents a QuickBooks MemoRef object.

type MetaData

type MetaData struct {
	CreateTime      Date `json:",omitempty"`
	LastUpdatedTime Date `json:",omitempty"`
}

MetaData is a timestamp of genesis and last change of a Quickbooks object

type Payment

type Payment struct {
	SyncToken           string        `json:",omitempty"`
	Domain              string        `json:"domain,omitempty"`
	DepositToAccountRef ReferenceType `json:",omitempty"`
	UnappliedAmt        float64       `json:",omitempty"`
	TxnDate             Date          `json:",omitempty"`
	TotalAmt            float64       `json:",omitempty"`
	ProcessPayment      bool          `json:",omitempty"`
	Line                []PaymentLine `json:",omitempty"`
	CustomerRef         ReferenceType `json:",omitempty"`
	Id                  string        `json:",omitempty"`
	MetaData            MetaData      `json:",omitempty"`
}

type PaymentLine

type PaymentLine struct {
	Amount    float64     `json:",omitempty"`
	LinkedTxn []LinkedTxn `json:",omitempty"`
}

type PhysicalAddress

type PhysicalAddress struct {
	Id string `json:"Id,omitempty"`
	// These lines are context-dependent! Read the QuickBooks API carefully.
	Line1   string `json:",omitempty"`
	Line2   string `json:",omitempty"`
	Line3   string `json:",omitempty"`
	Line4   string `json:",omitempty"`
	Line5   string `json:",omitempty"`
	City    string `json:",omitempty"`
	Country string `json:",omitempty"`
	// A.K.A. State.
	CountrySubDivisionCode string `json:",omitempty"`
	PostalCode             string `json:",omitempty"`
	Lat                    string `json:",omitempty"`
	Long                   string `json:",omitempty"`
}

PhysicalAddress represents a QuickBooks address.

type ReferenceType

type ReferenceType struct {
	Value string `json:"value,omitempty"`
	Name  string `json:"name,omitempty"`
	Type  string `json:"type,omitempty"`
}

ReferenceType represents a QuickBooks reference to another object.

type SalesItemLineDetail

type SalesItemLineDetail struct {
	ItemRef   ReferenceType `json:",omitempty"`
	ClassRef  ReferenceType `json:",omitempty"`
	UnitPrice json.Number   `json:",omitempty"`
	// MarkupInfo
	Qty             float32       `json:",omitempty"`
	ItemAccountRef  ReferenceType `json:",omitempty"`
	TaxCodeRef      ReferenceType `json:",omitempty"`
	ServiceDate     Date          `json:",omitempty"`
	TaxInclusiveAmt json.Number   `json:",omitempty"`
	DiscountRate    json.Number   `json:",omitempty"`
	DiscountAmt     json.Number   `json:",omitempty"`
}

SalesItemLineDetail ...

type TaxLineDetail

type TaxLineDetail struct {
	PercentBased     bool        `json:",omitempty"`
	NetAmountTaxable json.Number `json:",omitempty"`
	// TaxInclusiveAmount json.Number `json:",omitempty"`
	// OverrideDeltaAmount
	TaxPercent json.Number `json:",omitempty"`
	TaxRateRef ReferenceType
}

TaxLineDetail ...

type TelephoneNumber

type TelephoneNumber struct {
	FreeFormNumber string `json:",omitempty"`
}

TelephoneNumber represents a QuickBooks phone number.

type TxnTaxDetail

type TxnTaxDetail struct {
	TxnTaxCodeRef ReferenceType `json:",omitempty"`
	TotalTax      json.Number   `json:",omitempty"`
	TaxLine       []Line        `json:",omitempty"`
}

type Vendor

type Vendor struct {
	Id               string       `json:"Id,omitempty"`
	SyncToken        string       `json:",omitempty"`
	Title            string       `json:",omitempty"`
	GivenName        string       `json:",omitempty"`
	MiddleName       string       `json:",omitempty"`
	Suffix           string       `json:",omitempty"`
	FamilyName       string       `json:",omitempty"`
	PrimaryEmailAddr EmailAddress `json:",omitempty"`
	DisplayName      string       `json:",omitempty"`
	// ContactInfo
	APAccountRef      ReferenceType   `json:",omitempty"`
	TermRef           ReferenceType   `json:",omitempty"`
	GSTIN             string          `json:",omitempty"`
	Fax               TelephoneNumber `json:",omitempty"`
	BusinessNumber    string          `json:",omitempty"`
	CurrencyRef       ReferenceType   `json:",omitempty"`
	HasTPAR           bool            `json:",omitempty"`
	TaxReportingBasis string          `json:",omitempty"`
	Mobile            TelephoneNumber `json:",omitempty"`
	PrimaryPhone      TelephoneNumber `json:",omitempty"`
	Active            bool            `json:",omitempty"`
	AlternatePhone    TelephoneNumber `json:",omitempty"`
	MetaData          MetaData        `json:",omitempty"`
	Vendor1099        bool            `json:",omitempty"`
	BillRate          json.Number     `json:",omitempty"`
	WebAddr           *WebSiteAddress `json:",omitempty"`
	CompanyName       string          `json:",omitempty"`
	// VendorPaymentBankDetail
	TaxIdentifier       string           `json:",omitempty"`
	AcctNum             string           `json:",omitempty"`
	GSTRegistrationType string           `json:",omitempty"`
	PrintOnCheckName    string           `json:",omitempty"`
	BillAddr            *PhysicalAddress `json:",omitempty"`
	Balance             json.Number      `json:",omitempty"`
}

Vendor describes a vendor.

type WebSiteAddress

type WebSiteAddress struct {
	URI string `json:",omitempty"`
}

WebSiteAddress represents a Quickbooks Website

Jump to

Keyboard shortcuts

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