productep

package
v1.4.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProductPresenter

func ProductPresenter(proto *pb.ProductFullInfo) apiresource.Product

Types

type BulkUpsertProductsEndpoint

type BulkUpsertProductsEndpoint struct{}

Creates or updates multiple products for the account, matched by SKU. Validates and resolves synchronously, then writes asynchronously — 202 with a job to poll.

func (*BulkUpsertProductsEndpoint) Materialize

type BulkUpsertProductsRequest

type BulkUpsertProductsRequest struct {
	// Products to create or update, matched by SKU within the account.
	Products []UpsertProductInput `json:"products" validate:"required,min=1,max=1000,dive"`
}

Request to bulk upsert products.

func (*BulkUpsertProductsRequest) SchemaExample

func (*BulkUpsertProductsRequest) SchemaExample() any

type ChangeProductProductLineEndpoint

type ChangeProductProductLineEndpoint struct{}

Moves a product to a different product line.

The target product line must be one your account owns or a shared system line; anything else fails as not found. Because customer accounts are granted access to whole product lines, moving a product changes which buyers can see and order it in the customer portal, and which default commission and freight policies apply to it.

func (*ChangeProductProductLineEndpoint) Materialize

type ChangeProductProductLineRequest

type ChangeProductProductLineRequest struct {
	// Product ID.
	ProductID string `path:"id" validate:"required"`
	// ID of the product line to assign to the product.
	ProductLineID string `path:"product_line_id" validate:"required"`
}

Request to move a product to a different product line.

type CreateProductEndpoint

type CreateProductEndpoint struct{}

Creates a product and its backing inventory item.

The new item starts with zero on-hand inventory, and its pricing defaults to zero rates in the category's base unit unless `unit_price` or `unit_cost` is provided.

Only products of type `sale` appear in the product list and export; products created with any other type are still usable on orders and invoices but must be retrieved by ID.

func (*CreateProductEndpoint) Materialize

type CreateProductRequest

type CreateProductRequest struct {
	// Stock keeping unit code for the product's item.
	//
	// Must be unique within the account; creation fails with a conflict error if another item already uses it.
	SKU string `json:"sku" validate:"required,max=255"`
	// Free-form description of the product.
	Description field.Optional[string] `json:"description,omitzero"`
	// Free-form notes about the product.
	Notes field.Optional[string] `json:"notes,omitzero"`
	// Product type code, which determines how the product behaves on orders and invoices.
	//
	// - `sale`: a standard sellable product.
	// - `service`: a non-physical service line, such as labor or installation.
	// - `shipping`: a shipping charge applied to an order.
	// - `credit`: a credit applied against an order or invoice.
	// - `return`: a returned product (RMA).
	// - `tax`: a tax line.
	ProductTypeCode constants.ProductTypeCode `json:"type" validate:"required"`
	// ID of the product line to assign the product to.
	//
	// The product line must be one your account owns or a shared system line; anything else fails as not found. Buyers are granted access to whole product lines, so a product created without one never appears in the customer portal, whatever its `portal_visibility`.
	ProductLineID field.Optional[string] `json:"product_line_id,omitzero" validate:"omitempty"`
	// ID of the item category for the product's item.
	//
	// The category's unit group determines the default units used for the product's pricing rates and inventory tracking.
	CategoryID string `json:"category_id" validate:"required"`
	// Whether the product is shown to buyers in the customer portal.
	//
	// - `visible`: buyers can see and order the product in the portal.
	// - `hidden`: the product is concealed from the portal but remains usable internally.
	//
	// When omitted, the product is created hidden, so it must be set to `visible` before buyers can see it.
	PortalVisibility field.Optional[constants.CustomerPortalVisibility] `json:"portal_visibility,omitzero" default:"hidden"`
	// Initial selling price per unit.
	//
	// When set, the numerator unit must be a currency unit and the denominator unit must not be. When omitted, the price is initialized to a zero rate in the category's base unit.
	UnitPrice field.Optional[apirequest.RateInput] `json:"unit_price,omitzero"`
	// Initial cost per unit.
	//
	// The same unit rule as `unit_price` applies: the numerator unit must be a currency unit and the denominator unit must not be. When omitted, the cost is initialized to a zero rate in the category's base unit.
	UnitCost field.Optional[apirequest.RateInput] `json:"unit_cost,omitzero"`
	// Attribute IDs to link to the product's item at creation time.
	//
	// Every ID must already exist in your account, and each attribute's property must be one the item's category carries; an ID that fails either check fails the whole request rather than being skipped.
	AttributeIDs []string `json:"attribute_ids,omitzero"`
}

