xero

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: Unlicense Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account added in v0.3.0

type Account struct {
	AccountID string `json:"AccountID"`
	Code      string `json:"Code"`
}

type Address

type Address struct {
	AddressType  string `json:"AddressType,omitempty"`
	AddressLine1 string `json:"AddressLine1,omitempty"`
	AddressLine2 string `json:"AddressLine2,omitempty"`
	AddressLine3 string `json:"AddressLine3,omitempty"`
	AddressLine4 string `json:"AddressLine4,omitempty"`
	City         string `json:"City,omitempty"`
	Region       string `json:"Region,omitempty"`
	PostalCode   string `json:"PostalCode,omitempty"`
	Country      string `json:"Country,omitempty"`
}

type Connection

type Connection struct {
	ID          string `json:"id"`
	TenantID    string `json:"tenantId"`
	AuthEventId string `json:"authEventId"`
	TenantType  string `json:"tenantType"`
	TenantName  string `json:"tenantName"`
}

type ConnectionsResponse

type ConnectionsResponse struct {
	Connections []Connection `json:"connections"`
}

type Contact

type Contact struct {
	ContactID                   string        `json:"ContactID,omitempty"`
	ContactStatus               string        `json:"ContactStatus,omitempty"`
	Name                        string        `json:"Name,omitempty"`
	FirstName                   string        `json:"FirstName,omitempty"`
	LastName                    string        `json:"LastName,omitempty"`
	EmailAddress                string        `json:"EmailAddress,omitempty"`
	BankAccountDetails          string        `json:"BankAccountDetails,omitempty"`
	CompanyNumber               string        `json:"CompanyNumber,omitempty"`
	TaxNumber                   string        `json:"TaxNumber,omitempty"`
	AccountsReceivableTaxType   string        `json:"AccountsReceivableTaxType,omitempty"`
	AccountsPayableTaxType      string        `json:"AccountsPayableTaxType,omitempty"`
	Addresses                   []Address     `json:"Addresses,omitempty"`
	Phones                      []Phone       `json:"Phones,omitempty"`
	ContactGroups               []interface{} `json:"ContactGroups,omitempty"`
	IsSupplier                  bool          `json:"IsSupplier,omitempty"`
	IsCustomer                  bool          `json:"IsCustomer,omitempty"`
	DefaultCurrency             string        `json:"DefaultCurrency,omitempty"`
	XeroNetworkKey              string        `json:"XeroNetworkKey,omitempty"`
	SalesTrackingCategories     []interface{} `json:"SalesTrackingCategories,omitempty"`
	PurchasesTrackingCategories []interface{} `json:"PurchasesTrackingCategories,omitempty"`
	ContactPersons              []interface{} `json:"ContactPersons,omitempty"`
	HasValidationErrors         bool          `json:"HasValidationErrors,omitempty"`
	UpdatedDateUTC              string        `json:"UpdatedDateUTC,omitempty"`
}

type ContactBase

type ContactBase struct {
	Name                      string    `json:"Name,omitempty"`
	FirstName                 string    `json:"FirstName,omitempty"`
	LastName                  string    `json:"LastName,omitempty"`
	EmailAddress              string    `json:"EmailAddress,omitempty"`
	BankAccountDetails        string    `json:"BankAccountDetails,omitempty"`
	CompanyNumber             string    `json:"CompanyNumber,omitempty"`
	TaxNumber                 string    `json:"TaxNumber,omitempty"`
	AccountsReceivableTaxType string    `json:"AccountsReceivableTaxType,omitempty"`
	AccountsPayableTaxType    string    `json:"AccountsPayableTaxType,omitempty"`
	Addresses                 []Address `json:"Addresses,omitempty"`
	Phones                    []Phone   `json:"Phones,omitempty"`
	DefaultCurrency           string    `json:"DefaultCurrency,omitempty"`
	XeroNetworkKey            string    `json:"XeroNetworkKey,omitempty"`
}

type ContactsResponse

type ContactsResponse struct {
	Contacts []Contact `json:"Contacts"`
}

type CreatePaymentResponse added in v0.3.0

type CreatePaymentResponse struct {
	Payments []Payment `json:"Payments"`
}

type HTTPMethod

type HTTPMethod string
const (
	GET    HTTPMethod = "GET"
	POST   HTTPMethod = "POST"
	PUT    HTTPMethod = "PUT"
	PATCH  HTTPMethod = "PATCH"
	DELETE HTTPMethod = "DELETE"
)

func (HTTPMethod) String

func (m HTTPMethod) String() string

type Invoice

