Documentation ¶
Overview ¶
Package quickbooks provides access to Intuit's QuickBooks Online API.
NOTE: This library is very incomplete. I just implemented the minimum for my use case. Pull requests welcome :)
// Do this after you go through the normal OAuth process. var client = oauth2.NewClient(ctx, tokenSource) // Initialize the client handle. var qb = quickbooks.Client{ Client: client, Endpoint: quickbooks.SandboxEndpoint, RealmID: "some company account ID"' } // Make a request! var companyInfo, err = qb.FetchCompanyInfo()
Index ¶
- type Client
- func (c *Client) CreateCustomer(customer *Customer) (*Customer, error)
- func (c *Client) CreateInvoice(inv *Invoice) (*Invoice, error)
- func (c *Client) DeleteInvoice(id, syncToken string) error
- func (c *Client) FetchCompanyInfo() (*CompanyInfo, error)
- func (c *Client) FetchCreditMemos() ([]CreditMemo, error)
- func (c *Client) FetchCustomers() ([]Customer, error)
- func (c *Client) FetchInvoices() ([]Invoice, error)
- func (c *Client) FetchItem(id string) (*Item, error)
- func (c *Client) FetchItems() ([]Item, error)
- type CompanyInfo
- type CreditMemo
- type Customer
- type Date
- type EmailAddress
- type EndpointURL
- type Invoice
- type Item
- type Line
- type MemoRef
- type MetaData
- type PhysicalAddress
- type ReferenceType
- type SalesItemLine
- type SalesItemLineDetail
- type TaxLineDetail
- type TelephoneNumber
- type TxnTaxDetail
- type WebSiteAddress
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // Get this from oauth2.NewClient(). Client *http.Client // Set to ProductionEndpoint or SandboxEndpoint. Endpoint EndpointURL // The account ID you're connecting to. RealmID string }
Client is your handle to the QuickBooks API.
func (*Client) CreateCustomer ¶
CreateCustomer creates the given Customer on the QuickBooks server, returning the resulting Customer object.
func (*Client) CreateInvoice ¶
CreateInvoice creates the given Invoice on the QuickBooks server, returning the resulting Invoice object.
func (*Client) DeleteInvoice ¶
DeleteInvoice deletes the given Invoice by ID and sync token from the QuickBooks server.
func (*Client) FetchCompanyInfo ¶
func (c *Client) FetchCompanyInfo() (*CompanyInfo, error)
FetchCompanyInfo returns the QuickBooks CompanyInfo object. This is a good test to check whether you're connected.
func (*Client) FetchCreditMemos ¶
func (c *Client) FetchCreditMemos() ([]CreditMemo, error)
FetchCreditMemos gets the full list of CreditMemos in the QuickBooks account.
func (*Client) FetchCustomers ¶
FetchCustomers gets the full list of Customers in the QuickBooks account.
func (*Client) FetchInvoices ¶
FetchInvoices gets the full list of Invoices in the QuickBooks account.
func (*Client) FetchItems ¶
FetchItems returns the list of Items in the QuickBooks account. These are basically product types, and you need them to create invoices.
type CompanyInfo ¶
type CompanyInfo struct { CompanyName string LegalName string //CompanyAddr //CustomerCommunicationAddr //LegalAddr //PrimaryPhone CompanyStartDate Date FiscalYearStartMonth string Country string //Email //WebAddr SupportedLanguages string //NameValue Domain string ID string `json:"Id"` SyncToken string Metadata MetaData `json:",omitempty"` }
CompanyInfo describes a company account.
type CreditMemo ¶
type CreditMemo struct { ID string `json:"Id,omitempty"` SyncToken string `json:",omitempty"` MetaData MetaData `json:",omitempty"` //CustomField DocNumber string `json:",omitempty"` TxnDate Date `json:",omitempty"` //DepartmentRef PrivateNote string `json:",omitempty"` Line []SalesItemLine 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"` //GlobalTaxCalculation TotalAmt json.Number `json:",omitempty"` //CurrencyRef ExchangeRate 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"` Balance json.Number `json:",omitempty"` }
CreditMemo represents a QuickBooks Credit Memo object.
type Customer ¶
type Customer struct { ID string `json:"Id,omitempty"` SyncToken string `json:",omitempty"` MetaData MetaData `json:",omitempty"` Title null.String `json:",omitempty"` GivenName null.String `json:",omitempty"` MiddleName null.String `json:",omitempty"` FamilyName null.String `json:",omitempty"` Suffix null.String `json:",omitempty"` DisplayName string `json:",omitempty"` FullyQualifiedName null.String `json:",omitempty"` CompanyName null.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"` PrimaryEmailAddr *EmailAddress `json:",omitempty"` WebAddr *WebSiteAddress `json:",omitempty"` //DefaultTaxCodeRef Taxable bool `json:",omitempty"` TaxExemptionReasonID string `json:"TaxExemptionReasonId,omitempty"` BillAddr *PhysicalAddress `json:",omitempty"` ShipAddr *PhysicalAddress `json:",omitempty"` Notes string `json:",omitempty"` Job null.Bool `json:",omitempty"` BillWithParent bool `json:",omitempty"` //ParentRef 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 ¶
GetPrimaryEmail de-nests the PrimaryEmailAddr object
func (Customer) GetWebsite ¶
GetWebsite de-nests the Website object
type Date ¶
Date represents a Quickbooks date
func (*Date) MarshalJSON ¶
func (*Date) UnmarshalJSON ¶
UnmarshalJSON removes time from parsed date
type EmailAddress ¶
type EmailAddress struct {
Address string `json:",omitempty"`
}
EmailAddress represents a QuickBooks email address.
type EndpointURL ¶
type EndpointURL string
EndpointURL specifies the endpoint to connect to.
const ( // ProductionEndpoint is for live apps. ProductionEndpoint EndpointURL = "https://quickbooks.api.intuit.com" // SandboxEndpoint is for testing. SandboxEndpoint EndpointURL = "https://sandbox-quickbooks.api.intuit.com" )
type Invoice ¶
type Invoice struct { ID string `json:"Id,omitempty"` SyncToken string `json:",omitempty"` MetaData MetaData `json:",omitempty"` //CustomField DocNumber string `json:",omitempty"` TxnDate Date `json:",omitempty"` //DepartmentRef PrivateNote string `json:",omitempty"` //LinkedTxn Line []SalesItemLine 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 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 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 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 { Amount json.Number `json:",omitempty"` // Must be set to "TaxLineDetail". DetailType string TaxLineDetail TaxLineDetail }
Line ...
type MemoRef ¶
type MemoRef struct {
Value string `json:"value,omitempty"`
}
MemoRef represents a QuickBooks MemoRef object.
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"` }
ReferenceType represents a QuickBooks reference to another object.
type SalesItemLine ¶
type SalesItemLine struct { ID string `json:"Id,omitempty"` LineNum int `json:",omitempty"` Description string `json:",omitempty"` Amount json.Number DetailType string SalesItemLineDetail SalesItemLineDetail }
SalesItemLine ...
type SalesItemLineDetail ¶
type SalesItemLineDetail struct { ItemRef ReferenceType `json:",omitempty"` ClassRef ReferenceType `json:",omitempty"` UnitPrice json.Number `json:",omitempty"` //MarkupInfo Qty json.Number `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
}
TelephoneNumber represents a QuickBooks phone number.
type TxnTaxDetail ¶
type TxnTaxDetail struct { TxnTaxCodeRef ReferenceType `json:",omitempty"` TotalTax json.Number `json:",omitempty"` TaxLine []Line `json:",omitempty"` }
TxnTaxDetail ...
type WebSiteAddress ¶
type WebSiteAddress struct {
URI string
}
WebSiteAddress represents a Quickbooks Website