Request to create a product.

func (*CreateProductRequest) SchemaExample

func (*CreateProductRequest) SchemaExample() any

type DeleteProductEndpoint

type DeleteProductEndpoint struct{}

Soft-deletes a product and returns it as it stood at deletion.

Deletion marks the product's backing item as deleted, so the item and its inventory drop out of catalog and inventory listings too. Deleting the same product again returns an error saying it has already been deleted.

func (*DeleteProductEndpoint) Materialize

type DeleteProductRequest

type DeleteProductRequest struct {
	// Product ID.
	ProductID string `path:"id" validate:"required"`
}

Request to delete a product.

type ExportProductsEndpoint

type ExportProductsEndpoint struct{}

Starts an export of every matching product and returns the job that tracks it; as with the product list, only products of type `sale` are exported.

func (*ExportProductsEndpoint) Materialize

type ExportProductsRequest

type ExportProductsRequest struct {
	// Free-text search matched against the SKU and description of each product's item.
	Query *string `json:"q"`
	// Filter by the item category the product's item belongs to.
	CategoryIDs []string `json:"category_ids"`
	// Filter to products whose item carries at least one of these attributes.
	AttributeIDs []string `json:"attribute_ids"`
	// Filter by product line IDs.
	//
	// Combined with `customer_ids`, products matching either filter are exported.
	ProductLineIDs []string `json:"product_line_ids"`
	// Restrict the export to products these customer accounts are entitled to buy.
	//
	// A product matches when its product line has been granted to the customer directly, through the customer's account group, or through the account group used for the customer's pricing.
	CustomerIDs []string `json:"customer_ids"`
	// Start of creation date range.
	StartDate *time.Time `json:"starts_at"`
	// End of creation date range.
	EndDate *time.Time `json:"ends_at"`
}

Filters which products land in the exported file.

func (*ExportProductsRequest) SchemaExample

func (*ExportProductsRequest) SchemaExample() any

type ListProductsEndpoint

type ListProductsEndpoint struct{}

Returns a paginated list of products for the target account, newest first.

Only products of type `sale` are listed — service, shipping, credit, return, and tax products are excluded and must be retrieved by ID. A request made by a customer-portal buyer always returns portal-visible products only, and its `customer_ids` filter is replaced with the buyer's own account, so the results reflect what that account is entitled to buy.

The `q` search term is matched against the SKU and description of each product's item; when it is supplied, products whose SKU matches are returned ahead of the rest.

type ListProductsRequest

type ListProductsRequest struct {
	apiresource.PaginationRequest
	// Restrict results to products these customer accounts are entitled to buy.
	//
	// A product matches when its product line has been granted to the customer directly, through the customer's account group, or through the account group used for the customer's pricing. Combined with `product_line_ids` this widens the results rather than narrowing them: products matching either filter are returned.
	CustomerIDs []string `query:"customer_ids"`
	// Filter by product line IDs.
	//
	// Combined with `customer_ids`, products matching either filter are returned.
	ProductLineIDs []string `query:"product_line_ids"`
	// Filter by the item category the product's item belongs to.
	CategoryIDs []string `query:"category_ids"`
	// Filter to products whose item carries at least one of these attributes.
	AttributeIDs []string `query:"attribute_ids"`
	// Start of creation date range.
	StartDate *time.Time `query:"starts_at"`
	// End of creation date range.
	EndDate *time.Time `query:"ends_at"`
	// Filter by customer portal visibility.
	PortalVisibility *constants.CustomerPortalVisibility `query:"portal_visibility"`
}

Request to list products.

type ProductSvcConfig

type ProductSvcConfig struct {
	// CoreClient (required) is the core-service gRPC client.
	CoreClient pb.CoreServiceClient
}

type RetrieveProductEndpoint

type RetrieveProductEndpoint struct{}

Returns a product by ID.

func (*RetrieveProductEndpoint) Materialize

type RetrieveProductRequest

type RetrieveProductRequest struct {
	// Product ID.
	ProductID string `path:"id" validate:"required"`
}

Request to retrieve a product.

type UpdateProductEndpoint

type UpdateProductEndpoint struct{}

Partially updates a product.

`sku`, `description`, `notes`, and `unit_price` all live on the product's backing item and are written there, so the change is visible on the item as well. The product line is reassigned through its own endpoint, and the product type cannot be changed after creation.

func (*UpdateProductEndpoint) Materialize

type UpdateProductRequest