type Invoice struct {
	InvoiceID       string        `json:"InvoiceID,omitempty"`
	Type            InvoiceType   `json:"Type,omitempty"`
	InvoiceNumber   string        `json:"InvoiceNumber,omitempty"`
	Reference       string        `json:"Reference,omitempty"`
	AmountDue       float64       `json:"AmountDue,omitempty"`
	AmountPaid      float64       `json:"AmountPaid,omitempty"`
	SentToContact   bool          `json:"SentToContact,omitempty"`
	CurrencyRate    float64       `json:"CurrencyRate,omitempty"`
	IsDiscounted    bool          `json:"IsDiscounted,omitempty"`
	HasErrors       bool          `json:"HasErrors,omitempty"`
	Contact         *Contact      `json:"Contact,omitempty"`
	DateString      string        `json:"DateString,omitempty"`
	Date            string        `json:"Date,omitempty"`
	DueDateString   string        `json:"DueDateString,omitempty"`
	DueDate         string        `json:"DueDate,omitempty"`
	BrandingThemeID string        `json:"BrandingThemeID,omitempty"`
	Status          InvoiceStatus `json:"Status,omitempty"`
	SubTotal        float64       `json:"SubTotal,omitempty"`
	TotalTax        float64       `json:"TotalTax,omitempty"`
	Total           float64       `json:"Total,omitempty"`
	UpdatedDateUTC  string        `json:"UpdatedDateUTC,omitempty"`
	CurrencyCode    string        `json:"CurrencyCode,omitempty"`
	Reason          string        `json:"Reason,omitempty"`
	OrderRef        string        `json:"OrderRef,omitempty"`
	LineItems       []LineItem    `json:"LineItems"`
}

type InvoiceBase

type InvoiceBase struct {
	Type            InvoiceType   `json:"Type,omitempty"`
	InvoiceNumber   string        `json:"InvoiceNumber,omitempty"`
	Reference       string        `json:"Reference,omitempty"`
	AmountDue       float64       `json:"AmountDue,omitempty"`
	AmountPaid      float64       `json:"AmountPaid,omitempty"`
	SentToContact   bool          `json:"SentToContact,omitempty"`
	CurrencyRate    float64       `json:"CurrencyRate,omitempty"`
	IsDiscounted    bool          `json:"IsDiscounted,omitempty"`
	HasErrors       bool          `json:"HasErrors,omitempty"`
	Contact         Contact       `json:"Contact"`
	DateString      string        `json:"DateString,omitempty"`
	Date            string        `json:"Date,omitempty"`
	DueDateString   string        `json:"DueDateString,omitempty"`
	DueDate         string        `json:"DueDate,omitempty"`
	BrandingThemeID string        `json:"BrandingThemeID,omitempty"`
	Status          InvoiceStatus `json:"Status,omitempty"`
	SubTotal        float64       `json:"SubTotal,omitempty"`
	TotalTax        float64       `json:"TotalTax,omitempty"`
	Total           float64       `json:"Total,omitempty"`
	UpdatedDateUTC  string        `json:"UpdatedDateUTC,omitempty"`
	CurrencyCode    string        `json:"CurrencyCode"`
	Reason          string        `json:"Reason,omitempty"`
	OrderRef        string        `json:"OrderRef,omitempty"`
	LineItems       []LineItem    `json:"LineItems"`
}

type InvoiceStatus

type InvoiceStatus int
const (
	Draft      InvoiceStatus = iota // The default status if this element is not provided with your API call
	Submitted                       // Useful if there is an approval process required
	Deleted                         // An invoice with a status of DELETED will not be included in the Aged Receivables Report
	Authorised                      // The "approved" state of an invoice ready for sending to a customer
	Voided                          // If an invoice is no longer required, it can be voided
)

func (*InvoiceStatus) MarshalJSON

func (is *InvoiceStatus) MarshalJSON() ([]byte, error)

func (InvoiceStatus) String

func (is InvoiceStatus) String() string

func (*InvoiceStatus) UnmarshalJSON

func (is *InvoiceStatus) UnmarshalJSON(data []byte) error

type InvoiceType

type InvoiceType int
const (
	ACCPAY InvoiceType = iota // A bill – commonly known as an Accounts Payable or supplier invoice
	ACCREC                    // A sales invoice – commonly known as an Accounts Receivable or customer invoice
)

func (*InvoiceType) MarshalJSON

func (it *InvoiceType) MarshalJSON() ([]byte, error)

func (InvoiceType) String

func (it InvoiceType) String() string

func (*InvoiceType) UnmarshalJSON

func (it *InvoiceType) UnmarshalJSON(data []byte) error

type InvoicesResponse

type InvoicesResponse struct {
	Invoices []Invoice `json:"Invoices"`
}

type Item

type Item struct {
	ItemId string `json:"ItemId,omitempty"` // Xero generated identifier
	Name   string `json:"Name,omitempty"`   // User defined item code
	Code   string `json:"Code,omitempty"`   // The name of the item
}

type LineItem

