apirequest

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ItemIdentifierToProto

func ItemIdentifierToProto(i ItemIdentifier) *pb.ItemIdentifier

maps a fuzzy item reference to its protobuf form. Empty fields cross as empty strings, which the server treats as unset.

func ObjectIdentifierPtrToProto

func ObjectIdentifierPtrToProto(d *ObjectIdentifier) *pb.ObjectIdentifier

maps a nillable object reference, returning nil when it is omitted.

func ObjectIdentifierToProto

func ObjectIdentifierToProto(d ObjectIdentifier) *pb.ObjectIdentifier

maps a fuzzy object reference to its protobuf form.

func OptionalItemIdentifierToProto

func OptionalItemIdentifierToProto(i field.Optional[ItemIdentifier]) *pb.ItemIdentifier

maps an optional fuzzy item reference, returning nil when unset.

func OptionalObjectIdentifierToProto

func OptionalObjectIdentifierToProto(d field.Optional[ObjectIdentifier]) *pb.ObjectIdentifier

maps an optional object reference, returning nil when unset.

func OptionalUnitIdentifierToProto

func OptionalUnitIdentifierToProto(u field.Optional[UnitIdentifier]) *pb.UnitIdentifier

maps an optional fuzzy unit reference, returning nil when the unit is omitted entirely.

func QuantityFieldToProto

func QuantityFieldToProto(f field.Clearable[QuantityInput]) *pb.QuantityPatch

QuantityFieldToProto converts a clearable quantity request field into its patch representation: an omitted field yields nil so the stored value is left alone, an explicit null yields a clear instruction, and a supplied object yields the new value and unit.

func UnitIdentifierToProto

func UnitIdentifierToProto(u UnitIdentifier) *pb.UnitIdentifier

maps a fuzzy unit reference to its protobuf form. Empty fields cross as empty strings, which the server treats as unset.

Types

type AddressInput

type AddressInput struct {
	// Display name of the address.
	Name string `json:"name" validate:"required,min=1,max=255"`
	// Phone number associated with the address.
	Phone field.Optional[string] `json:"phone,omitzero" validate:"omitempty,max=255"`
	// Email address associated with the address.
	Email field.Optional[string] `json:"email,omitzero" validate:"omitempty,custom_email,max=255"`
	// How the address is used.
	//
	// - `standard`: a normal shipping or billing address.
	// - `drop_ship`: an address an order is shipped to directly, typically a third party or end customer rather than the account itself.
	Type field.Optional[constants.AddressType] `json:"type,omitzero" default:"standard"`
	// The operating calendar naming the days this dock accepts freight, overriding the customer's own.
	ReceiveCalendarID field.Optional[string] `json:"receive_calendar_id,omitzero" validate:"omitempty"`
	// First line of the street address.
	StreetLine1 field.Optional[string] `json:"street_line_1,omitzero" validate:"omitempty,max=255"`
	// Second line of the street address.
	StreetLine2 field.Optional[string] `json:"street_line_2,omitzero" validate:"omitempty,max=255"`
	// City or locality.
	Locality field.Optional[string] `json:"locality,omitzero" validate:"omitempty,max=255"`
	// State or administrative area.
	State field.Optional[string] `json:"state,omitzero" validate:"omitempty,max=255"`
	// Postal or ZIP code.
	PostalCode field.Optional[string] `json:"postal_code,omitzero" validate:"omitempty,max=255"`
	// Two-letter ISO 3166-1 country code, such as `US`.
	Country string `json:"country" validate:"required,max=2"`
}

Address details supplied when creating an address, either on its own or inline on another resource.

A few requests, such as shipping rate estimates, take these same fields for a one-off address that is never saved to the account.

func (*AddressInput) SchemaExample

func (*AddressInput) SchemaExample() any

type ItemIdentifier

type ItemIdentifier struct {
	// Item ID.
	ID string `json:"id,omitempty" validate:"omitempty,max=255"`
	// Item SKU, matched case-insensitively against the account's items.
	SKU string `json:"sku,omitempty" validate:"omitempty,max=255"`
}
-------------------------- ITEM --------------------------

Identifies an item by its id or its SKU. An id wins when both are given.

type ObjectIdentifier

type ObjectIdentifier struct {
	// Object ID.
	ID string `json:"id,omitempty" validate:"omitempty,max=255"`
	// Object name, matched case-insensitively.
	Name string `json:"name,omitempty" validate:"omitempty,max=255"`
}
-------------------------- Named Object --------------------------

Identifies an object by its id or its name. An id wins when both are given.

type OrderLineInput

type OrderLineInput struct {
	// ID of the product being ordered.
	ProductID string `json:"product_id" validate:"required"`
	// ID of the inventory item this line is linked to.
	//
	// Stock received against the line is booked into this item, so lines for goods you hold in inventory should reference one. Supplying an item also records the item's material as sourced from this order's supplier, with `product_sku` as the supplier part number, when that link does not exist yet.
	ItemID field.Optional[string] `json:"item_id,omitzero" validate:"omitempty"`
	// The product SKU recorded on the line.
	//
	// Stored on the line itself, so it stays stable even if the product's SKU changes later.
	ProductSKU string `json:"product_sku" validate:"required,max=255"`
	// The product description recorded on the line.
	ProductDescription field.Optional[string] `json:"product_description,omitzero"`
	// Quantity ordered from the supplier.
	Quantity QuantityInput `json:"quantity" validate:"required"`
	// Agreed purchase price per unit for this line.
	//
	// This is also the cost carried into inventory: stock received against the line is costed at this rate.
	UnitPrice RateInput `json:"unit_price" validate:"required"`
	// Cost per unit recorded on the line, if you capture it separately from the agreed purchase price.
	//
	// Kept for reference only; it does not affect how stock received against the line is costed.
	UnitCost field.Optional[RateInput] `json:"unit_cost,omitzero"`
}

Details of a single line item ordered from a supplier, used when creating a purchase order and when adding a line to an existing one.

type QuantityInput

type QuantityInput struct {
	// Decimal value, as a string to preserve precision.
	Value string `json:"value" validate:"required" format:"decimal"`
	// ID of the unit of measure for the value.
	UnitID string `json:"unit_id" validate:"required"`
}

An amount together with the unit it is expressed in.

The unit may be a currency, so money amounts such as a credit limit are written the same way as physical amounts like weights or counts.

type RateInput

type RateInput struct {
	// Decimal value of the rate, expressed as the amount of the numerator unit per one denominator unit.
	Value string `json:"value" validate:"required" format:"decimal"`
	// ID of the unit for the rate's numerator (e.g. the currency of a price).
	NumeratorUnitID string `json:"numerator_unit_id" validate:"required"`
	// ID of the unit for the rate's denominator (the per-unit basis).
	DenominatorUnitID string `json:"denominator_unit_id" validate:"required"`
}

A value expressed as a ratio of two units, supplied on create and update requests.

A unit price, for example, has a currency as its numerator unit and the unit the product is bought or sold by as its denominator.

type UnitIdentifier

type UnitIdentifier struct {
	// Unit ID.
	ID string `json:"id,omitempty" validate:"omitempty,max=255"`
	// Unit name, matched case-insensitively against the account's units.
	Name string `json:"name,omitempty" validate:"omitempty,max=255"`
	// Unit abbreviation, matched case-insensitively against the account's units.
	Abbreviation string `json:"abbreviation,omitempty" validate:"omitempty,max=255"`
}
-------------------------- UNIT --------------------------

Identifies a unit by its id, its name, or its abbreviation, in that order of precedence.

Jump to

Keyboard shortcuts

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