type UpdateProductRequest struct {
	// Product ID.
	ProductID string `path:"id" validate:"required"`
	// New stock keeping unit code for the product's item.
	//
	// Must be unique within the account; the update fails with a conflict error if another item already uses it.
	SKU field.Optional[string] `json:"sku,omitzero" validate:"omitempty,max=255"`
	// Free-form description of the product.
	//
	// Send `null` to clear.
	Description field.Clearable[string] `json:"description,omitzero"`
	// Free-form notes about the product.
	//
	// Send `null` to clear.
	Notes field.Clearable[string] `json:"notes,omitzero"`
	// Whether the product is shown to buyers in the customer portal.
	//
	// - `visible`: buyers can see and order the product in the portal.
	// - `hidden`: the product is concealed from the portal but remains usable internally.
	PortalVisibility field.Optional[constants.CustomerPortalVisibility] `json:"portal_visibility,omitzero"`
	// New selling price per unit.
	//
	// The numerator unit must be a currency unit and the denominator unit must not be. The new rate replaces the price on the product's backing item.
	UnitPrice field.Optional[apirequest.RateInput] `json:"unit_price,omitzero"`
}

Request to partially update a product.

func (*UpdateProductRequest) SchemaExample

func (*UpdateProductRequest) SchemaExample() any

type UpsertProductInput

type UpsertProductInput struct {
	// SKU for the product, used to match an existing product within the account. If it
	// exists the product is updated in place; otherwise a new product is created. A SKU
	// already used by a non-product item fails that row.
	SKU string `json:"sku" validate:"required,max=255"`
	// Product type. Create-only; defaults to `sale` when omitted.
	Type field.Optional[constants.ProductTypeCode] `json:"type,omitzero"`
	// Product description.
	Description field.Optional[string] `json:"description,omitzero"`
	// Product notes.
	Notes field.Optional[string] `json:"notes,omitzero"`
	// Item category to place the product in, referenced by `id` or `name`. Create-only.
	Category apirequest.ObjectIdentifier `json:"category" validate:"required"`
	// Product line to assign, referenced by `id` or `name`. Create-only.
	ProductLine field.Optional[apirequest.ObjectIdentifier] `json:"product_line,omitzero"`
	// Whether the product is shown to buyers in the customer portal. Defaults to `hidden`
	// on create; preserved when omitted on update.
	PortalVisibility field.Optional[constants.CustomerPortalVisibility] `json:"portal_visibility,omitzero"`
	// Selling price per unit. Numerator must be a currency unit, denominator the per-unit
	// basis. Defaults to a zero rate in the category's base unit on create; unchanged when
	// omitted on update.
	UnitPrice field.Optional[apirequest.RateInput] `json:"unit_price,omitzero"`
	// Cost per unit. Same currency-vs-non-currency rule as `unit_price`.
	UnitCost field.Optional[apirequest.RateInput] `json:"unit_cost,omitzero"`
	// Properties to attach to the product, matched/created by name + value. Additive —
	// existing attributes are not removed.
	Properties []UpsertProductProperty `json:"properties" default:"[]" validate:"dive"`
}

Input for a single product in a bulk upsert operation.

type UpsertProductProperty

type UpsertProductProperty struct {
	// Property name (e.g. "Color"). Matched case-insensitively; created if missing.
	Name string `json:"name" validate:"required,max=255"`
	// Property value (e.g. "Red"). Matched case-insensitively; created under the property
	// if missing. A value already in use under a different property fails the whole job.
	Value string `json:"value" validate:"required,max=255"`
}

Property name + value pair attached to a product. The property and its value (an attribute) are created if they do not yet exist.

type ValidateProductsEndpoint

type ValidateProductsEndpoint struct{}

Resolves a batch of SKUs to products in one call, keyed by the keys you supplied.

Useful before importing order lines from a spreadsheet or a customer document: send each row's SKU under its row key and check which keys come back. Unmatched SKUs are simply left out of the response rather than reported as errors, and unlike the product list this covers products of every type, not just `sale`.

type ValidateProductsRequest

type ValidateProductsRequest struct {
	// Map of caller-chosen keys to SKU values to look up.
	//
	// SKUs are matched case-insensitively. Each key is echoed back in the response with its matched product; keys whose SKU does not match any product are omitted.
	ProductsMap map[string]string `json:"products_map" validate:"required"`
}

Request to look up products by SKU.

func (*ValidateProductsRequest) SchemaExample

func (*ValidateProductsRequest) SchemaExample() any

Jump to

Keyboard shortcuts

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