customer

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("customer not found")
	ErrInvalidUUID   = errors.New("invalid syntax of uuid")
	ErrInvalidID     = errors.New("billing customer id is invalid")
	ErrConflict      = errors.New("customer already exist")
	ErrInvalidDetail = errors.New("invalid billing customer detail")
	ErrDisabled      = errors.New("billing customer is disabled")
)

Functions

This section is empty.

Types

type Address

type Address struct {
	City       string `json:"city"`
	Country    string `json:"country"`
	Line1      string `json:"line1"`
	Line2      string `json:"line2"`
	PostalCode string `json:"postal_code"`
	State      string `json:"state"`
}

type Customer

type Customer struct {
	ID         string
	OrgID      string
	ProviderID string // identifier set by the billing engine provider

	Name    string
	Email   string
	Phone   string
	Address Address
	// Currency Three-letter ISO 4217 currency code in lower case
	Currency string `default:"usd"`
	Metadata metadata.Metadata

	State     string
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time
}

type Filter

type Filter struct {
	OrgID string
}

type OrgService

type OrgService interface {
	Get(ctx context.Context, id string) (organization.Organization, error)
}

type Provider

type Provider string
const (
	ProviderStripe Provider = "stripe"
)

type Repository

type Repository interface {
	GetByID(ctx context.Context, id string) (Customer, error)
	List(ctx context.Context, filter Filter) ([]Customer, error)
	Create(ctx context.Context, customer Customer) (Customer, error)
	Delete(ctx context.Context, id string) error
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(stripeClient *client.API, repository Repository, orgService OrgService) *Service

func (Service) Create

func (s Service) Create(ctx context.Context, customer Customer) (Customer, error)

func (Service) Delete

func (s Service) Delete(ctx context.Context, id string) error

func (Service) GetByID

func (s Service) GetByID(ctx context.Context, id string) (Customer, error)

func (Service) GetByOrgID

func (s Service) GetByOrgID(ctx context.Context, orgID string) (Customer, error)

func (Service) List

func (s Service) List(ctx context.Context, filter Filter) ([]Customer, error)

Jump to

Keyboard shortcuts

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