unitgroupep

package
v1.4.2 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: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BulkUpsertUnitGroupsEndpoint

type BulkUpsertUnitGroupsEndpoint struct{}

Creates or updates multiple unit groups for the account, matched by name (case-insensitive), then writes asynchronously — 202 with a job to poll.

func (*BulkUpsertUnitGroupsEndpoint) Materialize

type BulkUpsertUnitGroupsRequest

type BulkUpsertUnitGroupsRequest struct {
	// Unit groups to create or update, matched by name within the account.
	UnitGroups []UpsertUnitGroupInput `json:"unit_groups" validate:"required,min=1,max=1000,dive"`
}

BulkUpsertUnitGroupsRequest is the request to bulk upsert unit groups.

func (*BulkUpsertUnitGroupsRequest) SchemaExample

func (*BulkUpsertUnitGroupsRequest) SchemaExample() any

type CreateUnitGroupEndpoint

type CreateUnitGroupEndpoint struct{}

Creates a unit group, optionally associating units with it in the same request.

The name must be unique within the account, and the base unit and every associated unit must share the group's dimension.

func (*CreateUnitGroupEndpoint) Materialize

type CreateUnitGroupRequest

type CreateUnitGroupRequest struct {
	// Display name of the unit group.
	//
	// Must be unique within the account.
	Name string `json:"name" validate:"required,max=255"`
	// Free-form notes about the unit group.
	Notes field.Optional[string] `json:"notes,omitzero" default:"null"`
	// The dimension shared by every unit in this group, such as mass, volume, or currency.
	//
	// The base unit and all associated units must be of this dimension, and the dimension cannot be changed after the group is created.
	Type constants.UnitType `json:"type" validate:"required"`
	// ID of the unit to designate as the group's reference unit.
	//
	// Must be a unit of the group's `type`.
	BaseUnitID string `json:"base_unit_id" validate:"required"`
	// Units to associate with the group, each with its own discount and customer portal visibility.
	AssociatedUnits []CreateUnitGroupUnitParam `json:"associated_units,omitzero"`
}

Request to create a unit group.

func (*CreateUnitGroupRequest) SchemaExample

func (*CreateUnitGroupRequest) SchemaExample() any

type CreateUnitGroupUnitEndpoint

type CreateUnitGroupUnitEndpoint struct{}

Adds a unit to a unit group so that products using the group can be ordered in it.

A unit can appear in a group only once, so use the update endpoint to change the discount or visibility of a unit that is already associated. Units cannot be added to system unit groups.

type CreateUnitGroupUnitParam

type CreateUnitGroupUnitParam struct {
	// ID of the unit to associate with the group.
	//
	// The unit's dimension must match the group's `type`.
	UnitID string `json:"unit_id" validate:"required"`
	// Share of the unit's price removed when an order is placed in this unit.
	//
	// Expressed as a decimal fraction rather than a whole number, so `0.1` is a 10% discount. Send `0` explicitly for no discount — omitting the field stores a discount of `1`, which removes the entire price.
	DiscountPercentage field.Optional[float64] `json:"discount_percentage,omitzero" default:"1"`
	// Flat amount subtracted from the unit's price when an order is placed in this unit.
	//
	// Subtracted before `discount_percentage` is applied.
	DiscountFixed field.Optional[float64] `json:"discount_fixed,omitzero" default:"0"`
	// Whether the unit is shown to customers in the customer portal.
	CustomerPortalVisibility field.Optional[constants.CustomerPortalVisibility] `json:"customer_portal_visibility,omitzero" default:"visible"`
}

Parameters for associating a unit with a unit group.

type CreateUnitGroupUnitRequest

type CreateUnitGroupUnitRequest struct {
	// Unit group ID.
	UnitGroupID string `path:"unit_group_id" validate:"required"`
	// ID of the unit to associate with the group.
	//
	// The unit's dimension must match the group's `type`.
	UnitID string `json:"unit_id" validate:"required"`
	// Share of the unit's price removed when an order is placed in this unit.
	//
	// Expressed as a decimal fraction rather than a whole number, so `0.1` is a 10% discount. Send `0` explicitly for no discount — omitting the field stores a discount of `1`, which removes the entire price.
	DiscountPercentage field.Optional[float64] `json:"discount_percentage,omitzero" default:"1"`
	// Flat amount subtracted from the unit's price when an order is placed in this unit.
	//
	// Subtracted before `discount_percentage` is applied.
	DiscountFixed field.Optional[float64] `json:"discount_fixed,omitzero" default:"0"`
	// Whether the unit is shown to customers in the customer portal.
	CustomerPortalVisibility field.Optional[constants.CustomerPortalVisibility] `json:"customer_portal_visibility,omitzero" default:"visible"`
}

