Documentation ¶
Index ¶
- Constants
- func WithBaseUrl(baseUrl string) func(*Client)
- func WithClient(client *http.Client) func(*Client)
- func WithRate(opPerSecond int) func(*Client)
- type Client
- func (c *Client) CreateContact(ctx context.Context, body ContactBody) (ContactsResponse, error)
- func (c *Client) CreateFile(ctx context.Context, r io.Reader, name string) (CreateFileResponse, error)
- func (c *Client) CreateInvoice(ctx context.Context, o CreateInvoiceOptions) (InvoiceResponse, error)
- func (c *Client) DeeplinkInvoiceURL(ctx context.Context, invoiceID string, edit bool) (string, error)
- func (c *Client) DownloadFile(ctx context.Context, out io.Writer, id string) error
- func (c *Client) GetContact(ctx context.Context, id string) (ContactsContent, error)
- func (c *Client) GetContacts(ctx context.Context, p GetContactsParams) (ContactsReturn, error)
- func (c *Client) GetInvoice(ctx context.Context, id string) (InvoiceBody, error)
- func (c *Client) RenderInvoicePDF(ctx context.Context, invoiceID string) (RenderResponse, error)
- func (c *Client) Request(path string) *requests.Builder
- func (c *Client) Requestf(path string, args ...any) *requests.Builder
- func (c *Client) UpdateContact(ctx context.Context, body ContactBody) (ContactsResponse, error)
- type ContactBody
- type ContactBodyAddresses
- type ContactBodyBilling
- type ContactBodyCompany
- type ContactBodyContactPersons
- type ContactBodyCustomer
- type ContactBodyEmailAddresses
- type ContactBodyPerson
- type ContactBodyPhoneNumbers
- type ContactBodyRoles
- type ContactBodyShipping
- type ContactBodyVendor
- type ContactsContent
- type ContactsResponse
- type ContactsReturn
- type ContactsReturnAddresses
- type ContactsReturnBilling
- type ContactsReturnCompany
- type ContactsReturnContactPersons
- type ContactsReturnCustomer
- type ContactsReturnEmailAddresses
- type ContactsReturnPhoneNumbers
- type ContactsReturnRoles
- type ContactsReturnShipping
- type ContactsReturnSort
- type ContactsReturnVendor
- type CreateFileResponse
- type CreateInvoiceOptions
- type Date
- type ErrorResponse
- type GetContactsParams
- type InvoiceBody
- type InvoiceBodyAddress
- type InvoiceBodyFiles
- type InvoiceBodyLineItems
- type InvoiceBodyPaymentConditions
- type InvoiceBodyPaymentDiscountConditions
- type InvoiceBodyShippingConditions
- type InvoiceBodyTaxAmounts
- type InvoiceBodyTaxConditions
- type InvoiceBodyTotalPrice
- type InvoiceBodyUnitPrice
- type InvoiceResponse
- type LanguageOption
- type LegacyErrorResponse
- type RenderResponse
Constants ¶
const DateFormat = "2006-01-02T15:04:05.000-07:00"
Variables ¶
This section is empty.
Functions ¶
func WithBaseUrl ¶
func WithClient ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is to define the request data
func (*Client) CreateContact ¶
func (c *Client) CreateContact(ctx context.Context, body ContactBody) (ContactsResponse, error)
CreateContact creates a new contact <https://developers.lexoffice.io/docs/?shell#contacts-endpoint-create-a-contact>
func (*Client) CreateFile ¶
func (c *Client) CreateFile(ctx context.Context, r io.Reader, name string) (CreateFileResponse, error)
CreateFile uploads a file <https://developers.lexoffice.io/docs/?shell#files-endpoint-upload-a-file>
func (*Client) CreateInvoice ¶
func (c *Client) CreateInvoice(ctx context.Context, o CreateInvoiceOptions) (InvoiceResponse, error)
CreateInvoice is to create a new invoice, or to pursue a sales voucher to an invoice <https://developers.lexoffice.io/docs/?shell#invoices-endpoint-create-an-invoice> and <https://developers.lexoffice.io/docs/?shell#invoices-endpoint-pursue-to-an-invoice>
func (*Client) DeeplinkInvoiceURL ¶
func (c *Client) DeeplinkInvoiceURL(ctx context.Context, invoiceID string, edit bool) (string, error)
DeeplinkInvoiceURL is to get the deeplink url for a invoice <https://developers.lexoffice.io/docs/?shell#invoices-endpoint-deeplink-to-an-invoice>
func (*Client) DownloadFile ¶
DownloadFile downloads a file <https://developers.lexoffice.io/docs/?shell#files-endpoint-download-a-file>
func (*Client) GetContact ¶
GetContact is to get a contact by id <https://developers.lexoffice.io/docs/?shell#contacts-endpoint-retrieve-a-contact>
func (*Client) GetContacts ¶
func (c *Client) GetContacts(ctx context.Context, p GetContactsParams) (ContactsReturn, error)
GetContacts is to get a list of all contacts <https://developers.lexoffice.io/docs/?shell#contacts-endpoint-filtering-contacts>
func (*Client) GetInvoice ¶
GetInvoice is to get a invoice <https://developers.lexoffice.io/docs/?shell#invoices-endpoint-retrieve-an-invoice>
func (*Client) RenderInvoicePDF ¶
RenderInvoicePDF is to render a invoice as pdf <https://developers.lexoffice.io/docs/?shell#invoices-endpoint-render-an-invoice-document-pdf>
func (*Client) UpdateContact ¶
func (c *Client) UpdateContact(ctx context.Context, body ContactBody) (ContactsResponse, error)
UpdateContact updates existing contact <https://developers.lexoffice.io/docs/?shell#contacts-endpoint-update-a-contact>
type ContactBody ¶
type ContactBody struct { Id string `json:"id,omitempty"` Version int `json:"version"` Roles ContactBodyRoles `json:"roles"` Company *ContactBodyCompany `json:"company,omitempty"` Person *ContactBodyPerson `json:"person,omitempty"` Addresses *ContactBodyAddresses `json:"addresses,omitempty"` EmailAddresses *ContactBodyEmailAddresses `json:"emailAddresses,omitempty"` PhoneNumbers *ContactBodyPhoneNumbers `json:"phoneNumbers,omitempty"` Note string `json:"note"` Archived bool `json:"archived,omitempty"` }
ContactBody is to create a new contact
type ContactBodyAddresses ¶
type ContactBodyAddresses struct { Billing []*ContactBodyBilling `json:"billing"` Shipping []*ContactBodyShipping `json:"shipping"` }
type ContactBodyBilling ¶
type ContactBodyCompany ¶
type ContactBodyCompany struct { Name string `json:"name"` TaxNumber string `json:"taxNumber,omitempty"` VatRegistrationId string `json:"vatRegistrationId,omitempty"` AllowTaxFreeInvoices bool `json:"allowTaxFreeInvoices"` ContactPersons []*ContactBodyContactPersons `json:"contactPersons"` }
type ContactBodyCustomer ¶
type ContactBodyCustomer struct {
Number int `json:"number,omitempty"`
}
type ContactBodyPerson ¶
type ContactBodyPhoneNumbers ¶
type ContactBodyRoles ¶
type ContactBodyRoles struct { Customer *ContactBodyCustomer `json:"customer,omitempty"` Vendor *ContactBodyVendor `json:"vendor,omitempty"` }
type ContactBodyShipping ¶
type ContactBodyVendor ¶
type ContactBodyVendor struct {
Number int `json:"number,omitempty"`
}
type ContactsContent ¶
type ContactsContent struct { Id string `json:"id,omitempty"` Version int `json:"version,omitempty"` Roles ContactBodyRoles `json:"roles"` Company *ContactBodyCompany `json:"company,omitempty"` Person *ContactBodyPerson `json:"person,omitempty"` Addresses ContactBodyAddresses `json:"addresses"` EmailAddresses ContactBodyEmailAddresses `json:"emailAddresses"` PhoneNumbers ContactBodyPhoneNumbers `json:"phoneNumbers"` Note string `json:"note"` Archived bool `json:"archived,omitempty"` }
type ContactsResponse ¶
type ContactsReturn ¶
type ContactsReturn struct { Content []ContactsContent `json:"content"` First bool `json:"first"` Last bool `json:"last"` TotalPages int `json:"totalPages"` TotalElements int `json:"totalElements"` NumberOfElements int `json:"numberOfElements"` Size int `json:"size"` Number int `json:"number"` Sort []ContactsReturnSort `json:"sort"` }
ContactsReturn is to decode json data
type ContactsReturnAddresses ¶
type ContactsReturnAddresses struct { Billing []ContactsReturnBilling `json:"billing"` Shipping []ContactsReturnShipping `json:"shipping"` }
type ContactsReturnBilling ¶
type ContactsReturnCompany ¶
type ContactsReturnCompany struct { Name string `json:"name"` TaxNumber string `json:"taxNumber"` VatRegistrationId string `json:"vatRegistrationId"` AllowTaxFreeInvoices bool `json:"allowTaxFreeInvoices"` ContactPersons []ContactsReturnContactPersons `json:"contactPersons"` }
type ContactsReturnCustomer ¶
type ContactsReturnCustomer struct {
Number int `json:"number,omitempty"`
}
type ContactsReturnRoles ¶
type ContactsReturnRoles struct { Customer ContactsReturnCustomer `json:"customer"` Vendor ContactsReturnVendor `json:"vendor"` }
type ContactsReturnShipping ¶
type ContactsReturnSort ¶
type ContactsReturnVendor ¶
type ContactsReturnVendor struct {
Number int `json:"number,omitempty"`
}
type CreateFileResponse ¶
type CreateFileResponse struct {
ID string `json:"id"`
}
type CreateInvoiceOptions ¶
type CreateInvoiceOptions struct { Finalize bool PrecedingSalesVoucherID string Body InvoiceBody }
CreateInvoiceOptions represent the set of possible options when creating an invoice. if you provide a body, then the invoice will be created with the given body. if you provide a preceding sales voucher id, then the invoice will be created from the sales voucher with the given id.
type ErrorResponse ¶
type ErrorResponse struct { Timestamp Date `json:"timestamp"` Status int `json:"status"` ErrorString string `json:"error"` Path string `json:"path"` TraceID string `json:"traceId"` Message string `json:"message"` Details []struct { Violation string `json:"violation"` Field string `json:"field"` Message string `json:"message"` } `json:"details"` }
source: https://developers.lexoffice.io/docs/#error-codes-regular-error-response event-subscription, invoices
{ "timestamp": "2017-05-11T17:12:31.233+02:00", "status": 406, "error": "Not Acceptable", "path": "/v1/invoices", "traceId": "90d78d0777be", "message": "Validation failed for request. Please see details list for specific causes.", "details": [ { "violation": "NOTNULL", "field": "lineItems[0].unitPrice.taxRatePercentage", "message": "darf nicht leer sein" } ] }
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
func (ErrorResponse) String ¶
func (e ErrorResponse) String() string
type GetContactsParams ¶
type GetContactsParams struct { Page omit.Val[int] Email omit.Val[string] Name omit.Val[string] Number omit.Val[int] // filtering goes like this: // - unspecified -> no filter // - true -> only customer // - false -> only non-customer Customer omit.Val[bool] // filtering goes like this: // - unspecified -> no filter // - true -> only vendor // - false -> only non-vendor Vendor omit.Val[bool] }
type InvoiceBody ¶
type InvoiceBody struct { ID string `json:"id,omitempty"` OrganizationID string `json:"organizationId,omitempty"` CreateDate Date `json:"createDate,omitempty"` UpdatedDate Date `json:"updatedDate,omitempty"` Version int `json:"version,omitempty"` Archived bool `json:"archived,omitempty"` VoucherStatus string `json:"voucherStatus,omitempty"` VoucherNumber string `json:"voucherNumber,omitempty"` VoucherDate Date `json:"voucherDate,omitempty"` DueDate Date `json:"dueDate,omitempty"` Address InvoiceBodyAddress `json:"address,omitempty"` LineItems []InvoiceBodyLineItems `json:"lineItems,omitempty"` TotalPrice InvoiceBodyTotalPrice `json:"totalPrice,omitempty"` TaxAmounts []InvoiceBodyTaxAmounts `json:"taxAmounts,omitempty"` TaxConditions InvoiceBodyTaxConditions `json:"taxConditions,omitempty"` PaymentConditions InvoiceBodyPaymentConditions `json:"paymentConditions,omitempty"` ShippingConditions InvoiceBodyShippingConditions `json:"shippingConditions,omitempty"` Title string `json:"title,omitempty"` Introduction string `json:"introduction,omitempty"` Language LanguageOption `json:"language,omitempty"` Remark string `json:"remark,omitempty"` Files InvoiceBodyFiles `json:"files,omitempty"` }
InvoiceBody is to define body data
type InvoiceBodyAddress ¶
type InvoiceBodyAddress struct { ContactID string `json:"contactId,omitempty"` Name string `json:"name,omitempty"` Supplement string `json:"supplement,omitempty"` Street string `json:"street,omitempty"` City string `json:"city,omitempty"` Zip string `json:"zip,omitempty"` CountryCode string `json:"countryCode,omitempty"` }
type InvoiceBodyFiles ¶
type InvoiceBodyFiles struct {
ID string `json:"documentFileId,omitempty"`
}
type InvoiceBodyLineItems ¶
type InvoiceBodyLineItems struct { Id string `json:"id,omitempty"` Type string `json:"type,omitempty"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Quantity float64 `json:"quantity,omitempty"` UnitName string `json:"unitName,omitempty"` UnitPrice InvoiceBodyUnitPrice `json:"unitPrice,omitempty"` DiscountPercentage float64 `json:"discountPercentage,omitempty"` LineItemAmount float64 `json:"lineItemAmount,omitempty"` }
type InvoiceBodyPaymentConditions ¶
type InvoiceBodyPaymentConditions struct { PaymentTermLabel string `json:"paymentTermLabel,omitempty"` PaymentTermDuration int `json:"paymentTermDuration,omitempty"` PaymentDiscountConditions omit.Val[InvoiceBodyPaymentDiscountConditions] `json:"paymentDiscountConditions,omitempty"` }
type InvoiceBodyTaxAmounts ¶
type InvoiceBodyTotalPrice ¶
type InvoiceBodyTotalPrice struct { Currency string `json:"currency,omitempty"` TotalNetAmount decimal.Decimal `json:"totalNetAmount,omitempty"` TotalGrossAmount decimal.Decimal `json:"totalGrossAmount,omitempty"` TaxRatePercentage float64 `json:"taxRatePercentage,omitempty"` TotalTaxAmount decimal.Decimal `json:"totalTaxAmount,omitempty"` TotalDiscountAbsolute omit.Val[decimal.Decimal] `json:"totalDiscountAbsolute,omitempty"` TotalDiscountPercentage omit.Val[float64] `json:"totalDiscountPercentage,omitempty"` }
type InvoiceBodyUnitPrice ¶
type InvoiceResponse ¶
type InvoiceResponse struct { ID string `json:"id,omitempty"` ResourceURI string `json:"resourceUri,omitempty"` CreatedDate Date `json:"createdDate,omitempty"` UpdatedDate Date `json:"updatedDate,omitempty"` Version int `json:"version,omitempty"` }
InvoiceResponse is to decode json data
type LanguageOption ¶
type LanguageOption string
const ( LanguageOptionEN LanguageOption = "en" LanguageOptionDE LanguageOption = "de" )
type LegacyErrorResponse ¶
type LegacyErrorResponse struct { RequestID string `json:"requestId"` IssueList []struct { Key string `json:"i18nKey"` Source string `json:"source"` Type string `json:"type"` } `json:"IssueList"` }
source: https://developers.lexoffice.io/docs/#error-codes-legacy-error-response files, profile, contacts
{ "requestId":"3fb21ee4-ad26-4e2f-82af-a1197af02d08", "IssueList":[ {"i18nKey":"invalid_value","source":"company and person","type":"validation_failure"}, {"i18nKey":"missing_entity","source":"company.name","type":"validation_failure"} ] }
func (LegacyErrorResponse) Error ¶
func (e LegacyErrorResponse) Error() string
func (LegacyErrorResponse) String ¶
func (e LegacyErrorResponse) String() string
type RenderResponse ¶
type RenderResponse struct {
ID string `json:"documentFileId,omitempty"`
}