Documentation
¶
Index ¶
- type AccountGroupSvc
- type AccountGroupSvcConfig
- type CreateAccountGroupEndpoint
- type CreateAccountGroupRequest
- type DeleteAccountGroupEndpoint
- type DeleteAccountGroupRequest
- type ListAccountGroupsEndpoint
- type ListAccountGroupsRequest
- type RetrieveAccountGroupEndpoint
- type RetrieveAccountGroupRequest
- type UpdateAccountGroupEndpoint
- type UpdateAccountGroupRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountGroupSvc ¶
type AccountGroupSvc interface {
ListAccountGroups(ctx context.Context, req *ListAccountGroupsRequest) (*apiresource.List[apiresource.AccountGroup], *apierror.APIError)
GetAccountGroup(ctx context.Context, req *RetrieveAccountGroupRequest) (*apiresource.AccountGroup, *apierror.APIError)
CreateAccountGroup(ctx context.Context, req *CreateAccountGroupRequest) (*apiresource.AccountGroup, *apierror.APIError)
UpdateAccountGroup(ctx context.Context, req *UpdateAccountGroupRequest) (*apiresource.AccountGroup, *apierror.APIError)
DeleteAccountGroup(ctx context.Context, req *DeleteAccountGroupRequest) (*apiresource.EmptyResource, *apierror.APIError)
}
func NewAccountGroupSvc ¶
func NewAccountGroupSvc(config *AccountGroupSvcConfig) AccountGroupSvc
type AccountGroupSvcConfig ¶
type AccountGroupSvcConfig struct {
// CoreClient (required) is the core-service gRPC client.
CoreClient pb.CoreServiceClient
}
type CreateAccountGroupEndpoint ¶
type CreateAccountGroupEndpoint struct{}
Creates an account group.
Returns a conflict error if an account group with the same name already exists.
func (*CreateAccountGroupEndpoint) Materialize ¶
func (e *CreateAccountGroupEndpoint) Materialize() *apiendpoint.APIEndpoint[*CreateAccountGroupRequest, *apiresource.AccountGroup]
type CreateAccountGroupRequest ¶
type CreateAccountGroupRequest struct {
// Display name of the account group.
//
// Must be unique within your account.
Name string `json:"name" validate:"required,max=255"`
// How this account group will be used.
//
// - `pricing_group`: used for pricing rules, such as a "Preferred" group that receives a special discount.
// - `type_group`: used to categorize accounts, such as "Consumers" or "Distributors".
//
// The type cannot be changed after creation.
Type constants.AccountGroupType `json:"type" validate:"required"`
// How sales commission applies to accounts in this group.
//
// - `commission_applied`: sales commission is calculated on orders from accounts in this group.
// - `commission_exempt`: orders from accounts in this group are exempt from commission.
//
// Leave this out and the group is created commission-exempt, so orders from its accounts earn no sales commission until you change it.
CommissionPolicy field.Optional[constants.CommissionPolicy] `json:"commission_policy,omitzero" default:"commission_exempt"`
// How freight charges apply to orders from accounts in this group.
//
// - `free_freight`: customers within this group will not have to pay for freight.
// - `billed_freight`: freight will be applied to any order within this account group, unless overridden elsewhere.
FreightPolicy field.Optional[constants.FreightPolicy] `json:"freight_policy,omitzero" default:"billed_freight"`
// Calendar days between an order being issued and it being due to ship, inherited by every customer in this group that has not set its own.
DefaultLeadTimeDays field.Optional[int32] `json:"default_lead_time_days,omitzero" validate:"omitempty,gte=0,lte=3650"`
// Free-form description of the account group.
Description field.Optional[string] `json:"description,omitzero"`
}
Request to create an account group.
func (*CreateAccountGroupRequest) SchemaExample ¶
func (*CreateAccountGroupRequest) SchemaExample() any
type DeleteAccountGroupEndpoint ¶
type DeleteAccountGroupEndpoint struct{}
Deletes an account group.
Deletion fails with a validation error while the group is still in use: a `type_group` that is set as a customer's type cannot be deleted, and no group can be deleted while it grants product line access, backs a volume discount, or is attached to a customer registration flow.
Deleting a `pricing_group` first unassigns it from every customer it was applied to, so those customers immediately stop receiving its pricing.
func (*DeleteAccountGroupEndpoint) Materialize ¶
func (e *DeleteAccountGroupEndpoint) Materialize() *apiendpoint.APIEndpoint[*DeleteAccountGroupRequest, *apiresource.EmptyResource]
type DeleteAccountGroupRequest ¶
type DeleteAccountGroupRequest struct {
// Account group ID.
AccountGroupID string `path:"id" validate:"required"`
}
Request to delete an account group.
type ListAccountGroupsEndpoint ¶
type ListAccountGroupsEndpoint struct{}
Returns a paginated list of account groups, newest first.
The `q` search term matches the group's name and description.
func (*ListAccountGroupsEndpoint) Materialize ¶
func (e *ListAccountGroupsEndpoint) Materialize() *apiendpoint.APIEndpoint[*ListAccountGroupsRequest, *apiresource.List[apiresource.AccountGroup]]
type ListAccountGroupsRequest ¶
type ListAccountGroupsRequest struct {
apiresource.PaginationRequest
// Filters results to account groups of the given type.
Type *constants.AccountGroupType `query:"type"`
}
Request to list account groups.
type RetrieveAccountGroupEndpoint ¶
type RetrieveAccountGroupEndpoint struct{}
Returns an account group by ID.
func (*RetrieveAccountGroupEndpoint) Materialize ¶
func (e *RetrieveAccountGroupEndpoint) Materialize() *apiendpoint.APIEndpoint[*RetrieveAccountGroupRequest, *apiresource.AccountGroup]
type RetrieveAccountGroupRequest ¶
type RetrieveAccountGroupRequest struct {
// Account group ID.
AccountGroupID string `path:"id" validate:"required"`
}
Request to retrieve an account group.
type UpdateAccountGroupEndpoint ¶
type UpdateAccountGroupEndpoint struct{}
Partially updates an account group.
Only the provided fields are changed. The account group's `type` cannot be changed after creation, and renaming the group to a name another group in your account already uses returns a conflict error.
A new commission or freight policy takes effect for every account already in the group, not just accounts added afterwards.
func (*UpdateAccountGroupEndpoint) Materialize ¶
func (e *UpdateAccountGroupEndpoint) Materialize() *apiendpoint.APIEndpoint[*UpdateAccountGroupRequest, *apiresource.AccountGroup]
type UpdateAccountGroupRequest ¶
type UpdateAccountGroupRequest struct {
// Account group ID.
AccountGroupID string `path:"id" validate:"required"`
// Display name of the account group.
//
// Must be unique within your account.
Name field.Optional[string] `json:"name,omitzero" validate:"omitempty,max=255"`
// Free-form description of the account group.
Description field.Clearable[string] `json:"description,omitzero"`
// How sales commission applies to accounts in this group.
//
// - `commission_applied`: sales commission is calculated on orders from accounts in this group.
// - `commission_exempt`: orders from accounts in this group are exempt from commission.
CommissionPolicy field.Optional[constants.CommissionPolicy] `json:"commission_policy,omitzero"`
// How freight charges apply to orders from accounts in this group.
//
// - `free_freight`: customers within this group will not have to pay for freight.
// - `billed_freight`: freight will be applied to any order within this account group, unless overridden elsewhere.
FreightPolicy field.Optional[constants.FreightPolicy] `json:"freight_policy,omitzero"`
// Calendar days between an order being issued and it being due to ship, inherited by every customer in this group that has not set its own. Clearing it returns the group's customers to the account default.
DefaultLeadTimeDays field.Clearable[int32] `json:"default_lead_time_days,omitzero" validate:"omitempty,gte=0,lte=3650"`
}
Request to partially update an account group.
func (*UpdateAccountGroupRequest) SchemaExample ¶
func (*UpdateAccountGroupRequest) SchemaExample() any