materialep

package
v1.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaterialPresenter

func MaterialPresenter(m *pb.MaterialInfo) apiresource.Material

Types

type BulkUpsertMaterialsEndpoint

type BulkUpsertMaterialsEndpoint struct{}

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

func (*BulkUpsertMaterialsEndpoint) Materialize

type BulkUpsertMaterialsRequest

type BulkUpsertMaterialsRequest struct {
	// Materials to create or update, matched by SKU within the account.
	Materials []UpsertMaterialInput `json:"materials" validate:"required,min=1,max=1000,dive"`
}

Request to bulk upsert materials.

func (*BulkUpsertMaterialsRequest) SchemaExample

func (*BulkUpsertMaterialsRequest) SchemaExample() any

type CreateMaterialEndpoint

type CreateMaterialEndpoint struct{}

Creates a material together with the catalog item that carries its SKU, description, category, pricing, and attributes.

Inventory tracking for the new material starts at a zero on-hand quantity in the category's base unit. The item's consumption rate (`burn_rate`) also starts at zero and cannot be supplied here — it is derived from recorded consumption as production happens.

func (*CreateMaterialEndpoint) Materialize

type CreateMaterialRequest

type CreateMaterialRequest struct {
	// Stock keeping unit code for the material.
	//
	// Must be unique within the account; creating a material with a SKU already used by another item fails with a conflict error.
	SKU string `json:"sku" validate:"required,max=255"`
	// Free-form description of the material.
	Description field.Optional[string] `json:"description,omitzero"`
	// Free-form notes about the material.
	Notes field.Optional[string] `json:"notes,omitzero"`
	// ID of the item category to place the material in.
	//
	// The category's unit group determines the base unit used for the material's rates (`unit_value`, `unit_cost`, `burn_rate`).
	CategoryID string `json:"category_id" validate:"required"`
	// Reorder threshold: when on-hand stock falls to this quantity, the material should be reordered.
	//
	// When omitted, the material is created without a reorder threshold.
	OrderPoint field.Optional[QuantityInputRequest] `json:"order_point,omitzero"`
	// Expected time between placing an order for this material and receiving it, expressed as a quantity in a time unit (e.g. days).
	//
	// When omitted, the material is created without a lead time.
	LeadTime field.Optional[QuantityInputRequest] `json:"lead_time,omitzero"`
	// Initial selling price per unit.
	//
	// `numerator_unit_id` must reference a currency unit and `denominator_unit_id` must reference a non-currency unit (e.g. `$5` per `ea`). When omitted, the price is initialized to a zero rate in the category's base unit. It becomes the `unit_value` rate on the material's item; the material update endpoint cannot change it afterwards.
	UnitPrice field.Optional[apirequest.RateInput] `json:"unit_price,omitzero"`
	// Initial cost per unit.
	//
	// Follows the same unit rule as `unit_price`: currency numerator, non-currency denominator. 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"`
	// IDs of existing attributes to link to the material at creation time.
	//
	// Each attribute's property must be one the material's category carries; an attribute from any other property fails the whole request.
	AttributeIDs []string `json:"attribute_ids,omitzero"`
}

Request to create a material.

func (*CreateMaterialRequest) SchemaExample

func (*CreateMaterialRequest) SchemaExample() any

type DeleteMaterialEndpoint

type DeleteMaterialEndpoint struct{}

Deletes a material.

This is a soft delete: the material and the catalog item behind it stop being returned by other endpoints, but the records are retained. The response is the material as it stood immediately before deletion, and deleting an already-deleted material returns an error.

func (*DeleteMaterialEndpoint) Materialize

type DeleteMaterialRequest

type DeleteMaterialRequest struct {
	// ID of the material to delete.
	ItemID string `path:"id" validate:"required"`
}

Request to delete a material.

type ExportMaterialsEndpoint

type ExportMaterialsEndpoint struct{}

Starts an export of every matching material and returns the job that tracks it.

func (*ExportMaterialsEndpoint) Materialize

type ExportMaterialsRequest

type ExportMaterialsRequest struct {
	// Free-text search term matched against material SKU and description.
	Query *string `json:"q"`
	// Filter to materials in any of these categories.
	CategoryIDs []string `json:"category_ids"`
	// Filter to materials carrying any of these attributes.
	AttributeIDs []string `json:"attribute_ids"`
	// Filter to materials created on or after this date.
	StartDate *time.Time `json:"starts_at"`
	// Filter to materials created on or before this date.
	EndDate *time.Time `json:"ends_at"`
}

Filters which materials land in the exported file.

func (*ExportMaterialsRequest) SchemaExample

func (*ExportMaterialsRequest) SchemaExample() any