Request to add a unit to a unit group.

func (*CreateUnitGroupUnitRequest) SchemaExample

func (*CreateUnitGroupUnitRequest) SchemaExample() any

type DeleteUnitGroupEndpoint

type DeleteUnitGroupEndpoint struct{}

Deletes a unit group along with every unit association it contains.

The units themselves are not deleted and remain available to other groups. System unit groups, which are shared across all accounts, cannot be deleted.

func (*DeleteUnitGroupEndpoint) Materialize

type DeleteUnitGroupRequest

type DeleteUnitGroupRequest struct {
	// Unit group ID.
	UnitGroupID string `path:"id" validate:"required"`
}

Request to delete a unit group.

type DeleteUnitGroupUnitEndpoint

type DeleteUnitGroupUnitEndpoint struct{}

Removes a unit from a unit group so that products using the group can no longer be ordered in it.

Only the association is deleted; the unit itself remains available. Associations cannot be removed from system unit groups.

type DeleteUnitGroupUnitRequest

type DeleteUnitGroupUnitRequest struct {
	// Unit group ID.
	UnitGroupID string `path:"unit_group_id" validate:"required"`
	// ID of the unit's association with the group, not the ID of the unit itself.
	AssociatedUnitID string `path:"id" validate:"required"`
}

Request to remove an associated unit from a unit group.

type ExportUnitGroupsEndpoint

type ExportUnitGroupsEndpoint struct{}

Starts an export of every matching unit group and returns the job that tracks it; the file lists a group's units one per row, the base unit excepted.

func (*ExportUnitGroupsEndpoint) Materialize

type ExportUnitGroupsRequest

type ExportUnitGroupsRequest struct {
	// Free-text search term matched against unit group names.
	Query *string `json:"q"`
}

Filters which unit groups land in the exported file.

func (*ExportUnitGroupsRequest) SchemaExample

func (*ExportUnitGroupsRequest) SchemaExample() any

type ListUnitGroupUnitsEndpoint

type ListUnitGroupUnitsEndpoint struct{}

Returns the units associated with a unit group, along with the discount and customer portal visibility applied to each.

Every association in the group is returned in a single response; this list is not paginated.

type ListUnitGroupUnitsRequest

type ListUnitGroupUnitsRequest struct {
	// Unit group ID.
	UnitGroupID string `path:"unit_group_id" validate:"required"`
}

Request to list the associated units within a unit group.

type ListUnitGroupsEndpoint

type ListUnitGroupsEndpoint struct{}

Returns a paginated list of unit groups, including system unit groups.

type ListUnitGroupsRequest

type ListUnitGroupsRequest struct {
	apiresource.PaginationRequest
	// Filter by unit dimension.
	Type *constants.UnitType `query:"type"`
}

Request to list unit groups.

type RetrieveUnitGroupEndpoint

type RetrieveUnitGroupEndpoint struct{}

Returns a unit group by ID, including the system unit groups shared across all accounts.

func (*RetrieveUnitGroupEndpoint) Materialize

type RetrieveUnitGroupRequest

type RetrieveUnitGroupRequest struct {
	// Unit group ID.
	UnitGroupID string `path:"id" validate:"required"`
}

Request to retrieve a unit group.

type RetrieveUnitGroupUnitEndpoint

type RetrieveUnitGroupUnitEndpoint struct{}

Returns a single unit association within a unit group, including the discount and customer portal visibility applied to it.

type RetrieveUnitGroupUnitRequest

type RetrieveUnitGroupUnitRequest struct {
	// Unit group ID.
	UnitGroupID string `path:"unit_group_id" validate:"required"`
	// ID of the unit's association with the group, not the ID of the unit itself.
	UnitGroupUnitID string `path:"id" validate:"required"`
}

Request to retrieve an associated unit within a unit group.

type UnitGroupSvc

func NewUnitGroupSvc

func NewUnitGroupSvc(config *UnitGroupSvcConfig) UnitGroupSvc

type UnitGroupSvcConfig

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

type UpdateUnitGroupEndpoint

type UpdateUnitGroupEndpoint struct{}

Partially updates a unit group.

System unit groups cannot be modified, and a group's dimension is fixed once it is created.