type LineItem struct {
	LineItemId     string  `json:"LineItemId,omitempty"`     //
	Description    string  `json:"Description,omitempty"`    //
	Quantity       float32 `json:"Quantity,omitempty"`       //
	UnitAmount     float32 `json:"UnitAmount,omitempty"`     // Lineitem unit amount. By default, unit amount will be rounded to two decimal places. You can opt in to use four decimal places by adding the querystring parameter unitdp=4 to your query. See the Rounding in Xero guide for more information.
	ItemCode       string  `json:"ItemCode,omitempty"`       //
	AccountCode    string  `json:"AccountCode,omitempty"`    //
	AccountId      string  `json:"AccountId,omitempty"`      //
	TaxType        string  `json:"TaxType,omitempty"`        //
	TaxAmount      float32 `json:"TaxAmount,omitempty"`      // The tax amount is auto calculated as a percentage of the line amount based on the tax rate
	LineAmount     float32 `json:"LineAmount,omitempty"`     // The line amount reflects the discounted price if a DiscountRate has been used i.e LineAmount = Quantity * Unit Amount * ((100 – DiscountRate)/100)
	DiscountRate   float32 `json:"DiscountRate,omitempty"`   // Percentage discount being applied to a line item. Only supported on ACCREC invoices and quotes. ACCPAY invoices and credit notes in Xero do not support discounts
	DiscountAmount float32 `json:"DiscountAmount,omitempty"` // Discount amount being applied to a line item. Only supported on ACCREC invoices and quotes. ACCPAY invoices and credit notes in Xero do not support discounts
}

type OAuth2ClientCrendentials

type OAuth2ClientCrendentials struct {
	ClientId     string
	ClientSecret string
}

type OnlineInvoice

type OnlineInvoice struct {
	OnlineInvoiceUrl string `json:"OnlineInvoiceUrl"`
}

type OnlineInvoicesResponse

type OnlineInvoicesResponse struct {
	OnlineInvoices []OnlineInvoice `json:"OnlineInvoices"`
}

type Params

type Params struct {
	TenantId string
}

type Payment added in v0.3.0

type Payment struct {
	Invoice Invoice `json:"Invoice"`
	Account Account `json:"Account"`
	Date    string  `json:"Date"`
	Amount  float64 `json:"Amount"`
}

type Phone

type Phone struct {
	PhoneType        PhoneType `json:"PhoneType"`
	PhoneNumber      string    `json:"PhoneNumber"`
	PhoneAreaCode    string    `json:"PhoneAreaCode"`
	PhoneCountryCode string    `json:"PhoneCountryCode"`
}

type PhoneType

type PhoneType int
const (
	DEFAULT PhoneType = iota
	DDI
	MOBILE
	FAX
)

func (*PhoneType) MarshalJSON

func (pt *PhoneType) MarshalJSON() ([]byte, error)

func (PhoneType) String

func (pt PhoneType) String() string

func (*PhoneType) UnmarshalJSON

func (pt *PhoneType) UnmarshalJSON(data []byte) error

type XeroClient

type XeroClient struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, baseURL string, credentials OAuth2ClientCrendentials, params Params, scopes []string) (*XeroClient, error)

func (*XeroClient) CreateContact

func (c *XeroClient) CreateContact(contact *ContactBase) (*Contact, error)

func (*XeroClient) CreateInvoice

func (c *XeroClient) CreateInvoice(invoice *InvoiceBase) (*Invoice, error)

func (*XeroClient) CreatePayment added in v0.3.0

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

func (*XeroClient) GetConnections

func (c *XeroClient) GetConnections() (*ConnectionsResponse, error)

func (*XeroClient) GetContactById

func (c *XeroClient) GetContactById(contactID string) (*Contact, error)

func (*XeroClient) GetContacts

func (c *XeroClient) GetContacts() (*ContactsResponse, error)

func (*XeroClient) GetInvoiceAsPDF added in v0.2.4

func (c *XeroClient) GetInvoiceAsPDF(invoiceID string) ([]byte, error)

func (*XeroClient) GetInvoiceByID

func (c *XeroClient) GetInvoiceByID(invoiceID string) (*Invoice, error)

func (*XeroClient) GetInvoices

func (c *XeroClient) GetInvoices() (*InvoicesResponse, error)

func (*XeroClient) PayInvoice added in v0.3.0

func (c *XeroClient) PayInvoice(invoiceID string, accountID string, amount float64) error

func (*XeroClient) SendInvoiceAsEmail

func (c *XeroClient) SendInvoiceAsEmail(invoiceID string) error

func (*XeroClient) SetDebug added in v0.2.0

func (c *XeroClient) SetDebug(debug bool)

func (*XeroClient) SetupBaseRequest

func (c *XeroClient) SetupBaseRequest(method HTTPMethod, entity string) http.Request

Jump to

Keyboard shortcuts

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