type ListMaterialsEndpoint

type ListMaterialsEndpoint struct{}

Returns a paginated list of materials, newest first.

`q` matches against SKU and description, with closer SKU matches ranked first.

type ListMaterialsRequest

type ListMaterialsRequest struct {
	apiresource.PaginationRequest
	// Filter to materials in any of these categories.
	CategoryIDs []string `query:"category_ids"`
	// Filter to materials carrying any of these attributes.
	AttributeIDs []string `query:"attribute_ids"`
	// Filter to materials created on or after this date.
	StartDate *time.Time `query:"starts_at"`
	// Filter to materials created on or before this date.
	EndDate *time.Time `query:"ends_at"`
}

Request to list materials.

type MaterialSvcConfig

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

type QuantityInputRequest

type QuantityInputRequest struct {
	// Decimal value of the quantity.
	Value string `json:"value" validate:"required" format:"decimal"`
	// ID of the unit the value is expressed in.
	UnitID string `json:"unit_id" validate:"required"`
}

A quantity, given as a decimal value and the unit it is measured in.

type RetrieveMaterialEndpoint

type RetrieveMaterialEndpoint struct{}

Returns a material by ID.

func (*RetrieveMaterialEndpoint) Materialize

type RetrieveMaterialRequest

type RetrieveMaterialRequest struct {
	// ID of the material to retrieve.
	ItemID string `path:"id" validate:"required"`
}

Request to get a material.

type UpdateMaterialEndpoint

type UpdateMaterialEndpoint struct{}

Partially updates a material.

Fields not provided retain their current values. Only the cost side of pricing can be changed here; the selling price set at creation is not editable through this endpoint. Use the Change Item Category endpoint to move the material to a different category.

func (*UpdateMaterialEndpoint) Materialize

type UpdateMaterialRequest

type UpdateMaterialRequest struct {
	// ID of the material to update.
	ItemID string `path:"id" validate:"required"`
	// New stock keeping unit code for the material.
	//
	// Must remain unique within the account; a conflict error is returned if another item already uses it.
	SKU field.Optional[string] `json:"sku,omitzero" validate:"omitempty,max=255"`
	// New description for the material.
	Description field.Optional[string] `json:"description,omitzero"`
	// New notes for the material.
	Notes field.Optional[string] `json:"notes,omitzero"`
	// New reorder threshold: when on-hand stock falls to this quantity, the material should be reordered.
	OrderPoint field.Optional[QuantityInputRequest] `json:"order_point,omitzero"`
	// New expected time between placing an order for this material and receiving it.
	LeadTime field.Optional[QuantityInputRequest] `json:"lead_time,omitzero"`
	// New cost per unit.
	//
	// Follows the same unit rule as on create: `numerator_unit_id` must reference a currency unit and `denominator_unit_id` must reference a non-currency unit.
	UnitCost field.Optional[apirequest.RateInput] `json:"unit_cost,omitzero"`
}

Request to update a material.

func (*UpdateMaterialRequest) SchemaExample

func (*UpdateMaterialRequest) SchemaExample() any

type UpsertMaterialInput

type UpsertMaterialInput struct {
	// SKU for the material, used to match an existing material within the account. If it
	// exists the material is updated in place; otherwise a new material is created. A SKU
	// already used by a non-material item fails that row.
	SKU string `json:"sku" validate:"required,max=255"`
	// Material description.
	Description field.Optional[string] `json:"description,omitzero"`
	// Material notes.
	Notes field.Optional[string] `json:"notes,omitzero"`
	// Item category to place the material in, referenced by `id` or `name`. Create-only.
	Category apirequest.ObjectIdentifier `json:"category" validate:"required"`
	// Reorder threshold quantity. When omitted on create it defaults to a zero quantity in
	// the category's base unit.
	OrderPoint field.Optional[QuantityInputRequest] `json:"order_point,omitzero"`
	// Expected lead time quantity. When omitted on create it defaults to a zero quantity in
	// the category's base unit.
	LeadTime field.Optional[QuantityInputRequest] `json:"lead_time,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 material, matched/created by name + value. Additive —
	// existing attributes are not removed.
	Properties []UpsertMaterialProperty `json:"properties" default:"[]" validate:"dive"`
}

Input for a single material in a bulk upsert operation.

type UpsertMaterialProperty

type UpsertMaterialProperty struct {
	// Property name (e.g. "Grade"). Matched case-insensitively; created if missing.
	Name string `json:"name" validate:"required,max=255"`
	// Property value (e.g. "A36"). 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 material. The property and its value (an attribute) are created if they do not yet exist.

Jump to

Keyboard shortcuts

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