func (*UpdateUnitGroupEndpoint) Materialize

type UpdateUnitGroupRequest

type UpdateUnitGroupRequest struct {
	// Unit group ID.
	UnitGroupID string `path:"id" validate:"required"`
	// Display name of the unit group.
	//
	// Must be unique within the account.
	Name field.Optional[string] `json:"name,omitzero" validate:"omitempty,max=255"`
	// Free-form notes about the unit group.
	//
	// Set to `null` to clear.
	Notes field.Clearable[string] `json:"notes,omitzero"`
	// ID of the unit to designate as the group's reference unit.
	//
	// Must be a unit of the group's dimension, which cannot itself be changed.
	BaseUnitID field.Optional[string] `json:"base_unit_id,omitzero" validate:"omitempty"`
	// Units to add to the group.
	//
	// Only units that are not already in the group can be listed here; use the associated-unit update and delete endpoints to change or remove an existing association. Associations left out of the list are untouched.
	AssociatedUnits field.Optional[[]CreateUnitGroupUnitParam] `json:"associated_units,omitzero"`
}

Request to partially update a unit group.

func (*UpdateUnitGroupRequest) SchemaExample

func (*UpdateUnitGroupRequest) SchemaExample() any

type UpdateUnitGroupUnitEndpoint

type UpdateUnitGroupUnitEndpoint struct{}

Partially updates a unit's association with a unit group, changing the discount or customer portal visibility applied when ordering in that unit.

Associations within system unit groups cannot be modified.

type UpdateUnitGroupUnitRequest

type UpdateUnitGroupUnitRequest struct {
	// Unit group ID.
	UnitGroupID string `path:"unit_group_id" validate:"required"`
	// ID of the unit's association with the group, not the ID of the unit itself.
	AssociatedUnitID string `path:"id" validate:"required"`
	// ID of the unit this association refers to.
	//
	// Sending a different unit does not repoint the association; remove the association and add a new one instead. A unit sent here must still match the group's `type`.
	UnitID field.Optional[string] `json:"unit_id,omitzero" validate:"omitempty"`
	// Share of the unit's price removed when an order is placed in this unit.
	//
	// Expressed as a decimal fraction rather than a whole number, so `0.1` is a 10% discount and `0` is no discount.
	DiscountPercentage field.Optional[float64] `json:"discount_percentage,omitzero"`
	// Flat amount subtracted from the unit's price when an order is placed in this unit.
	//
	// Subtracted before `discount_percentage` is applied.
	DiscountFixed field.Optional[float64] `json:"discount_fixed,omitzero"`
	// Whether the unit is shown to customers in the customer portal.
	CustomerPortalVisibility field.Optional[constants.CustomerPortalVisibility] `json:"customer_portal_visibility,omitzero"`
}

Request to partially update an associated unit within a unit group.

func (*UpdateUnitGroupUnitRequest) SchemaExample

func (*UpdateUnitGroupUnitRequest) SchemaExample() any

type UpsertUnitGroupConversionInput

type UpsertUnitGroupConversionInput struct {
	// Unit for this conversion, referenced by `id`, `name`, or `abbreviation`.
	Unit apirequest.UnitIdentifier `json:"unit" validate:"required"`
	// Discount percentage to apply for this unit conversion.
	DiscountPercentage *float64 `json:"discount_percentage,omitempty" default:"1" nullable:"false"`
}

UpsertUnitGroupConversionInput is the input for a single unit conversion within a bulk upsert unit group.

type UpsertUnitGroupInput

type UpsertUnitGroupInput struct {
	// Display name of the unit group, matched case-insensitively against existing groups.
	// A row matching a system unit group fails — system groups cannot be modified.
	Name string `json:"name" validate:"required,max=255"`
	// Free-form notes about the unit group. Preserved when omitted on update.
	Notes *string `json:"notes,omitempty" default:"null" nullable:"false"`
	// Unit dimension type. Create-only — an existing group keeps its stored type.
	Type constants.UnitType `json:"type" validate:"required"`
	// Base unit for this group, referenced by `id`, `name`, or `abbreviation`.
	BaseUnit apirequest.UnitIdentifier `json:"base_unit" validate:"required"`
	// Units to associate with the group. Replaces the existing set on update; the base
	// unit is always kept.
	UnitConversions []UpsertUnitGroupConversionInput `json:"unit_conversions,omitempty"`
}

UpsertUnitGroupInput is the input for a single unit group in a bulk upsert operation.

Jump to

Keyboard shortcuts

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