Documentation
¶
Index ¶
- func Bool(b bool) param.Opt[bool]
- func BoolPtr(v bool) *bool
- func DefaultClientOptions() []option.RequestOption
- func File(rdr io.Reader, filename string, contentType string) file
- func Float(f float64) param.Opt[float64]
- func FloatPtr(v float64) *float64
- func Int(i int64) param.Opt[int64]
- func IntPtr(v int64) *int64
- func Opt[T comparable](v T) param.Opt[T]
- func Ptr[T any](v T) *T
- func String(s string) param.Opt[string]
- func StringPtr(v string) *string
- func Time(t time.Time) param.Opt[time.Time]
- func TimePtr(v time.Time) *time.Time
- type Client
- func (r *Client) Delete(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, ...) error
- func (r *Client) Get(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Patch(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Post(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Put(ctx context.Context, path string, params any, res any, ...) error
- type Country
- type CountryListParams
- type CountryListProvincesParams
- type CountryListProvincesResponse
- type CountryListProvincesResponseData
- type CountryListResponse
- type CountryObject
- type CountryService
- type CreateInvoiceParam
- type CreateInvoiceTaxType
- type CreateInvoiceType
- type CurrencyCalculateVatPriceParams
- type CurrencyCalculateVatPriceParamsTaxType
- type CurrencyCalculateVatPriceResponse
- type CurrencyConvertParams
- type CurrencyConvertParamsTo
- type CurrencyConvertResponse
- type CurrencyConvertResponseData
- type CurrencyListParams
- type CurrencyListParamsTo
- type CurrencyListResponse
- type CurrencyListResponseData
- type CurrencyService
- func (r *CurrencyService) CalculateVatPrice(ctx context.Context, query CurrencyCalculateVatPriceParams, ...) (res *CurrencyCalculateVatPriceResponse, err error)
- func (r *CurrencyService) Convert(ctx context.Context, query CurrencyConvertParams, opts ...option.RequestOption) (res *CurrencyConvertResponse, err error)
- func (r *CurrencyService) List(ctx context.Context, query CurrencyListParams, opts ...option.RequestOption) (res *CurrencyListResponse, err error)
- type Error
- type FindRate
- type Invoice
- type InvoiceBusiness
- type InvoiceBusinessInputParam
- type InvoiceConversionInput
- type InvoiceConversionInputParam
- type InvoiceCustomer
- type InvoiceCustomerInputParam
- type InvoiceDeleteResponse
- type InvoiceItem
- type InvoiceItemAddParams
- type InvoiceItemDeleteParams
- type InvoiceItemGetParams
- type InvoiceItemGetResponse
- type InvoiceItemInputParam
- type InvoiceItemObject
- type InvoiceItemService
- func (r *InvoiceItemService) Add(ctx context.Context, invoiceID string, body InvoiceItemAddParams, ...) (res *InvoiceResponse, err error)
- func (r *InvoiceItemService) Delete(ctx context.Context, itemID string, body InvoiceItemDeleteParams, ...) (res *InvoiceResponse, err error)
- func (r *InvoiceItemService) Get(ctx context.Context, itemID string, query InvoiceItemGetParams, ...) (res *InvoiceItemGetResponse, err error)
- func (r *InvoiceItemService) Update(ctx context.Context, itemID string, params InvoiceItemUpdateParams, ...) (res *InvoiceResponse, err error)
- type InvoiceItemUpdateParams
- type InvoiceListParams
- type InvoiceListResponse
- type InvoiceNewParams
- type InvoiceObject
- type InvoiceResponse
- type InvoiceService
- func (r *InvoiceService) Delete(ctx context.Context, invoiceID string, opts ...option.RequestOption) (res *InvoiceDeleteResponse, err error)
- func (r *InvoiceService) Get(ctx context.Context, invoiceID string, opts ...option.RequestOption) (res *InvoiceResponse, err error)
- func (r *InvoiceService) List(ctx context.Context, query InvoiceListParams, opts ...option.RequestOption) (res *InvoiceListResponse, err error)
- func (r *InvoiceService) New(ctx context.Context, body InvoiceNewParams, opts ...option.RequestOption) (res *InvoiceResponse, err error)
- func (r *InvoiceService) Update(ctx context.Context, invoiceID string, body InvoiceUpdateParams, ...) (res *InvoiceResponse, err error)
- type InvoiceTaxType
- type InvoiceTotals
- type InvoiceType
- type InvoiceUpdateParams
- type Rate
- type RateCalculatePriceParams
- type RateCalculatePriceParamsTaxType
- type RateCalculatePriceResponse
- type RateCalculatePriceResponseData
- type RateDetailsParams
- type RateFindParams
- type RateListParams
- type RateListResponse
- type RateListTypesResponse
- type RateObject
- type RateOther
- type RateService
- func (r *RateService) CalculatePrice(ctx context.Context, query RateCalculatePriceParams, ...) (res *RateCalculatePriceResponse, err error)
- func (r *RateService) Details(ctx context.Context, query RateDetailsParams, opts ...option.RequestOption) (res *FindRate, err error)
- func (r *RateService) Find(ctx context.Context, query RateFindParams, opts ...option.RequestOption) (res *FindRate, err error)
- func (r *RateService) List(ctx context.Context, query RateListParams, opts ...option.RequestOption) (res *RateListResponse, err error)
- func (r *RateService) ListTypes(ctx context.Context, opts ...option.RequestOption) (res *RateListTypesResponse, err error)
- type RateWithTaxRate
- type RateWithTaxRateObject
- type SandboxGenerateKeyResponse
- type SandboxGenerateKeyResponseData
- type SandboxService
- type TaxRate
- type TaxRateObject
- type TaxRateTypesUnion
- type UsageGetResponse
- type UsageGetResponseData
- type UsageGetResponseDataRequests
- type UsageService
- type ValidateCheckParams
- type ValidateCheckResponse
- type ValidateCheckResponseData
- type ValidateCheckResponseDataCompanyEoriValidationCompany
- type ValidateCheckResponseDataCompanyUnion
- func (u ValidateCheckResponseDataCompanyUnion) AsValidateCheckResponseDataCompanyEoriValidationCompany() (v ValidateCheckResponseDataCompanyEoriValidationCompany)
- func (u ValidateCheckResponseDataCompanyUnion) AsValidateCheckResponseDataCompanyValidationCompany() (v ValidateCheckResponseDataCompanyValidationCompany)
- func (u ValidateCheckResponseDataCompanyUnion) RawJSON() string
- func (r *ValidateCheckResponseDataCompanyUnion) UnmarshalJSON(data []byte) error
- type ValidateCheckResponseDataCompanyValidationCompany
- type ValidateService
- type VatPrice
- type VatPriceObject
- type VatPriceTaxType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultClientOptions ¶
func DefaultClientOptions() []option.RequestOption
DefaultClientOptions read from the environment (VAT_SENSE_USERNAME, VAT_SENSE_PASSWORD, VAT_SENSE_BASE_URL). This should be used to initialize new clients.
func Opt ¶
func Opt[T comparable](v T) param.Opt[T]
Types ¶
type Client ¶
type Client struct {
// VAT/GST rate lookups for countries worldwide
Rates RateService
// Country and province information
Countries CountryService
// VAT and EORI number validation
Validate ValidateService
// Currency exchange rates and conversion
Currency CurrencyService
// VAT-compliant invoice management
Invoice InvoiceService
// API usage statistics
Usage UsageService
// Temporary sandbox API keys for testing
Sandbox SandboxService
// contains filtered or unexported fields
}
Client creates a struct with services and top level methods that help with interacting with the vat-sense API. You should not instantiate this client directly, and instead use the NewClient method instead.
func NewClient ¶
func NewClient(opts ...option.RequestOption) (r Client)
NewClient generates a new client with the default option read from the environment (VAT_SENSE_USERNAME, VAT_SENSE_PASSWORD, VAT_SENSE_BASE_URL). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.
func (*Client) Delete ¶
func (r *Client) Delete(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error
Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Execute ¶
func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error
Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.
If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.
The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned url.Values will be used as query strings to the url.
If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.
Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.
The response body will be deserialized into the res variable, depending on its type:
- A pointer to a *http.Response is populated by the raw response.
- A pointer to a byte array will be populated with the contents of the request body.
- A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
- A nil value will not read the response body.
For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.
func (*Client) Get ¶
func (r *Client) Get(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error
Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Patch ¶
func (r *Client) Patch(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error
Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
type Country ¶
type Country struct {
// 2-character ISO 3166-1 alpha-2 country code.
CountryCode string `json:"country_code"`
CountryName string `json:"country_name"`
// Whether the country is subject to EU VAT.
Eu bool `json:"eu"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
// Any of "country".
Object CountryObject `json:"object"`
// Whether the country is subject to VAT/GST.
Vat bool `json:"vat"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
CountryCode respjson.Field
CountryName respjson.Field
Eu respjson.Field
Latitude respjson.Field
Longitude respjson.Field
Object respjson.Field
Vat respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (*Country) UnmarshalJSON ¶
type CountryListParams ¶
type CountryListParams struct {
// A 2-character ISO 3166-1 alpha-2 country code (e.g. "GB", "FR").
CountryCode param.Opt[string] `query:"country_code,omitzero" json:"-"`
// An IPv4 or IPv6 address. If provided, the country will be determined from the IP
// address.
IPAddress param.Opt[string] `query:"ip_address,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (CountryListParams) URLQuery ¶
func (r CountryListParams) URLQuery() (v url.Values, err error)
URLQuery serializes CountryListParams's query parameters as `url.Values`.
type CountryListProvincesParams ¶
type CountryListProvincesParams struct {
// A 2-character ISO 3166-1 alpha-2 country code (e.g. "CA").
CountryCode string `query:"country_code" api:"required" json:"-"`
// contains filtered or unexported fields
}
func (CountryListProvincesParams) URLQuery ¶
func (r CountryListProvincesParams) URLQuery() (v url.Values, err error)
URLQuery serializes CountryListProvincesParams's query parameters as `url.Values`.
type CountryListProvincesResponse ¶
type CountryListProvincesResponse struct {
Code int64 `json:"code"`
Data []CountryListProvincesResponseData `json:"data"`
Success bool `json:"success"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Data respjson.Field
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (CountryListProvincesResponse) RawJSON ¶
func (r CountryListProvincesResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*CountryListProvincesResponse) UnmarshalJSON ¶
func (r *CountryListProvincesResponse) UnmarshalJSON(data []byte) error
type CountryListProvincesResponseData ¶
type CountryListProvincesResponseData struct {
CountryCode string `json:"country_code"`
// Any of "province".
Object string `json:"object"`
ProvinceCode string `json:"province_code"`
ProvinceName string `json:"province_name"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
CountryCode respjson.Field
Object respjson.Field
ProvinceCode respjson.Field
ProvinceName respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (CountryListProvincesResponseData) RawJSON ¶
func (r CountryListProvincesResponseData) RawJSON() string
Returns the unmodified JSON received from the API
func (*CountryListProvincesResponseData) UnmarshalJSON ¶
func (r *CountryListProvincesResponseData) UnmarshalJSON(data []byte) error
type CountryListResponse ¶
type CountryListResponse struct {
Code int64 `json:"code"`
Data []Country `json:"data"`
Success bool `json:"success"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Data respjson.Field
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (CountryListResponse) RawJSON ¶
func (r CountryListResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*CountryListResponse) UnmarshalJSON ¶
func (r *CountryListResponse) UnmarshalJSON(data []byte) error
type CountryObject ¶
type CountryObject string
const (
CountryObjectCountry CountryObject = "country"
)
type CountryService ¶
type CountryService struct {
// contains filtered or unexported fields
}
Country and province information
CountryService contains methods and other services that help with interacting with the vat-sense API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewCountryService method instead.
func NewCountryService ¶
func NewCountryService(opts ...option.RequestOption) (r CountryService)
NewCountryService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*CountryService) List ¶
func (r *CountryService) List(ctx context.Context, query CountryListParams, opts ...option.RequestOption) (res *CountryListResponse, err error)
Returns a list of all countries, including whether they are subject to VAT/GST and whether they are subject to EU VAT. Each country is returned as a country object.
You can optionally filter by country code or IP address.
func (*CountryService) ListProvinces ¶
func (r *CountryService) ListProvinces(ctx context.Context, query CountryListProvincesParams, opts ...option.RequestOption) (res *CountryListProvincesResponse, err error)
Retrieve a list of all provinces within a given country.
type CreateInvoiceParam ¶
type CreateInvoiceParam struct {
Business InvoiceBusinessInputParam `json:"business,omitzero" api:"required"`
// The 3-character currency code the invoice is billed in.
CurrencyCode string `json:"currency_code" api:"required"`
// The date the invoice was issued (YYYY-MM-DD or YYYY-MM-DD HH:MM:SS).
Date string `json:"date" api:"required"`
Items []InvoiceItemInputParam `json:"items,omitzero" api:"required"`
// The tax point or "time of supply" (YYYY-MM-DD or YYYY-MM-DD HH:MM:SS).
TaxPoint string `json:"tax_point" api:"required"`
// Whether the invoice is subject to VAT.
HasVat param.Opt[bool] `json:"has_vat,omitzero"`
// A unique invoice number. If not provided, defaults to an auto-incremented
// number.
InvoiceNumber param.Opt[string] `json:"invoice_number,omitzero"`
// Whether the invoice is a copy of a primary invoice.
IsCopy param.Opt[bool] `json:"is_copy,omitzero"`
// Whether the invoice is zero-rated due to reverse charge.
IsReverseCharge param.Opt[bool] `json:"is_reverse_charge,omitzero"`
// Any additional notes for the invoice.
Notes param.Opt[string] `json:"notes,omitzero"`
// Pad the auto-generated invoice number with leading zeros to this length.
PadInvoiceNumber param.Opt[int64] `json:"pad_invoice_number,omitzero"`
// A serial prepended to the auto-generated invoice number. Each unique serial has
// its own auto-increment range.
Serial param.Opt[string] `json:"serial,omitzero"`
// Whether the invoice has been zero-rated.
ZeroRated param.Opt[bool] `json:"zero_rated,omitzero"`
Conversion InvoiceConversionInputParam `json:"conversion,omitzero"`
Customer InvoiceCustomerInputParam `json:"customer,omitzero"`
// Whether item prices include or exclude VAT.
//
// Any of "incl", "excl".
TaxType CreateInvoiceTaxType `json:"tax_type,omitzero"`
// The type of invoice.
//
// Any of "sale", "refund".
Type CreateInvoiceType `json:"type,omitzero"`
// contains filtered or unexported fields
}
The properties Business, CurrencyCode, Date, Items, TaxPoint are required.
func (CreateInvoiceParam) MarshalJSON ¶
func (r CreateInvoiceParam) MarshalJSON() (data []byte, err error)
func (*CreateInvoiceParam) UnmarshalJSON ¶
func (r *CreateInvoiceParam) UnmarshalJSON(data []byte) error
type CreateInvoiceTaxType ¶
type CreateInvoiceTaxType string
Whether item prices include or exclude VAT.
const ( CreateInvoiceTaxTypeIncl CreateInvoiceTaxType = "incl" CreateInvoiceTaxTypeExcl CreateInvoiceTaxType = "excl" )
type CreateInvoiceType ¶
type CreateInvoiceType string
The type of invoice.
const ( CreateInvoiceTypeSale CreateInvoiceType = "sale" CreateInvoiceTypeRefund CreateInvoiceType = "refund" )
type CurrencyCalculateVatPriceParams ¶
type CurrencyCalculateVatPriceParams struct {
// The price to calculate on. Must be a string with exactly 2 decimal places (e.g.
// "30.00", "59.95").
Price string `query:"price" api:"required" json:"-"`
// Whether the provided price is inclusive or exclusive of VAT.
//
// Any of "incl", "excl".
TaxType CurrencyCalculateVatPriceParamsTaxType `query:"tax_type,omitzero" api:"required" json:"-"`
// A percentage VAT rate to use for the calculation.
VatRate float64 `query:"vat_rate" api:"required" json:"-"`
// contains filtered or unexported fields
}
func (CurrencyCalculateVatPriceParams) URLQuery ¶
func (r CurrencyCalculateVatPriceParams) URLQuery() (v url.Values, err error)
URLQuery serializes CurrencyCalculateVatPriceParams's query parameters as `url.Values`.
type CurrencyCalculateVatPriceParamsTaxType ¶
type CurrencyCalculateVatPriceParamsTaxType string
Whether the provided price is inclusive or exclusive of VAT.
const ( CurrencyCalculateVatPriceParamsTaxTypeIncl CurrencyCalculateVatPriceParamsTaxType = "incl" CurrencyCalculateVatPriceParamsTaxTypeExcl CurrencyCalculateVatPriceParamsTaxType = "excl" )
type CurrencyCalculateVatPriceResponse ¶
type CurrencyCalculateVatPriceResponse struct {
Code int64 `json:"code"`
Data VatPrice `json:"data"`
Success bool `json:"success"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Data respjson.Field
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (CurrencyCalculateVatPriceResponse) RawJSON ¶
func (r CurrencyCalculateVatPriceResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*CurrencyCalculateVatPriceResponse) UnmarshalJSON ¶
func (r *CurrencyCalculateVatPriceResponse) UnmarshalJSON(data []byte) error
type CurrencyConvertParams ¶
type CurrencyConvertParams struct {
// The amount to convert. Must be a string with exactly 2 decimal places (e.g.
// "39.99").
Amount string `query:"amount" api:"required" json:"-"`
// The 3-character source currency code (e.g. "USD", "CAD").
From string `query:"from" api:"required" json:"-"`
// The 3-character target currency code. Must be either "GBP" or "EUR".
//
// Any of "GBP", "EUR".
To CurrencyConvertParamsTo `query:"to,omitzero" api:"required" json:"-"`
// contains filtered or unexported fields
}
func (CurrencyConvertParams) URLQuery ¶
func (r CurrencyConvertParams) URLQuery() (v url.Values, err error)
URLQuery serializes CurrencyConvertParams's query parameters as `url.Values`.
type CurrencyConvertParamsTo ¶
type CurrencyConvertParamsTo string
The 3-character target currency code. Must be either "GBP" or "EUR".
const ( CurrencyConvertParamsToGbp CurrencyConvertParamsTo = "GBP" CurrencyConvertParamsToEur CurrencyConvertParamsTo = "EUR" )
type CurrencyConvertResponse ¶
type CurrencyConvertResponse struct {
Code int64 `json:"code"`
Data CurrencyConvertResponseData `json:"data"`
Success bool `json:"success"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Data respjson.Field
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (CurrencyConvertResponse) RawJSON ¶
func (r CurrencyConvertResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*CurrencyConvertResponse) UnmarshalJSON ¶
func (r *CurrencyConvertResponse) UnmarshalJSON(data []byte) error
type CurrencyConvertResponseData ¶
type CurrencyConvertResponseData struct {
// The original amount.
Amount float64 `json:"amount"`
// The converted amount.
Converted float64 `json:"converted"`
From string `json:"from"`
// Any of "conversion".
Object string `json:"object"`
// The exchange rate used.
Rate float64 `json:"rate"`
To string `json:"to"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Amount respjson.Field
Converted respjson.Field
From respjson.Field
Object respjson.Field
Rate respjson.Field
To respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (CurrencyConvertResponseData) RawJSON ¶
func (r CurrencyConvertResponseData) RawJSON() string
Returns the unmodified JSON received from the API
func (*CurrencyConvertResponseData) UnmarshalJSON ¶
func (r *CurrencyConvertResponseData) UnmarshalJSON(data []byte) error
type CurrencyListParams ¶
type CurrencyListParams struct {
// The 3-character currency code(s) to convert from (e.g. "USD", "CAD"). Can be a
// comma-separated list without spaces (e.g. "USD,CAD,AUD").
From param.Opt[string] `query:"from,omitzero" json:"-"`
// The 3-character target currency code. Must be either "GBP" or "EUR".
//
// Any of "GBP", "EUR".
To CurrencyListParamsTo `query:"to,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (CurrencyListParams) URLQuery ¶
func (r CurrencyListParams) URLQuery() (v url.Values, err error)
URLQuery serializes CurrencyListParams's query parameters as `url.Values`.
type CurrencyListParamsTo ¶
type CurrencyListParamsTo string
The 3-character target currency code. Must be either "GBP" or "EUR".
const ( CurrencyListParamsToGbp CurrencyListParamsTo = "GBP" CurrencyListParamsToEur CurrencyListParamsTo = "EUR" )
type CurrencyListResponse ¶
type CurrencyListResponse struct {
Code int64 `json:"code"`
Data []CurrencyListResponseData `json:"data"`
Success bool `json:"success"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Data respjson.Field
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (CurrencyListResponse) RawJSON ¶
func (r CurrencyListResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*CurrencyListResponse) UnmarshalJSON ¶
func (r *CurrencyListResponse) UnmarshalJSON(data []byte) error
type CurrencyListResponseData ¶
type CurrencyListResponseData struct {
// The 3-character source currency code.
From string `json:"from"`
// Any of "convert_rate".
Object string `json:"object"`
// The exchange rate.
Rate float64 `json:"rate"`
// The 3-character target currency code (GBP or EUR).
To string `json:"to"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
From respjson.Field
Object respjson.Field
Rate respjson.Field
To respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (CurrencyListResponseData) RawJSON ¶
func (r CurrencyListResponseData) RawJSON() string
Returns the unmodified JSON received from the API
func (*CurrencyListResponseData) UnmarshalJSON ¶
func (r *CurrencyListResponseData) UnmarshalJSON(data []byte) error
type CurrencyService ¶
type CurrencyService struct {
// contains filtered or unexported fields
}
Currency exchange rates and conversion
CurrencyService contains methods and other services that help with interacting with the vat-sense API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewCurrencyService method instead.
func NewCurrencyService ¶
func NewCurrencyService(opts ...option.RequestOption) (r CurrencyService)
NewCurrencyService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*CurrencyService) CalculateVatPrice ¶
func (r *CurrencyService) CalculateVatPrice(ctx context.Context, query CurrencyCalculateVatPriceParams, opts ...option.RequestOption) (res *CurrencyCalculateVatPriceResponse, err error)
Calculate the inclusive and exclusive VAT price on a given amount and VAT rate. This is a standalone calculation that does not look up rates by country.
func (*CurrencyService) Convert ¶
func (r *CurrencyService) Convert(ctx context.Context, query CurrencyConvertParams, opts ...option.RequestOption) (res *CurrencyConvertResponse, err error)
Convert a foreign currency amount to either GBP or EUR using official exchange rates.
GBP rates are from HMRC (updated on the 1st of every month). EUR rates are from the European Central Bank (updated around 16:00 CET on working days).
func (*CurrencyService) List ¶
func (r *CurrencyService) List(ctx context.Context, query CurrencyListParams, opts ...option.RequestOption) (res *CurrencyListResponse, err error)
Returns a list of all currency conversion rates sourced from HMRC (GBP) and the European Central Bank (EUR).
You can optionally filter by source and target currency.
type FindRate ¶
type FindRate struct {
Code int64 `json:"code"`
Data RateWithTaxRate `json:"data"`
Success bool `json:"success"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Data respjson.Field
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (*FindRate) UnmarshalJSON ¶
type Invoice ¶
type Invoice struct {
ID string `json:"id"`
Business InvoiceBusiness `json:"business"`
Conversion InvoiceConversionInput `json:"conversion" api:"nullable"`
Created time.Time `json:"created" format:"date-time"`
CurrencyCode string `json:"currency_code"`
Customer InvoiceCustomer `json:"customer" api:"nullable"`
Date string `json:"date"`
HasVat bool `json:"has_vat"`
InvoiceNumber string `json:"invoice_number"`
// Unique URL to view the invoice. Append "/pdf" to download a PDF copy.
InvoiceURL string `json:"invoice_url" format:"uri"`
IsCopy bool `json:"is_copy"`
IsReverseCharge bool `json:"is_reverse_charge"`
Items []InvoiceItem `json:"items"`
Notes string `json:"notes" api:"nullable"`
NumItems int64 `json:"num_items"`
// Any of "invoice".
Object InvoiceObject `json:"object"`
TaxPoint string `json:"tax_point"`
// Any of "incl", "excl".
TaxType InvoiceTaxType `json:"tax_type"`
Totals InvoiceTotals `json:"totals"`
// Any of "sale", "refund".
Type InvoiceType `json:"type"`
Updated time.Time `json:"updated" format:"date-time"`
ZeroRated bool `json:"zero_rated"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Business respjson.Field
Conversion respjson.Field
Created respjson.Field
CurrencyCode respjson.Field
Customer respjson.Field
Date respjson.Field
HasVat respjson.Field
InvoiceNumber respjson.Field
InvoiceURL respjson.Field
IsCopy respjson.Field
IsReverseCharge respjson.Field
Items respjson.Field
Notes respjson.Field
NumItems respjson.Field
Object respjson.Field
TaxPoint respjson.Field
TaxType respjson.Field
Totals respjson.Field
Type respjson.Field
Updated respjson.Field
ZeroRated respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (*Invoice) UnmarshalJSON ¶
type InvoiceBusiness ¶
type InvoiceBusiness struct {
Address string `json:"address"`
CompanyNumber string `json:"company_number"`
Logo string `json:"logo" api:"nullable"`
Name string `json:"name"`
VatNumber string `json:"vat_number"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Address respjson.Field
CompanyNumber respjson.Field
Logo respjson.Field
Name respjson.Field
VatNumber respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (InvoiceBusiness) RawJSON ¶
func (r InvoiceBusiness) RawJSON() string
Returns the unmodified JSON received from the API
func (*InvoiceBusiness) UnmarshalJSON ¶
func (r *InvoiceBusiness) UnmarshalJSON(data []byte) error
type InvoiceBusinessInputParam ¶
type InvoiceBusinessInputParam struct {
// Your business trading address.
Address string `json:"address" api:"required"`
// Your business trading name.
Name string `json:"name" api:"required"`
// Your business VAT number.
VatNumber string `json:"vat_number" api:"required"`
BankAccount param.Opt[string] `json:"bank_account,omitzero"`
// Your business company number.
CompanyNumber param.Opt[string] `json:"company_number,omitzero"`
Email param.Opt[string] `json:"email,omitzero" format:"email"`
// URL to your company logo (HTTPS only, .svg/.jpg/.png). Recommended 240px by
// 60px.
Logo param.Opt[string] `json:"logo,omitzero" format:"uri"`
Phone param.Opt[string] `json:"phone,omitzero"`
Website param.Opt[string] `json:"website,omitzero" format:"uri"`
// contains filtered or unexported fields
}
The properties Address, Name, VatNumber are required.
func (InvoiceBusinessInputParam) MarshalJSON ¶
func (r InvoiceBusinessInputParam) MarshalJSON() (data []byte, err error)
func (*InvoiceBusinessInputParam) UnmarshalJSON ¶
func (r *InvoiceBusinessInputParam) UnmarshalJSON(data []byte) error
type InvoiceConversionInput ¶
type InvoiceConversionInput struct {
// The 3-character currency code for the conversion.
CurrencyCode string `json:"currency_code" api:"required"`
// The rate of conversion.
Rate float64 `json:"rate" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
CurrencyCode respjson.Field
Rate respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (InvoiceConversionInput) RawJSON ¶
func (r InvoiceConversionInput) RawJSON() string
Returns the unmodified JSON received from the API
func (InvoiceConversionInput) ToParam ¶
func (r InvoiceConversionInput) ToParam() InvoiceConversionInputParam
ToParam converts this InvoiceConversionInput to a InvoiceConversionInputParam.
Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with InvoiceConversionInputParam.Overrides()
func (*InvoiceConversionInput) UnmarshalJSON ¶
func (r *InvoiceConversionInput) UnmarshalJSON(data []byte) error
type InvoiceConversionInputParam ¶
type InvoiceConversionInputParam struct {
// The 3-character currency code for the conversion.
CurrencyCode string `json:"currency_code" api:"required"`
// The rate of conversion.
Rate float64 `json:"rate" api:"required"`
// contains filtered or unexported fields
}
The properties CurrencyCode, Rate are required.
func (InvoiceConversionInputParam) MarshalJSON ¶
func (r InvoiceConversionInputParam) MarshalJSON() (data []byte, err error)
func (*InvoiceConversionInputParam) UnmarshalJSON ¶
func (r *InvoiceConversionInputParam) UnmarshalJSON(data []byte) error
type InvoiceCustomer ¶
type InvoiceCustomer struct {
Address string `json:"address"`
CompanyNumber string `json:"company_number"`
Logo string `json:"logo" api:"nullable"`
Name string `json:"name"`
VatNumber string `json:"vat_number"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Address respjson.Field
CompanyNumber respjson.Field
Logo respjson.Field
Name respjson.Field
VatNumber respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (InvoiceCustomer) RawJSON ¶
func (r InvoiceCustomer) RawJSON() string
Returns the unmodified JSON received from the API
func (*InvoiceCustomer) UnmarshalJSON ¶
func (r *InvoiceCustomer) UnmarshalJSON(data []byte) error
type InvoiceCustomerInputParam ¶
type InvoiceCustomerInputParam struct {
// The customer's trading name.
Name string `json:"name" api:"required"`
Address param.Opt[string] `json:"address,omitzero"`
CompanyNumber param.Opt[string] `json:"company_number,omitzero"`
CountryCode param.Opt[string] `json:"country_code,omitzero"`
Email param.Opt[string] `json:"email,omitzero" format:"email"`
// URL to the customer logo (HTTPS only, .jpg/.png).
Logo param.Opt[string] `json:"logo,omitzero" format:"uri"`
VatNumber param.Opt[string] `json:"vat_number,omitzero"`
// contains filtered or unexported fields
}
The property Name is required.
func (InvoiceCustomerInputParam) MarshalJSON ¶
func (r InvoiceCustomerInputParam) MarshalJSON() (data []byte, err error)
func (*InvoiceCustomerInputParam) UnmarshalJSON ¶
func (r *InvoiceCustomerInputParam) UnmarshalJSON(data []byte) error
type InvoiceDeleteResponse ¶
type InvoiceDeleteResponse struct {
Code int64 `json:"code" api:"required"`
Success bool `json:"success" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (InvoiceDeleteResponse) RawJSON ¶
func (r InvoiceDeleteResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*InvoiceDeleteResponse) UnmarshalJSON ¶
func (r *InvoiceDeleteResponse) UnmarshalJSON(data []byte) error
type InvoiceItem ¶
type InvoiceItem struct {
ID string `json:"id"`
DiscountRate float64 `json:"discount_rate" api:"nullable"`
Item string `json:"item"`
// Any of "item".
Object InvoiceItemObject `json:"object"`
PriceEach float64 `json:"price_each"`
PriceTotal float64 `json:"price_total"`
Quantity float64 `json:"quantity"`
VatRate float64 `json:"vat_rate"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
DiscountRate respjson.Field
Item respjson.Field
Object respjson.Field
PriceEach respjson.Field
PriceTotal respjson.Field
Quantity respjson.Field
VatRate respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (InvoiceItem) RawJSON ¶
func (r InvoiceItem) RawJSON() string
Returns the unmodified JSON received from the API
func (*InvoiceItem) UnmarshalJSON ¶
func (r *InvoiceItem) UnmarshalJSON(data []byte) error
type InvoiceItemAddParams ¶
type InvoiceItemAddParams struct {
Items []InvoiceItemInputParam `json:"items,omitzero" api:"required"`
// contains filtered or unexported fields
}
func (InvoiceItemAddParams) MarshalJSON ¶
func (r InvoiceItemAddParams) MarshalJSON() (data []byte, err error)
func (*InvoiceItemAddParams) UnmarshalJSON ¶
func (r *InvoiceItemAddParams) UnmarshalJSON(data []byte) error
type InvoiceItemDeleteParams ¶
type InvoiceItemDeleteParams struct {
InvoiceID string `path:"invoice_id" api:"required" json:"-"`
// contains filtered or unexported fields
}
type InvoiceItemGetParams ¶
type InvoiceItemGetParams struct {
InvoiceID string `path:"invoice_id" api:"required" json:"-"`
// contains filtered or unexported fields
}
type InvoiceItemGetResponse ¶
type InvoiceItemGetResponse struct {
Code int64 `json:"code"`
Data InvoiceItem `json:"data"`
Success bool `json:"success"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Data respjson.Field
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (InvoiceItemGetResponse) RawJSON ¶
func (r InvoiceItemGetResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*InvoiceItemGetResponse) UnmarshalJSON ¶
func (r *InvoiceItemGetResponse) UnmarshalJSON(data []byte) error
type InvoiceItemInputParam ¶
type InvoiceItemInputParam struct {
// The description of the line item.
Item string `json:"item" api:"required"`
// The price per item. Must be a decimal with 2 decimal places.
PriceEach float64 `json:"price_each" api:"required"`
// The quantity of the item.
Quantity float64 `json:"quantity" api:"required"`
// A percentage VAT rate for this item.
VatRate float64 `json:"vat_rate" api:"required"`
// A percentage discount to apply to the price.
DiscountRate param.Opt[float64] `json:"discount_rate,omitzero"`
// contains filtered or unexported fields
}
The properties Item, PriceEach, Quantity, VatRate are required.
func (InvoiceItemInputParam) MarshalJSON ¶
func (r InvoiceItemInputParam) MarshalJSON() (data []byte, err error)
func (*InvoiceItemInputParam) UnmarshalJSON ¶
func (r *InvoiceItemInputParam) UnmarshalJSON(data []byte) error
type InvoiceItemObject ¶
type InvoiceItemObject string
const (
InvoiceItemObjectItem InvoiceItemObject = "item"
)
type InvoiceItemService ¶
type InvoiceItemService struct {
// contains filtered or unexported fields
}
VAT-compliant invoice management
InvoiceItemService contains methods and other services that help with interacting with the vat-sense API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewInvoiceItemService method instead.
func NewInvoiceItemService ¶
func NewInvoiceItemService(opts ...option.RequestOption) (r InvoiceItemService)
NewInvoiceItemService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*InvoiceItemService) Add ¶
func (r *InvoiceItemService) Add(ctx context.Context, invoiceID string, body InvoiceItemAddParams, opts ...option.RequestOption) (res *InvoiceResponse, err error)
Add one or more line items to an existing invoice.
func (*InvoiceItemService) Delete ¶
func (r *InvoiceItemService) Delete(ctx context.Context, itemID string, body InvoiceItemDeleteParams, opts ...option.RequestOption) (res *InvoiceResponse, err error)
Remove a specific line item from an invoice.
func (*InvoiceItemService) Get ¶
func (r *InvoiceItemService) Get(ctx context.Context, itemID string, query InvoiceItemGetParams, opts ...option.RequestOption) (res *InvoiceItemGetResponse, err error)
Retrieve a specific line item from an invoice.
func (*InvoiceItemService) Update ¶
func (r *InvoiceItemService) Update(ctx context.Context, itemID string, params InvoiceItemUpdateParams, opts ...option.RequestOption) (res *InvoiceResponse, err error)
Update a specific line item on an invoice.
type InvoiceItemUpdateParams ¶
type InvoiceItemUpdateParams struct {
InvoiceID string `path:"invoice_id" api:"required" json:"-"`
InvoiceItemInput InvoiceItemInputParam
// contains filtered or unexported fields
}
func (InvoiceItemUpdateParams) MarshalJSON ¶
func (r InvoiceItemUpdateParams) MarshalJSON() (data []byte, err error)
func (*InvoiceItemUpdateParams) UnmarshalJSON ¶
func (r *InvoiceItemUpdateParams) UnmarshalJSON(data []byte) error
type InvoiceListParams ¶
type InvoiceListParams struct {
// Number of invoices to return (default 10, max 100).
Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
// Number of invoices to skip (default 0).
Offset param.Opt[int64] `query:"offset,omitzero" json:"-"`
// Search query to filter invoices.
Search param.Opt[string] `query:"search,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (InvoiceListParams) URLQuery ¶
func (r InvoiceListParams) URLQuery() (v url.Values, err error)
URLQuery serializes InvoiceListParams's query parameters as `url.Values`.
type InvoiceListResponse ¶
type InvoiceListResponse struct {
Code int64 `json:"code"`
Data []Invoice `json:"data"`
Success bool `json:"success"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Data respjson.Field
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (InvoiceListResponse) RawJSON ¶
func (r InvoiceListResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*InvoiceListResponse) UnmarshalJSON ¶
func (r *InvoiceListResponse) UnmarshalJSON(data []byte) error
type InvoiceNewParams ¶
type InvoiceNewParams struct {
CreateInvoice CreateInvoiceParam
// contains filtered or unexported fields
}
func (InvoiceNewParams) MarshalJSON ¶
func (r InvoiceNewParams) MarshalJSON() (data []byte, err error)
func (*InvoiceNewParams) UnmarshalJSON ¶
func (r *InvoiceNewParams) UnmarshalJSON(data []byte) error
type InvoiceObject ¶
type InvoiceObject string
const (
InvoiceObjectInvoice InvoiceObject = "invoice"
)
type InvoiceResponse ¶
type InvoiceResponse struct {
Code int64 `json:"code"`
Data Invoice `json:"data"`
Success bool `json:"success"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Data respjson.Field
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (InvoiceResponse) RawJSON ¶
func (r InvoiceResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*InvoiceResponse) UnmarshalJSON ¶
func (r *InvoiceResponse) UnmarshalJSON(data []byte) error
type InvoiceService ¶
type InvoiceService struct {
// VAT-compliant invoice management
Item InvoiceItemService
// contains filtered or unexported fields
}
VAT-compliant invoice management
InvoiceService contains methods and other services that help with interacting with the vat-sense API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewInvoiceService method instead.
func NewInvoiceService ¶
func NewInvoiceService(opts ...option.RequestOption) (r InvoiceService)
NewInvoiceService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*InvoiceService) Delete ¶
func (r *InvoiceService) Delete(ctx context.Context, invoiceID string, opts ...option.RequestOption) (res *InvoiceDeleteResponse, err error)
Permanently delete an invoice.
func (*InvoiceService) Get ¶
func (r *InvoiceService) Get(ctx context.Context, invoiceID string, opts ...option.RequestOption) (res *InvoiceResponse, err error)
Retrieve a specific invoice by its ID.
func (*InvoiceService) List ¶
func (r *InvoiceService) List(ctx context.Context, query InvoiceListParams, opts ...option.RequestOption) (res *InvoiceListResponse, err error)
Retrieve a paginated list of all invoices.
func (*InvoiceService) New ¶
func (r *InvoiceService) New(ctx context.Context, body InvoiceNewParams, opts ...option.RequestOption) (res *InvoiceResponse, err error)
Create a new VAT-compliant invoice. VAT Sense will automatically calculate the totals based on the items provided.
Not available with sandbox API keys.
func (*InvoiceService) Update ¶
func (r *InvoiceService) Update(ctx context.Context, invoiceID string, body InvoiceUpdateParams, opts ...option.RequestOption) (res *InvoiceResponse, err error)
Update an existing invoice. Only the fields provided will be updated.
type InvoiceTaxType ¶
type InvoiceTaxType string
const ( InvoiceTaxTypeIncl InvoiceTaxType = "incl" InvoiceTaxTypeExcl InvoiceTaxType = "excl" )
type InvoiceTotals ¶
type InvoiceTotals struct {
// Total discount amount.
Discount float64 `json:"discount"`
// Total before VAT.
Subtotal float64 `json:"subtotal"`
// Grand total.
Total float64 `json:"total"`
// Total VAT amount.
Vat float64 `json:"vat"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Discount respjson.Field
Subtotal respjson.Field
Total respjson.Field
Vat respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (InvoiceTotals) RawJSON ¶
func (r InvoiceTotals) RawJSON() string
Returns the unmodified JSON received from the API
func (*InvoiceTotals) UnmarshalJSON ¶
func (r *InvoiceTotals) UnmarshalJSON(data []byte) error
type InvoiceType ¶
type InvoiceType string
const ( InvoiceTypeSale InvoiceType = "sale" InvoiceTypeRefund InvoiceType = "refund" )
type InvoiceUpdateParams ¶
type InvoiceUpdateParams struct {
CreateInvoice CreateInvoiceParam
// contains filtered or unexported fields
}
func (InvoiceUpdateParams) MarshalJSON ¶
func (r InvoiceUpdateParams) MarshalJSON() (data []byte, err error)
func (*InvoiceUpdateParams) UnmarshalJSON ¶
func (r *InvoiceUpdateParams) UnmarshalJSON(data []byte) error
type Rate ¶
type Rate struct {
// 2-character ISO 3166-1 alpha-2 country code.
CountryCode string `json:"country_code"`
CountryName string `json:"country_name"`
// Whether the country is an EU member.
Eu bool `json:"eu"`
// Any of "rate".
Object RateObject `json:"object"`
// A list of other tax rates. Null if no additional rates exist.
Other []RateOther `json:"other" api:"nullable"`
Standard TaxRate `json:"standard"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
CountryCode respjson.Field
CountryName respjson.Field
Eu respjson.Field
Object respjson.Field
Other respjson.Field
Standard respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (*Rate) UnmarshalJSON ¶
type RateCalculatePriceParams ¶
type RateCalculatePriceParams struct {
// The price to calculate on. Must be a string with exactly 2 decimal places (e.g.
// "30.00", "59.95").
Price string `query:"price" api:"required" json:"-"`
// Whether the provided price is inclusive or exclusive of VAT.
//
// Any of "incl", "excl".
TaxType RateCalculatePriceParamsTaxType `query:"tax_type,omitzero" api:"required" json:"-"`
// A 2-character ISO 3166-1 alpha-2 country code (e.g. "GB", "FR").
CountryCode param.Opt[string] `query:"country_code,omitzero" json:"-"`
// Filter results by EU membership. Use 1 for EU countries only, 0 for non-EU only.
Eu param.Opt[bool] `query:"eu,omitzero" json:"-"`
// An IPv4 or IPv6 address. If provided, the country will be determined from the IP
// address.
IPAddress param.Opt[string] `query:"ip_address,omitzero" json:"-"`
// A 2-character province code (e.g. "NU", "NT"). If providing a province code, you
// must also provide the relevant country_code.
ProvinceCode param.Opt[string] `query:"province_code,omitzero" json:"-"`
// The product type to find the applicable rate for. See the /rates/types endpoint
// for a full list of valid values.
Type param.Opt[string] `query:"type,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (RateCalculatePriceParams) URLQuery ¶
func (r RateCalculatePriceParams) URLQuery() (v url.Values, err error)
URLQuery serializes RateCalculatePriceParams's query parameters as `url.Values`.
type RateCalculatePriceParamsTaxType ¶
type RateCalculatePriceParamsTaxType string
Whether the provided price is inclusive or exclusive of VAT.
const ( RateCalculatePriceParamsTaxTypeIncl RateCalculatePriceParamsTaxType = "incl" RateCalculatePriceParamsTaxTypeExcl RateCalculatePriceParamsTaxType = "excl" )
type RateCalculatePriceResponse ¶
type RateCalculatePriceResponse struct {
Code int64 `json:"code"`
Data RateCalculatePriceResponseData `json:"data"`
Success bool `json:"success"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Data respjson.Field
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (RateCalculatePriceResponse) RawJSON ¶
func (r RateCalculatePriceResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*RateCalculatePriceResponse) UnmarshalJSON ¶
func (r *RateCalculatePriceResponse) UnmarshalJSON(data []byte) error
type RateCalculatePriceResponseData ¶
type RateCalculatePriceResponseData struct {
CountryCode string `json:"country_code"`
CountryName string `json:"country_name"`
Eu bool `json:"eu"`
// Any of "rate".
Object string `json:"object"`
TaxRate TaxRate `json:"tax_rate"`
VatPrice VatPrice `json:"vat_price"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
CountryCode respjson.Field
CountryName respjson.Field
Eu respjson.Field
Object respjson.Field
TaxRate respjson.Field
VatPrice respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (RateCalculatePriceResponseData) RawJSON ¶
func (r RateCalculatePriceResponseData) RawJSON() string
Returns the unmodified JSON received from the API
func (*RateCalculatePriceResponseData) UnmarshalJSON ¶
func (r *RateCalculatePriceResponseData) UnmarshalJSON(data []byte) error
type RateDetailsParams ¶
type RateDetailsParams struct {
// A 2-character ISO 3166-1 alpha-2 country code (e.g. "GB", "FR").
CountryCode param.Opt[string] `query:"country_code,omitzero" json:"-"`
// Filter results by EU membership. Use 1 for EU countries only, 0 for non-EU only.
Eu param.Opt[bool] `query:"eu,omitzero" json:"-"`
// An IPv4 or IPv6 address. If provided, the country will be determined from the IP
// address.
IPAddress param.Opt[string] `query:"ip_address,omitzero" json:"-"`
// A historical date to retrieve rates for (format "YYYY-MM-DD HH:MM:SS"). Must be
// a past date.
Period param.Opt[time.Time] `query:"period,omitzero" format:"date-time" json:"-"`
// A 2-character province code (e.g. "NU", "NT"). If providing a province code, you
// must also provide the relevant country_code.
ProvinceCode param.Opt[string] `query:"province_code,omitzero" json:"-"`
// The product type to find the applicable rate for. See the /rates/types endpoint
// for a full list of valid values.
Type param.Opt[string] `query:"type,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (RateDetailsParams) URLQuery ¶
func (r RateDetailsParams) URLQuery() (v url.Values, err error)
URLQuery serializes RateDetailsParams's query parameters as `url.Values`.
type RateFindParams ¶
type RateFindParams struct {
// A 2-character ISO 3166-1 alpha-2 country code (e.g. "GB", "FR").
CountryCode param.Opt[string] `query:"country_code,omitzero" json:"-"`
// Filter results by EU membership. Use 1 for EU countries only, 0 for non-EU only.
Eu param.Opt[bool] `query:"eu,omitzero" json:"-"`
// An IPv4 or IPv6 address. If provided, the country will be determined from the IP
// address.
IPAddress param.Opt[string] `query:"ip_address,omitzero" json:"-"`
// A historical date to retrieve rates for (format "YYYY-MM-DD HH:MM:SS"). Must be
// a past date.
Period param.Opt[time.Time] `query:"period,omitzero" format:"date-time" json:"-"`
// A 2-character province code (e.g. "NU", "NT"). If providing a province code, you
// must also provide the relevant country_code.
ProvinceCode param.Opt[string] `query:"province_code,omitzero" json:"-"`
// The product type to find the applicable rate for. See the /rates/types endpoint
// for a full list of valid values.
Type param.Opt[string] `query:"type,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (RateFindParams) URLQuery ¶
func (r RateFindParams) URLQuery() (v url.Values, err error)
URLQuery serializes RateFindParams's query parameters as `url.Values`.
type RateListParams ¶
type RateListParams struct {
// A 2-character ISO 3166-1 alpha-2 country code (e.g. "GB", "FR").
CountryCode param.Opt[string] `query:"country_code,omitzero" json:"-"`
// Filter results by EU membership. Use 1 for EU countries only, 0 for non-EU only.
Eu param.Opt[bool] `query:"eu,omitzero" json:"-"`
// An IPv4 or IPv6 address. If provided, the country will be determined from the IP
// address.
IPAddress param.Opt[string] `query:"ip_address,omitzero" json:"-"`
// A historical date to retrieve rates for (format "YYYY-MM-DD HH:MM:SS"). Must be
// a past date.
Period param.Opt[time.Time] `query:"period,omitzero" format:"date-time" json:"-"`
// contains filtered or unexported fields
}
func (RateListParams) URLQuery ¶
func (r RateListParams) URLQuery() (v url.Values, err error)
URLQuery serializes RateListParams's query parameters as `url.Values`.
type RateListResponse ¶
type RateListResponse struct {
Code int64 `json:"code"`
Data []Rate `json:"data"`
Success bool `json:"success"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Data respjson.Field
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (RateListResponse) RawJSON ¶
func (r RateListResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*RateListResponse) UnmarshalJSON ¶
func (r *RateListResponse) UnmarshalJSON(data []byte) error
type RateListTypesResponse ¶
type RateListTypesResponse struct {
Code int64 `json:"code"`
Data []string `json:"data"`
Success bool `json:"success"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Data respjson.Field
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (RateListTypesResponse) RawJSON ¶
func (r RateListTypesResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*RateListTypesResponse) UnmarshalJSON ¶
func (r *RateListTypesResponse) UnmarshalJSON(data []byte) error
type RateOther ¶
type RateOther struct {
// The province this rate applies to, if applicable.
Province string `json:"province" api:"nullable"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Province respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
TaxRate
}
func (*RateOther) UnmarshalJSON ¶
type RateService ¶
type RateService struct {
// contains filtered or unexported fields
}
VAT/GST rate lookups for countries worldwide
RateService contains methods and other services that help with interacting with the vat-sense API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewRateService method instead.
func NewRateService ¶
func NewRateService(opts ...option.RequestOption) (r RateService)
NewRateService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*RateService) CalculatePrice ¶
func (r *RateService) CalculatePrice(ctx context.Context, query RateCalculatePriceParams, opts ...option.RequestOption) (res *RateCalculatePriceResponse, err error)
Combines the functionality of the "Find a tax rate" and "VAT price calculation" endpoints to return the particular VAT price for an applicable VAT rate. Requires both a location (country_code or ip_address) and a price to calculate.
func (*RateService) Details ¶
func (r *RateService) Details(ctx context.Context, query RateDetailsParams, opts ...option.RequestOption) (res *FindRate, err error)
Get detailed tax rate information for a location, including all applicable rate classes (standard, reduced, zero, etc.).
func (*RateService) Find ¶
func (r *RateService) Find(ctx context.Context, query RateFindParams, opts ...option.RequestOption) (res *FindRate, err error)
A handy endpoint for finding a rate that applies to a particular country and optional product type, based on country code or IP address.
If no type is provided, or no specific rate is applied to the given type, then the standard rate will be returned if the country is subject to tax.
If the country is not subject to VAT/GST then an error response will be returned, indicating no tax applies.
func (*RateService) List ¶
func (r *RateService) List(ctx context.Context, query RateListParams, opts ...option.RequestOption) (res *RateListResponse, err error)
Returns a list of VAT/GST rates for all countries, sorted alphabetically by country code. Each rate is returned as a rate object containing the standard rate and any other applicable rates.
You can optionally filter by country code, IP address, or EU membership.
func (*RateService) ListTypes ¶
func (r *RateService) ListTypes(ctx context.Context, opts ...option.RequestOption) (res *RateListTypesResponse, err error)
Returns a list of all available product types that can be used to filter tax rates.
type RateWithTaxRate ¶
type RateWithTaxRate struct {
CountryCode string `json:"country_code"`
CountryName string `json:"country_name"`
Eu bool `json:"eu"`
// Any of "rate".
Object RateWithTaxRateObject `json:"object"`
TaxRate TaxRate `json:"tax_rate"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
CountryCode respjson.Field
CountryName respjson.Field
Eu respjson.Field
Object respjson.Field
TaxRate respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (RateWithTaxRate) RawJSON ¶
func (r RateWithTaxRate) RawJSON() string
Returns the unmodified JSON received from the API
func (*RateWithTaxRate) UnmarshalJSON ¶
func (r *RateWithTaxRate) UnmarshalJSON(data []byte) error
type RateWithTaxRateObject ¶
type RateWithTaxRateObject string
const (
RateWithTaxRateObjectRate RateWithTaxRateObject = "rate"
)
type SandboxGenerateKeyResponse ¶
type SandboxGenerateKeyResponse struct {
Code int64 `json:"code"`
Data SandboxGenerateKeyResponseData `json:"data"`
Success bool `json:"success"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Data respjson.Field
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (SandboxGenerateKeyResponse) RawJSON ¶
func (r SandboxGenerateKeyResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*SandboxGenerateKeyResponse) UnmarshalJSON ¶
func (r *SandboxGenerateKeyResponse) UnmarshalJSON(data []byte) error
type SandboxGenerateKeyResponseData ¶
type SandboxGenerateKeyResponseData struct {
AllowedEndpoints []string `json:"allowed_endpoints"`
ExpiresAt time.Time `json:"expires_at" format:"date-time"`
// The temporary sandbox API key.
Key string `json:"key"`
RequestsRemaining int64 `json:"requests_remaining"`
SignupURL string `json:"signup_url" format:"uri"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
AllowedEndpoints respjson.Field
ExpiresAt respjson.Field
Key respjson.Field
RequestsRemaining respjson.Field
SignupURL respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (SandboxGenerateKeyResponseData) RawJSON ¶
func (r SandboxGenerateKeyResponseData) RawJSON() string
Returns the unmodified JSON received from the API
func (*SandboxGenerateKeyResponseData) UnmarshalJSON ¶
func (r *SandboxGenerateKeyResponseData) UnmarshalJSON(data []byte) error
type SandboxService ¶
type SandboxService struct {
// contains filtered or unexported fields
}
Temporary sandbox API keys for testing
SandboxService contains methods and other services that help with interacting with the vat-sense API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewSandboxService method instead.
func NewSandboxService ¶
func NewSandboxService(opts ...option.RequestOption) (r SandboxService)
NewSandboxService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*SandboxService) GenerateKey ¶
func (r *SandboxService) GenerateKey(ctx context.Context, opts ...option.RequestOption) (res *SandboxGenerateKeyResponse, err error)
Generate a temporary sandbox API key for testing. Sandbox keys have limited request allowances and restricted endpoint access (no invoice endpoints). Rate limited to 1 key per IP address per 6 hours.
type TaxRate ¶
type TaxRate struct {
// The rate class (e.g. "standard", "reduced", "zero").
Class string `json:"class"`
// A description of what goods/services this rate applies to.
Description string `json:"description"`
// Any of "tax_rate".
Object TaxRateObject `json:"object"`
// The tax rate percentage.
Rate float64 `json:"rate"`
// Comma-separated list of product types this rate applies to, or false if it
// applies generally.
Types TaxRateTypesUnion `json:"types"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Class respjson.Field
Description respjson.Field
Object respjson.Field
Rate respjson.Field
Types respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (*TaxRate) UnmarshalJSON ¶
type TaxRateObject ¶
type TaxRateObject string
const (
TaxRateObjectTaxRate TaxRateObject = "tax_rate"
)
type TaxRateTypesUnion ¶
type TaxRateTypesUnion struct {
// This field will be present if the value is a [string] instead of an object.
OfString string `json:",inline"`
// This field will be present if the value is a [bool] instead of an object.
OfBool bool `json:",inline"`
JSON struct {
OfString respjson.Field
OfBool respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
TaxRateTypesUnion contains all possible properties and values from [string], [bool].
Use the methods beginning with 'As' to cast the union to one of its variants.
If the underlying value is not a json object, one of the following properties will be valid: OfString OfBool]
func (TaxRateTypesUnion) AsBool ¶
func (u TaxRateTypesUnion) AsBool() (v bool)
func (TaxRateTypesUnion) AsString ¶
func (u TaxRateTypesUnion) AsString() (v string)
func (TaxRateTypesUnion) RawJSON ¶
func (u TaxRateTypesUnion) RawJSON() string
Returns the unmodified JSON received from the API
func (*TaxRateTypesUnion) UnmarshalJSON ¶
func (r *TaxRateTypesUnion) UnmarshalJSON(data []byte) error
type UsageGetResponse ¶
type UsageGetResponse struct {
Code int64 `json:"code"`
Data UsageGetResponseData `json:"data"`
Success bool `json:"success"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Data respjson.Field
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (UsageGetResponse) RawJSON ¶
func (r UsageGetResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*UsageGetResponse) UnmarshalJSON ¶
func (r *UsageGetResponse) UnmarshalJSON(data []byte) error
type UsageGetResponseData ¶
type UsageGetResponseData struct {
Requests UsageGetResponseDataRequests `json:"requests"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Requests respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (UsageGetResponseData) RawJSON ¶
func (r UsageGetResponseData) RawJSON() string
Returns the unmodified JSON received from the API
func (*UsageGetResponseData) UnmarshalJSON ¶
func (r *UsageGetResponseData) UnmarshalJSON(data []byte) error
type UsageGetResponseDataRequests ¶
type UsageGetResponseDataRequests struct {
// Requests remaining before the limit is reached.
Remaining int64 `json:"remaining"`
// Total requests allowed on your plan.
Total int64 `json:"total"`
// Requests used in the last 30 days.
Used int64 `json:"used"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Remaining respjson.Field
Total respjson.Field
Used respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (UsageGetResponseDataRequests) RawJSON ¶
func (r UsageGetResponseDataRequests) RawJSON() string
Returns the unmodified JSON received from the API
func (*UsageGetResponseDataRequests) UnmarshalJSON ¶
func (r *UsageGetResponseDataRequests) UnmarshalJSON(data []byte) error
type UsageService ¶
type UsageService struct {
// contains filtered or unexported fields
}
API usage statistics
UsageService contains methods and other services that help with interacting with the vat-sense API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewUsageService method instead.
func NewUsageService ¶
func NewUsageService(opts ...option.RequestOption) (r UsageService)
NewUsageService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*UsageService) Get ¶
func (r *UsageService) Get(ctx context.Context, opts ...option.RequestOption) (res *UsageGetResponse, err error)
Check your used and remaining API requests.
type ValidateCheckParams ¶
type ValidateCheckParams struct {
// The EORI number to validate. Must include the leading 2-character country code
// (e.g. "GB123456789123"). UK and EU only.
EoriNumber param.Opt[string] `query:"eori_number,omitzero" json:"-"`
// Your own VAT number. If supplied, the response will include a unique
// consultation number issued by the relevant authority (VIES or HMRC). Must
// include the leading 2-character country code.
//
// Note: GB requester numbers only work for GB validations; EU requester numbers
// only work for EU validations. Cross-region is not supported.
RequesterVatNumber param.Opt[string] `query:"requester_vat_number,omitzero" json:"-"`
// The VAT number to validate. Must include the leading 2-character country code
// (e.g. "GB288305674", "FR12345678901").
VatNumber param.Opt[string] `query:"vat_number,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (ValidateCheckParams) URLQuery ¶
func (r ValidateCheckParams) URLQuery() (v url.Values, err error)
URLQuery serializes ValidateCheckParams's query parameters as `url.Values`.
type ValidateCheckResponse ¶
type ValidateCheckResponse struct {
Code int64 `json:"code"`
Data ValidateCheckResponseData `json:"data"`
Success bool `json:"success"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Data respjson.Field
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (ValidateCheckResponse) RawJSON ¶
func (r ValidateCheckResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*ValidateCheckResponse) UnmarshalJSON ¶
func (r *ValidateCheckResponse) UnmarshalJSON(data []byte) error
type ValidateCheckResponseData ¶
type ValidateCheckResponseData struct {
Company ValidateCheckResponseDataCompanyUnion `json:"company"`
// Official consultation number (only returned when requester_vat_number is
// provided).
ConsultationNumber string `json:"consultation_number" api:"nullable"`
// Whether the VAT/EORI number is valid.
Valid bool `json:"valid"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Company respjson.Field
ConsultationNumber respjson.Field
Valid respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (ValidateCheckResponseData) RawJSON ¶
func (r ValidateCheckResponseData) RawJSON() string
Returns the unmodified JSON received from the API
func (*ValidateCheckResponseData) UnmarshalJSON ¶
func (r *ValidateCheckResponseData) UnmarshalJSON(data []byte) error
type ValidateCheckResponseDataCompanyEoriValidationCompany ¶
type ValidateCheckResponseDataCompanyEoriValidationCompany struct {
CompanyAddress string `json:"company_address"`
CompanyName string `json:"company_name"`
CountryCode string `json:"country_code"`
// The EORI number (without country code prefix).
EoriNumber string `json:"eori_number"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
CompanyAddress respjson.Field
CompanyName respjson.Field
CountryCode respjson.Field
EoriNumber respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (ValidateCheckResponseDataCompanyEoriValidationCompany) RawJSON ¶
func (r ValidateCheckResponseDataCompanyEoriValidationCompany) RawJSON() string
Returns the unmodified JSON received from the API
func (*ValidateCheckResponseDataCompanyEoriValidationCompany) UnmarshalJSON ¶
func (r *ValidateCheckResponseDataCompanyEoriValidationCompany) UnmarshalJSON(data []byte) error
type ValidateCheckResponseDataCompanyUnion ¶
type ValidateCheckResponseDataCompanyUnion struct {
CompanyAddress string `json:"company_address"`
CompanyName string `json:"company_name"`
CountryCode string `json:"country_code"`
// This field is from variant [ValidateCheckResponseDataCompanyValidationCompany].
VatNumber string `json:"vat_number"`
// This field is from variant
// [ValidateCheckResponseDataCompanyEoriValidationCompany].
EoriNumber string `json:"eori_number"`
JSON struct {
CompanyAddress respjson.Field
CompanyName respjson.Field
CountryCode respjson.Field
VatNumber respjson.Field
EoriNumber respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
ValidateCheckResponseDataCompanyUnion contains all possible properties and values from ValidateCheckResponseDataCompanyValidationCompany, ValidateCheckResponseDataCompanyEoriValidationCompany.
Use the methods beginning with 'As' to cast the union to one of its variants.
func (ValidateCheckResponseDataCompanyUnion) AsValidateCheckResponseDataCompanyEoriValidationCompany ¶
func (u ValidateCheckResponseDataCompanyUnion) AsValidateCheckResponseDataCompanyEoriValidationCompany() (v ValidateCheckResponseDataCompanyEoriValidationCompany)
func (ValidateCheckResponseDataCompanyUnion) AsValidateCheckResponseDataCompanyValidationCompany ¶
func (u ValidateCheckResponseDataCompanyUnion) AsValidateCheckResponseDataCompanyValidationCompany() (v ValidateCheckResponseDataCompanyValidationCompany)
func (ValidateCheckResponseDataCompanyUnion) RawJSON ¶
func (u ValidateCheckResponseDataCompanyUnion) RawJSON() string
Returns the unmodified JSON received from the API
func (*ValidateCheckResponseDataCompanyUnion) UnmarshalJSON ¶
func (r *ValidateCheckResponseDataCompanyUnion) UnmarshalJSON(data []byte) error
type ValidateCheckResponseDataCompanyValidationCompany ¶
type ValidateCheckResponseDataCompanyValidationCompany struct {
CompanyAddress string `json:"company_address"`
CompanyName string `json:"company_name"`
CountryCode string `json:"country_code"`
// The VAT number (without country code prefix).
VatNumber string `json:"vat_number"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
CompanyAddress respjson.Field
CompanyName respjson.Field
CountryCode respjson.Field
VatNumber respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (ValidateCheckResponseDataCompanyValidationCompany) RawJSON ¶
func (r ValidateCheckResponseDataCompanyValidationCompany) RawJSON() string
Returns the unmodified JSON received from the API
func (*ValidateCheckResponseDataCompanyValidationCompany) UnmarshalJSON ¶
func (r *ValidateCheckResponseDataCompanyValidationCompany) UnmarshalJSON(data []byte) error
type ValidateService ¶
type ValidateService struct {
// contains filtered or unexported fields
}
VAT and EORI number validation
ValidateService contains methods and other services that help with interacting with the vat-sense API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewValidateService method instead.
func NewValidateService ¶
func NewValidateService(opts ...option.RequestOption) (r ValidateService)
NewValidateService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*ValidateService) Check ¶
func (r *ValidateService) Check(ctx context.Context, query ValidateCheckParams, opts ...option.RequestOption) (res *ValidateCheckResponse, err error)
Check whether a given VAT number or EORI number is valid against live government records.
**VAT validation** checks against UK (HMRC), EU (VIES), Australia, Norway, Switzerland, South Africa, and Brazil records.
**EORI validation** checks against UK and EU records only.
If the external validation service is temporarily unavailable, the API returns a `412` error and the request does not count against your usage quota.
Provide either `vat_number` or `eori_number`, but not both.
type VatPrice ¶
type VatPrice struct {
// Any of "vat_price".
Object VatPriceObject `json:"object"`
// The price provided.
Price float64 `json:"price"`
// The calculated price exclusive of VAT.
PriceExclVat float64 `json:"price_excl_vat"`
// The calculated price inclusive of VAT.
PriceInclVat float64 `json:"price_incl_vat"`
// Whether the price is inclusive or exclusive of VAT.
//
// Any of "incl", "excl".
TaxType VatPriceTaxType `json:"tax_type"`
// The total VAT amount.
Vat float64 `json:"vat"`
// The VAT rate percentage.
VatRate float64 `json:"vat_rate"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Object respjson.Field
Price respjson.Field
PriceExclVat respjson.Field
PriceInclVat respjson.Field
TaxType respjson.Field
Vat respjson.Field
VatRate respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (*VatPrice) UnmarshalJSON ¶
type VatPriceObject ¶
type VatPriceObject string
const (
VatPriceObjectVatPrice VatPriceObject = "vat_price"
)
type VatPriceTaxType ¶
type VatPriceTaxType string
Whether the price is inclusive or exclusive of VAT.
const ( VatPriceTaxTypeIncl VatPriceTaxType = "incl" VatPriceTaxTypeExcl VatPriceTaxType = "excl" )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
encoding/json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
|
Package json implements encoding and decoding of JSON as defined in RFC 7159. |
|
encoding/json/shims
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
|
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package. |
|
packages
|
|
|
shared
|
|