Documentation
¶
Index ¶
- Constants
- type BulkUpsertPropertiesEndpoint
- type BulkUpsertPropertiesRequest
- type CreateAttributeEndpoint
- type CreateAttributeRequest
- type CreatePropertyEndpoint
- type CreatePropertyRequest
- type DeleteAttributeEndpoint
- type DeleteAttributeRequest
- type DeletePropertyEndpoint
- type DeletePropertyRequest
- type ExportPropertiesEndpoint
- type ExportPropertiesRequest
- type ListAttributesEndpoint
- type ListAttributesRequest
- type ListPropertiesEndpoint
- type ListPropertiesRequest
- type PropertySvc
- type PropertySvcConfig
- type RetrieveAttributeEndpoint
- type RetrieveAttributeRequest
- type RetrievePropertyEndpoint
- type RetrievePropertyRequest
- type UpdateAttributeEndpoint
- type UpdateAttributeRequest
- type UpdatePropertyEndpoint
- type UpdatePropertyRequest
- type UpsertPropertyAttributeInput
- type UpsertPropertyInput
Constants ¶
const ( CatalogPropertiesRoute = "/v1/catalog/properties" CatalogPropertyRoute = "/v1/catalog/properties/{id}" CatalogPropertyAttributesRoute = "/v1/catalog/properties/{property_id}/attributes" CatalogPropertyAttributeRoute = "/v1/catalog/properties/{property_id}/attributes/{id}" )
Canonical HTTP route templates for this package. Endpoint Materialize Route fields must use these constants; presenters build concrete paths via apiendpoint.ExpandRoute.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BulkUpsertPropertiesEndpoint ¶
type BulkUpsertPropertiesEndpoint struct{}
Creates or updates multiple properties and their attributes for the account, matched by name (case-insensitive), then writes asynchronously — 202 with a job to poll.
func (*BulkUpsertPropertiesEndpoint) Materialize ¶
func (e *BulkUpsertPropertiesEndpoint) Materialize() *apiendpoint.APIEndpoint[*BulkUpsertPropertiesRequest, *apiresource.Job]
type BulkUpsertPropertiesRequest ¶
type BulkUpsertPropertiesRequest struct {
// Properties to create or update, matched by name (case-insensitive) within the account.
Properties []UpsertPropertyInput `json:"properties" validate:"required,min=1,max=1000,dive"`
}
carries the properties to bulk upsert
func (*BulkUpsertPropertiesRequest) SchemaExample ¶
func (*BulkUpsertPropertiesRequest) SchemaExample() any
type CreateAttributeEndpoint ¶
type CreateAttributeEndpoint struct{}
Creates an attribute under a property.
An attribute is one selectable value of the property, such as `Red` under `Color`, and can then be assigned to items. Returns a conflict error if another attribute in the account already uses the same value.
func (*CreateAttributeEndpoint) Materialize ¶
func (e *CreateAttributeEndpoint) Materialize() *apiendpoint.APIEndpoint[*CreateAttributeRequest, *apiresource.Attribute]
type CreateAttributeRequest ¶
type CreateAttributeRequest struct {
// The property to add this attribute to.
PropertyID string `path:"property_id" validate:"required"`
// The selectable value this attribute represents, such as `Red`.
//
// Must be unique across all attributes in the account, not just within the property. Leading and trailing whitespace is trimmed.
Value string `json:"value" validate:"required"`
// Swatch color used to display this attribute in the UI.
//
// When omitted, one of the nine named colors (everything except `default`) is assigned at random.
ColorCode field.Optional[constants.Color] `json:"color,omitzero"`
// Position of the new attribute relative to its siblings within the property, starting at `1`.
//
// Must be at most the property's current attribute count plus one; siblings at or after this position are shifted one position later. Defaults to the last position if not provided.
SortOrder field.Optional[int32] `json:"sort_order,omitzero" validate:"omitempty,min=1"`
}
Request to create an attribute.
func (*CreateAttributeRequest) SchemaExample ¶
func (*CreateAttributeRequest) SchemaExample() any
type CreatePropertyEndpoint ¶
type CreatePropertyEndpoint struct{}
Creates a property.
The property starts with no attributes; add its selectable values afterwards with the create attribute endpoint. Returns a conflict error if a property with the same name already exists.
func (*CreatePropertyEndpoint) Materialize ¶
func (e *CreatePropertyEndpoint) Materialize() *apiendpoint.APIEndpoint[*CreatePropertyRequest, *apiresource.Property]
type CreatePropertyRequest ¶
type CreatePropertyRequest struct {
// Display name of the property, such as `Color` or `Size`.
//
// Must be unique within your account.
Name string `json:"name" validate:"required,max=255"`
}
Request to create a property.
func (*CreatePropertyRequest) SchemaExample ¶
func (*CreatePropertyRequest) SchemaExample() any
type DeleteAttributeEndpoint ¶
type DeleteAttributeEndpoint struct{}
Deletes an attribute from a property.
Remaining attributes in the property are shifted so their sort orders stay contiguous.
func (*DeleteAttributeEndpoint) Materialize ¶
func (e *DeleteAttributeEndpoint) Materialize() *apiendpoint.APIEndpoint[*DeleteAttributeRequest, *apiresource.EmptyResource]
type DeleteAttributeRequest ¶
type DeleteAttributeRequest struct {
// The property the attribute belongs to.
PropertyID string `path:"property_id" validate:"required"`
// Attribute ID.
AttributeID string `path:"id" validate:"required"`
}
Request to delete an attribute.
type DeletePropertyEndpoint ¶
type DeletePropertyEndpoint struct{}
Deletes a property and every attribute defined under it.
Items previously classified by those attributes lose that classification.
func (*DeletePropertyEndpoint) Materialize ¶
func (e *DeletePropertyEndpoint) Materialize() *apiendpoint.APIEndpoint[*DeletePropertyRequest, *apiresource.EmptyResource]
type DeletePropertyRequest ¶
type DeletePropertyRequest struct {
// Property ID.
PropertyID string `path:"id" validate:"required"`
}
Request to delete a property.
type ExportPropertiesEndpoint ¶
type ExportPropertiesEndpoint struct{}
Starts an export of every matching property, one row per attribute, and returns the job that tracks it.
func (*ExportPropertiesEndpoint) Materialize ¶
func (e *ExportPropertiesEndpoint) Materialize() *apiendpoint.APIEndpoint[*ExportPropertiesRequest, *apiresource.Job]
type ExportPropertiesRequest ¶
type ExportPropertiesRequest struct {
// Free-text search term matched against property names.
Query *string `json:"q"`
}
Filters which properties land in the exported file.
func (*ExportPropertiesRequest) SchemaExample ¶
func (*ExportPropertiesRequest) SchemaExample() any
type ListAttributesEndpoint ¶
type ListAttributesEndpoint struct{}
Returns a paginated list of attributes for a property.
Attributes come back in the order they are arranged within the property, first to last. The `q` search term is matched against the attribute value.
func (*ListAttributesEndpoint) Materialize ¶
func (e *ListAttributesEndpoint) Materialize() *apiendpoint.APIEndpoint[*ListAttributesRequest, *apiresource.List[apiresource.Attribute]]
type ListAttributesRequest ¶
type ListAttributesRequest struct {
apiresource.PaginationRequest
// The property whose attributes are listed.
PropertyID string `path:"property_id" validate:"required"`
}
Request to list attributes for a property.
type ListPropertiesEndpoint ¶
type ListPropertiesEndpoint struct{}
Returns a paginated list of properties for the target account.
Properties come back newest first. The `q` search term is matched against the property name.
func (*ListPropertiesEndpoint) Materialize ¶
func (e *ListPropertiesEndpoint) Materialize() *apiendpoint.APIEndpoint[*ListPropertiesRequest, *apiresource.List[apiresource.Property]]
type ListPropertiesRequest ¶
type ListPropertiesRequest struct {
apiresource.PaginationRequest
}
Request to list properties.
type PropertySvc ¶
type PropertySvc interface {
ListProperties(ctx context.Context, req *ListPropertiesRequest) (*apiresource.List[apiresource.Property], *apierror.APIError)
GetProperty(ctx context.Context, req *RetrievePropertyRequest) (*apiresource.Property, *apierror.APIError)
CreateProperty(ctx context.Context, req *CreatePropertyRequest) (*apiresource.Property, *apierror.APIError)
UpdateProperty(ctx context.Context, req *UpdatePropertyRequest) (*apiresource.Property, *apierror.APIError)
DeleteProperty(ctx context.Context, req *DeletePropertyRequest) (*apiresource.EmptyResource, *apierror.APIError)
BulkUpsertProperties(ctx context.Context, req *BulkUpsertPropertiesRequest) (*apiresource.Job, *apierror.APIError)
ExportProperties(ctx context.Context, req *ExportPropertiesRequest) (*apiresource.Job, *apierror.APIError)
ListAttributes(ctx context.Context, req *ListAttributesRequest) (*apiresource.List[apiresource.Attribute], *apierror.APIError)
GetAttribute(ctx context.Context, req *RetrieveAttributeRequest) (*apiresource.Attribute, *apierror.APIError)
CreateAttribute(ctx context.Context, req *CreateAttributeRequest) (*apiresource.Attribute, *apierror.APIError)
UpdateAttribute(ctx context.Context, req *UpdateAttributeRequest) (*apiresource.Attribute, *apierror.APIError)
DeleteAttribute(ctx context.Context, req *DeleteAttributeRequest) (*apiresource.EmptyResource, *apierror.APIError)
}
func NewPropertySvc ¶
func NewPropertySvc(config *PropertySvcConfig) PropertySvc
type PropertySvcConfig ¶
type PropertySvcConfig struct {
// CoreClient (required) is the core-service gRPC client.
CoreClient pb.CoreServiceClient
}
type RetrieveAttributeEndpoint ¶
type RetrieveAttributeEndpoint struct{}
Returns an attribute by ID within a property.
func (*RetrieveAttributeEndpoint) Materialize ¶
func (e *RetrieveAttributeEndpoint) Materialize() *apiendpoint.APIEndpoint[*RetrieveAttributeRequest, *apiresource.Attribute]
type RetrieveAttributeRequest ¶
type RetrieveAttributeRequest struct {
// The property the attribute belongs to.
PropertyID string `path:"property_id" validate:"required"`
// Attribute ID.
AttributeID string `path:"id" validate:"required"`
}
Request to retrieve an attribute.
type RetrievePropertyEndpoint ¶
type RetrievePropertyEndpoint struct{}
Returns a property by ID.
func (*RetrievePropertyEndpoint) Materialize ¶
func (e *RetrievePropertyEndpoint) Materialize() *apiendpoint.APIEndpoint[*RetrievePropertyRequest, *apiresource.Property]
type RetrievePropertyRequest ¶
type RetrievePropertyRequest struct {
// Property ID.
PropertyID string `path:"id" validate:"required"`
}
Request to retrieve a property.
type UpdateAttributeEndpoint ¶
type UpdateAttributeEndpoint struct{}
Partially updates an attribute.
Items reference attributes by ID, so changing the value renames the attribute everywhere it is already assigned.
func (*UpdateAttributeEndpoint) Materialize ¶
func (e *UpdateAttributeEndpoint) Materialize() *apiendpoint.APIEndpoint[*UpdateAttributeRequest, *apiresource.Attribute]
type UpdateAttributeRequest ¶
type UpdateAttributeRequest struct {
// The property the attribute belongs to.
PropertyID string `path:"property_id" validate:"required"`
// Attribute ID.
AttributeID string `path:"id" validate:"required"`
// The selectable value this attribute represents, such as `Red`.
//
// Must be non-blank and unique across all attributes in the account, not just within the property.
Value field.Optional[string] `json:"value,omitzero"`
// Swatch color used to display this attribute in the UI.
ColorCode field.Optional[constants.Color] `json:"color,omitzero"`
// New position of this attribute relative to its siblings within the property, starting at `1`.
//
// Must be at most the property's current attribute count; the attributes between the old and new positions shift to make room.
SortOrder field.Optional[int32] `json:"sort_order,omitzero" validate:"omitempty,min=1"`
}
Request to update an attribute.
func (*UpdateAttributeRequest) SchemaExample ¶
func (*UpdateAttributeRequest) SchemaExample() any
type UpdatePropertyEndpoint ¶
type UpdatePropertyEndpoint struct{}
Partially updates a property.
func (*UpdatePropertyEndpoint) Materialize ¶
func (e *UpdatePropertyEndpoint) Materialize() *apiendpoint.APIEndpoint[*UpdatePropertyRequest, *apiresource.Property]
type UpdatePropertyRequest ¶
type UpdatePropertyRequest struct {
// Property ID.
PropertyID string `path:"id" validate:"required"`
// Display name of the property, such as `Color` or `Size`.
//
// Must be unique within your account.
Name field.Optional[string] `json:"name,omitzero" validate:"omitempty,max=255"`
}
Request to update a property.
func (*UpdatePropertyRequest) SchemaExample ¶
func (*UpdatePropertyRequest) SchemaExample() any
type UpsertPropertyAttributeInput ¶
type UpsertPropertyAttributeInput struct {
// The selectable value this attribute represents, such as `Red`.
//
// Must be unique across all attributes in the account, not just within the property. Leading and trailing whitespace is trimmed.
Value string `json:"value" validate:"required,max=255"`
// Swatch color used to display this attribute in the UI.
//
// When omitted, one of the nine named colors is assigned. Ignored for a value the property already defines.
ColorCode field.Optional[constants.Color] `json:"color,omitzero"`
}
carries one attribute under a bulk-upserted property
type UpsertPropertyInput ¶
type UpsertPropertyInput struct {
// Display name of the property, used to match existing properties within the account.
Name string `json:"name" validate:"required,max=255"`
// The selectable values to define under this property, in the order they should be arranged.
//
// Additive — values the property already defines are left as they stand, and none are removed. New values are appended after the existing ones.
Attributes []UpsertPropertyAttributeInput `json:"attributes" default:"[]" validate:"max=1000,dive"`
}
carries one property in a bulk upsert
Source Files
¶
- endpoint_bulk_upsert_properties.go
- endpoint_create_attribute.go
- endpoint_create_property.go
- endpoint_delete_attribute.go
- endpoint_delete_property.go
- endpoint_export_properties.go
- endpoint_list_attributes.go
- endpoint_list_properties.go
- endpoint_retrieve_attribute.go
- endpoint_retrieve_property.go
- endpoint_update_attribute.go
- endpoint_update_property.go
- routes.go
- service.go