user

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotExist         = errors.New("user doesn't exist")
	ErrInvalidID        = errors.New("user id is invalid")
	ErrInvalidEmail     = errors.New("user email is invalid")
	ErrConflict         = errors.New("user already exist")
	ErrEmptyKey         = errors.New("empty key")
	ErrKeyAlreadyExists = errors.New("key already exist")
	ErrKeyDoesNotExists = errors.New("key does not exist")
	ErrMissingEmail     = errors.New("user email is missing")
	ErrInvalidUUID      = errors.New("invalid syntax of uuid")
)

Functions

func GetEmailFromContext

func GetEmailFromContext(ctx context.Context) (string, bool)

func SetContextWithEmail

func SetContextWithEmail(ctx context.Context, email string) context.Context

Types

type Filter

type Filter struct {
	Limit   int32
	Page    int32
	Keyword string
}

type PagedUsers

type PagedUsers struct {
	Count int32
	Users []User
}

type Repository

type Repository interface {
	GetByID(ctx context.Context, id string) (User, error)
	GetByEmail(ctx context.Context, email string) (User, error)
	GetByIDs(ctx context.Context, userIds []string) ([]User, error)
	Create(ctx context.Context, user User) (User, error)
	List(ctx context.Context, flt Filter) ([]User, error)
	UpdateByID(ctx context.Context, toUpdate User) (User, error)
	UpdateByEmail(ctx context.Context, toUpdate User) (User, error)
	CreateMetadataKey(ctx context.Context, key UserMetadataKey) (UserMetadataKey, error)
}

type Service

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

func NewService

func NewService(repository Repository) *Service

func (Service) Create

func (s Service) Create(ctx context.Context, user User) (User, error)

func (Service) CreateMetadataKey

func (s Service) CreateMetadataKey(ctx context.Context, key UserMetadataKey) (UserMetadataKey, error)

func (Service) FetchCurrentUser

func (s Service) FetchCurrentUser(ctx context.Context) (User, error)

func (Service) GetByEmail

func (s Service) GetByEmail(ctx context.Context, email string) (User, error)

func (Service) GetByID

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

func (Service) GetByIDs

func (s Service) GetByIDs(ctx context.Context, userIDs []string) ([]User, error)

func (Service) List

func (s Service) List(ctx context.Context, flt Filter) (PagedUsers, error)

func (Service) UpdateByEmail

func (s Service) UpdateByEmail(ctx context.Context, toUpdate User) (User, error)

func (Service) UpdateByID

func (s Service) UpdateByID(ctx context.Context, toUpdate User) (User, error)

type User

type User struct {
	ID        string
	Name      string
	Email     string
	Metadata  metadata.Metadata
	CreatedAt time.Time
	UpdatedAt time.Time
}

type UserMetadataKey

type UserMetadataKey struct {
	Key         string
	Description string
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

Jump to

Keyboard shortcuts

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