customer

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateAddress

func ValidateAddress(c *Customer) error

ValidateAddress validates all address fields

func ValidateAddressCountry

func ValidateAddressCountry(country string) bool

ValidateAddressCountry validates the country code format

func ValidateAddressPostalCode

func ValidateAddressPostalCode(postalCode string, country string) bool

ValidateAddressPostalCode validates the postal code format

Types

type Customer

type Customer struct {
	// ID is the unique identifier for the customer
	ID string `db:"id" json:"id"`

	// ExternalID is the external identifier for the customer
	ExternalID string `db:"external_id" json:"external_id"`

	// Name is the name of the customer
	Name string `db:"name" json:"name"`

	// Email is the email of the customer
	Email string `db:"email" json:"email"`

	// AddressLine1 is the first line of the customer's address
	AddressLine1 string `db:"address_line1" json:"address_line1"`

	// AddressLine2 is the second line of the customer's address
	AddressLine2 string `db:"address_line2" json:"address_line2"`

	// AddressCity is the city of the customer's address
	AddressCity string `db:"address_city" json:"address_city"`

	// AddressState is the state of the customer's address
	AddressState string `db:"address_state" json:"address_state"`

	// AddressPostalCode is the postal code of the customer's address
	AddressPostalCode string `db:"address_postal_code" json:"address_postal_code"`

	// AddressCountry is the country of the customer's address (ISO 3166-1 alpha-2)
	AddressCountry string `db:"address_country" json:"address_country"`

	// Metadata
	Metadata map[string]string `db:"metadata" json:"metadata"`

	// EnvironmentID is the environment identifier for the customer
	EnvironmentID string `db:"environment_id" json:"environment_id"`

	types.BaseModel
}

Customer represents a customer in the system

func FromEnt

func FromEnt(c *ent.Customer) *Customer

FromEnt converts an ent customer to a domain customer

func FromEntList

func FromEntList(customers []*ent.Customer) []*Customer

FromEntList converts a list of ent customers to domain customers

type Repository

type Repository interface {
	Create(ctx context.Context, customer *Customer) error
	Get(ctx context.Context, id string) (*Customer, error)
	List(ctx context.Context, filter *types.CustomerFilter) ([]*Customer, error)
	Count(ctx context.Context, filter *types.CustomerFilter) (int, error)
	ListAll(ctx context.Context, filter *types.CustomerFilter) ([]*Customer, error)
	Update(ctx context.Context, customer *Customer) error
	Delete(ctx context.Context, customer *Customer) error
	GetByLookupKey(ctx context.Context, lookupKey string) (*Customer, error)
}

Repository defines the interface for customer data access

Jump to

Keyboard shortcuts

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