Documentation
¶
Index ¶
- Constants
- Variables
- func IsKeyConflictError(err error) bool
- func IsSubjectKeyConflictError(err error) bool
- func NewErrDeletingCustomerWithActiveSubscriptions(subscriptionIDs []string) error
- type Adapter
- type CreateCustomerInput
- type Customer
- type CustomerAdapter
- type CustomerCreateEvent
- type CustomerDeleteEvent
- type CustomerID
- type CustomerIDOrKey
- type CustomerKey
- type CustomerMutate
- type CustomerService
- type CustomerUpdateEvent
- type CustomerUsageAttribution
- type DeleteCustomerInput
- type Expand
- type Expands
- type GetCustomerByUsageAttributionInput
- type GetCustomerInput
- type GetEntitlementValueInput
- type KeyConflictError
- type ListCustomerUsageAttributionsInput
- type ListCustomersInput
- type NoopRequestValidator
- type RequestValidator
- type RequestValidatorKey
- type RequestValidatorRegistry
- type RequestValidatorService
- type Service
- type SubjectKeyConflictError
- type UpdateAfterDeleteError
- type UpdateCustomerInput
Constants ¶
const ( IncludeDeleted = false DefaultPageNumber = 1 DefaultPageSize = 100 )
const ( CustomerEventSubsystem metadata.EventSubsystem = "customer" CustomerCreateEventName metadata.EventName = "customer.created" CustomerUpdateEventName metadata.EventName = "customer.updated" CustomerDeleteEventName metadata.EventName = "customer.deleted" )
const ErrCodeDeletingCustomerWithActiveSubscriptions models.ErrorCode = "deleting_customer_with_active_subscriptions"
const MinSubjectKeyLength = 1
Variables ¶
var ErrDeletingCustomerWithActiveSubscriptions = models.NewValidationIssue( ErrCodeDeletingCustomerWithActiveSubscriptions, "cannot delete customer with active subscriptions", )
var (
ErrValidatorAlreadyRegistered = errors.New("validator already registered")
)
Functions ¶
func IsKeyConflictError ¶
Types ¶
type Adapter ¶
type Adapter interface {
CustomerAdapter
entutils.TxCreator
}
type CreateCustomerInput ¶
type CreateCustomerInput struct {
Namespace string
CustomerMutate
}
CreateCustomerInput represents the input for the CreateCustomer method
func (CreateCustomerInput) Validate ¶
func (i CreateCustomerInput) Validate() error
type Customer ¶
type Customer struct {
models.ManagedResource
Key *string `json:"key,omitempty"`
UsageAttribution *CustomerUsageAttribution `json:"usageAttribution,omitempty"`
PrimaryEmail *string `json:"primaryEmail,omitempty"`
Currency *currencyx.Code `json:"currency,omitempty"`
BillingAddress *models.Address `json:"billingAddress,omitempty"`
Metadata *models.Metadata `json:"metadata,omitempty"`
Annotation *models.Annotations `json:"annotations,omitempty"`
ActiveSubscriptionIDs mo.Option[[]string]
}
Customer represents a customer
func (Customer) AsCustomerMutate ¶
func (c Customer) AsCustomerMutate() CustomerMutate
AsCustomerMutate returns a CustomerMutate from the Customer
func (Customer) GetID ¶
func (c Customer) GetID() CustomerID
GetID returns the customer id This is a convenience method to get the customer id as a CustomerID It is used to avoid having to create a CustomerID struct in the codebase
func (Customer) GetUsageAttribution ¶
func (c Customer) GetUsageAttribution() streaming.CustomerUsageAttribution
GetUsageAttribution returns the customer usage attribution implementing the streaming.CustomerUsageAttribution interface
type CustomerAdapter ¶
type CustomerAdapter interface {
ListCustomers(ctx context.Context, params ListCustomersInput) (pagination.Result[Customer], error)
ListCustomerUsageAttributions(ctx context.Context, input ListCustomerUsageAttributionsInput) (pagination.Result[streaming.CustomerUsageAttribution], error)
CreateCustomer(ctx context.Context, params CreateCustomerInput) (*Customer, error)
DeleteCustomer(ctx context.Context, customer DeleteCustomerInput) error
GetCustomer(ctx context.Context, customer GetCustomerInput) (*Customer, error)
GetCustomerByUsageAttribution(ctx context.Context, input GetCustomerByUsageAttributionInput) (*Customer, error)
UpdateCustomer(ctx context.Context, params UpdateCustomerInput) (*Customer, error)
}
type CustomerCreateEvent ¶
type CustomerCreateEvent struct {
Customer *Customer `json:"customer"`
UserID *string `json:"userId,omitempty"`
}
CustomerCreateEvent is an event that is emitted when a customer is created
func NewCustomerCreateEvent ¶
func NewCustomerCreateEvent(ctx context.Context, customer *Customer) CustomerCreateEvent
NewCustomerCreateEvent creates a new customer create event
func (CustomerCreateEvent) EventMetadata ¶
func (e CustomerCreateEvent) EventMetadata() metadata.EventMetadata
func (CustomerCreateEvent) EventName ¶
func (e CustomerCreateEvent) EventName() string
func (CustomerCreateEvent) Validate ¶
func (e CustomerCreateEvent) Validate() error
type CustomerDeleteEvent ¶
type CustomerDeleteEvent struct {
Customer *Customer `json:"customer"`
UserID *string `json:"userId,omitempty"`
}
CustomerDeleteEvent is an event that is emitted when a customer is deleted
func NewCustomerDeleteEvent ¶
func NewCustomerDeleteEvent(ctx context.Context, customer *Customer) CustomerDeleteEvent
NewCustomerDeleteEvent creates a new customer delete event
func (CustomerDeleteEvent) EventMetadata ¶
func (e CustomerDeleteEvent) EventMetadata() metadata.EventMetadata
func (CustomerDeleteEvent) EventName ¶
func (e CustomerDeleteEvent) EventName() string
func (CustomerDeleteEvent) Validate ¶
func (e CustomerDeleteEvent) Validate() error
type CustomerID ¶
type CustomerID models.NamespacedID
CustomerID represents a customer id
func (CustomerID) Validate ¶
func (i CustomerID) Validate() error
type CustomerIDOrKey ¶
CustomerIDOrKey represents a customer id or key
func (CustomerIDOrKey) Validate ¶
func (i CustomerIDOrKey) Validate() error
type CustomerKey ¶
CustomerKey represents a customer key
func (CustomerKey) Validate ¶
func (i CustomerKey) Validate() error
type CustomerMutate ¶
type CustomerMutate struct {
Key *string `json:"key,omitempty"`
Name string `json:"name"`
Description *string `json:"description,omitempty"`
UsageAttribution *CustomerUsageAttribution `json:"usageAttribution,omitempty"`
PrimaryEmail *string `json:"primaryEmail"`
Currency *currencyx.Code `json:"currency"`
BillingAddress *models.Address `json:"billingAddress"`
Metadata *models.Metadata `json:"metadata"`
Annotation *models.Annotations `json:"annotations,omitempty"`
}
func (CustomerMutate) Validate ¶
func (c CustomerMutate) Validate() error
type CustomerService ¶
type CustomerService interface {
ListCustomers(ctx context.Context, params ListCustomersInput) (pagination.Result[Customer], error)
ListCustomerUsageAttributions(ctx context.Context, input ListCustomerUsageAttributionsInput) (pagination.Result[streaming.CustomerUsageAttribution], error)
CreateCustomer(ctx context.Context, params CreateCustomerInput) (*Customer, error)
DeleteCustomer(ctx context.Context, customer DeleteCustomerInput) error
GetCustomer(ctx context.Context, customer GetCustomerInput) (*Customer, error)
GetCustomerByUsageAttribution(ctx context.Context, input GetCustomerByUsageAttributionInput) (*Customer, error)
UpdateCustomer(ctx context.Context, params UpdateCustomerInput) (*Customer, error)
}
type CustomerUpdateEvent ¶
type CustomerUpdateEvent struct {
Customer *Customer `json:"customer"`
UserID *string `json:"userId,omitempty"`
}
CustomerUpdateEvent is an event that is emitted when a customer is updated
func NewCustomerUpdateEvent ¶
func NewCustomerUpdateEvent(ctx context.Context, customer *Customer) CustomerUpdateEvent
NewCustomerUpdateEvent creates a new customer update event
func (CustomerUpdateEvent) EventMetadata ¶
func (e CustomerUpdateEvent) EventMetadata() metadata.EventMetadata
func (CustomerUpdateEvent) EventName ¶
func (e CustomerUpdateEvent) EventName() string
func (CustomerUpdateEvent) Validate ¶
func (e CustomerUpdateEvent) Validate() error
type CustomerUsageAttribution ¶
type CustomerUsageAttribution struct {
SubjectKeys []string `json:"subjectKeys"`
}
CustomerUsageAttribution represents the additional fields for a customer usage attribution Do not use this struct directly, use the GetUsageAttribution method instead that implements the streaming.CustomerUsageAttribution interface The customer usage attribution is more than just the subject keys, it also includes key for example.
func (CustomerUsageAttribution) GetFirstSubjectKey
deprecated
func (c CustomerUsageAttribution) GetFirstSubjectKey() (string, error)
Deprecated: This functionality is only present for backwards compatibility
func (CustomerUsageAttribution) Validate ¶
func (c CustomerUsageAttribution) Validate() error
type DeleteCustomerInput ¶
type DeleteCustomerInput = CustomerID
DeleteCustomerInput represents the input for the DeleteCustomer method
type GetCustomerByUsageAttributionInput ¶
type GetCustomerByUsageAttributionInput struct {
Namespace string
// The key of either the customer or one of its subjects
Key string
// Expand
Expands Expands
}
GetCustomerByUsageAttributionInput represents the input for the GetCustomerByUsageAttribution method
func (GetCustomerByUsageAttributionInput) Validate ¶
func (i GetCustomerByUsageAttributionInput) Validate() error
type GetCustomerInput ¶
type GetCustomerInput struct {
CustomerID *CustomerID
CustomerKey *CustomerKey
CustomerIDOrKey *CustomerIDOrKey
// Expand
Expands Expands
}
GetCustomerInput represents the input for the GetCustomer method
func (GetCustomerInput) Validate ¶
func (i GetCustomerInput) Validate() error
type GetEntitlementValueInput ¶
type GetEntitlementValueInput struct {
CustomerID CustomerID
FeatureKey string
}
func (GetEntitlementValueInput) Validate ¶
func (i GetEntitlementValueInput) Validate() error
type KeyConflictError ¶
type KeyConflictError struct {
// contains filtered or unexported fields
}
KeyConflictError represents an error when a subject key is already associated with a customer
func NewKeyConflictError ¶
func NewKeyConflictError(namespace, key string) *KeyConflictError
NewKeyConflictError creates a new KeyConflictError
func (KeyConflictError) Error ¶
func (e KeyConflictError) Error() string
func (KeyConflictError) Unwrap ¶
func (e KeyConflictError) Unwrap() error
type ListCustomerUsageAttributionsInput ¶
type ListCustomerUsageAttributionsInput struct {
Namespace string
pagination.Page
// Filters
IncludeDeleted bool
CustomerIDs []string
}
func (ListCustomerUsageAttributionsInput) Validate ¶
func (i ListCustomerUsageAttributionsInput) Validate() error
type ListCustomersInput ¶
type ListCustomersInput struct {
Namespace string
pagination.Page
IncludeDeleted bool
// Order
OrderBy string
Order sortx.Order
// Filters
Key *string
Name *string
PrimaryEmail *string
Subject *string
PlanKey *string
CustomerIDs []string
// Expand
Expands Expands
}
ListCustomersInput represents the input for the ListCustomers method
func (ListCustomersInput) Validate ¶
func (i ListCustomersInput) Validate() error
type NoopRequestValidator ¶
type NoopRequestValidator struct{}
func (NoopRequestValidator) ValidateCreateCustomer ¶
func (NoopRequestValidator) ValidateCreateCustomer(context.Context, CreateCustomerInput) error
func (NoopRequestValidator) ValidateDeleteCustomer ¶
func (NoopRequestValidator) ValidateDeleteCustomer(context.Context, DeleteCustomerInput) error
func (NoopRequestValidator) ValidateUpdateCustomer ¶
func (NoopRequestValidator) ValidateUpdateCustomer(context.Context, UpdateCustomerInput) error
type RequestValidator ¶
type RequestValidator interface {
ValidateDeleteCustomer(context.Context, DeleteCustomerInput) error
ValidateCreateCustomer(context.Context, CreateCustomerInput) error
ValidateUpdateCustomer(context.Context, UpdateCustomerInput) error
}
type RequestValidatorKey ¶
type RequestValidatorKey string
type RequestValidatorRegistry ¶
type RequestValidatorRegistry interface {
RequestValidator
Register(RequestValidator)
}
func NewRequestValidatorRegistry ¶
func NewRequestValidatorRegistry() RequestValidatorRegistry
type RequestValidatorService ¶
type RequestValidatorService interface {
RegisterRequestValidator(RequestValidator)
}
type Service ¶
type Service interface {
CustomerService
RequestValidatorService
models.ServiceHooks[Customer]
}
type SubjectKeyConflictError ¶
type SubjectKeyConflictError struct {
// contains filtered or unexported fields
}
SubjectKeyConflictError represents an error when a subject key is already associated with a customer
func NewSubjectKeyConflictError ¶
func NewSubjectKeyConflictError(namespace string, subjectKeys []string) *SubjectKeyConflictError
NewSubjectKeyConflictError creates a new SubjectKeyConflictError
func (SubjectKeyConflictError) Error ¶
func (e SubjectKeyConflictError) Error() string
func (SubjectKeyConflictError) Unwrap ¶
func (e SubjectKeyConflictError) Unwrap() error
type UpdateAfterDeleteError ¶
type UpdateAfterDeleteError struct {
// contains filtered or unexported fields
}
func NewUpdateAfterDeleteError ¶
func NewUpdateAfterDeleteError() *UpdateAfterDeleteError
func (UpdateAfterDeleteError) Error ¶
func (e UpdateAfterDeleteError) Error() string
func (UpdateAfterDeleteError) Unwrap ¶
func (e UpdateAfterDeleteError) Unwrap() error
type UpdateCustomerInput ¶
type UpdateCustomerInput struct {
CustomerID CustomerID
CustomerMutate
}
UpdateCustomerInput represents the input for the UpdateCustomer method
func (UpdateCustomerInput) Validate ¶
func (i UpdateCustomerInput) Validate() error