plan

package
v0.8.9 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("plan not found")
	ErrInvalidUUID   = errors.New("invalid syntax of uuid")
	ErrInvalidName   = errors.New("plan name is invalid")
	ErrInvalidDetail = errors.New("invalid plan detail")
)

Functions

This section is empty.

Types

type FeatureService

type FeatureService interface {
	Create(ctx context.Context, f feature.Feature) (feature.Feature, error)
	GetByID(ctx context.Context, id string) (feature.Feature, error)
	Update(ctx context.Context, f feature.Feature) (feature.Feature, error)
	AddPlan(ctx context.Context, planID string, f feature.Feature) error

	CreatePrice(ctx context.Context, price feature.Price) (feature.Price, error)
	UpdatePrice(ctx context.Context, price feature.Price) (feature.Price, error)
	GetPriceByID(ctx context.Context, id string) (feature.Price, error)
	GetPriceByFeatureID(ctx context.Context, id string) ([]feature.Price, error)

	List(ctx context.Context, flt feature.Filter) ([]feature.Feature, error)
}

type File

type File struct {
	Plans    []Plan            `json:"plans" yaml:"plans"`
	Features []feature.Feature `json:"features" yaml:"features"`
}

type Filter

type Filter struct{}

type Plan

type Plan struct {
	ID string `json:"id" yaml:"id"`

	Name        string            `json:"name" yaml:"name"`   // a machine friendly name for the feature
	Title       string            `json:"title" yaml:"title"` // a human friendly title
	Description string            `json:"description" yaml:"description"`
	Metadata    metadata.Metadata `json:"metadata" yaml:"metadata"`

	// Interval is the interval at which the plan is billed
	// e.g. day, week, month, year
	Interval string `json:"interval" yaml:"interval"`

	// Features for the plan, return only, should not be set when creating a plan
	Features []feature.Feature `json:"features" yaml:"features"`

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

Plan is a collection of features it is a logical grouping of features and doesn't have a corresponding billing engine entity

type Repository

type Repository interface {
	GetByID(ctx context.Context, id string) (Plan, error)
	GetByName(ctx context.Context, name string) (Plan, error)
	Create(ctx context.Context, plan Plan) (Plan, error)
	UpdateByName(ctx context.Context, plan Plan) (Plan, error)
	List(ctx context.Context, filter Filter) ([]Plan, error)
}

type Service

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

func NewService

func NewService(stripeClient *client.API, planRepository Repository, featureService FeatureService) *Service

func (Service) Create

func (s Service) Create(ctx context.Context, p Plan) (Plan, error)

func (Service) GetByID

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

func (Service) List

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

func (Service) UpsertPlans

func (s Service) UpsertPlans(ctx context.Context, planFile File) error

Jump to

Keyboard shortcuts

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