Documentation
¶
Index ¶
- Constants
- Variables
- func GetEmailFromContext(ctx context.Context) (string, bool)
- func SetContextWithEmail(ctx context.Context, email string) context.Context
- type ActivityService
- type Filter
- type PagedUsers
- type Repository
- type Service
- func (s Service) Create(ctx context.Context, user User) (User, error)
- func (s Service) CreateMetadataKey(ctx context.Context, key UserMetadataKey) (UserMetadataKey, error)
- func (s Service) FetchCurrentUser(ctx context.Context) (User, error)
- func (s Service) Get(ctx context.Context, idOrEmail string) (User, error)
- func (s Service) GetByEmail(ctx context.Context, email string) (User, error)
- func (s Service) GetByID(ctx context.Context, id string) (User, error)
- func (s Service) GetByIDs(ctx context.Context, userIDs []string) ([]User, error)
- func (s Service) List(ctx context.Context, flt Filter) (PagedUsers, error)
- func (s Service) UpdateByEmail(ctx context.Context, toUpdate User) (User, error)
- func (s Service) UpdateByID(ctx context.Context, toUpdate User) (User, error)
- type User
- type UserLogData
- type UserMetadataKey
- type UserMetadataKeyLogData
Constants ¶
View Source
const ( AuditKeyUserCreate = "user.create" AuditKeyUserUpdate = "user.update" )
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") ErrLogActivity = errors.New("error while logging activity") )
Functions ¶
Types ¶
type ActivityService ¶ added in v0.6.15
type PagedUsers ¶
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(logger log.Logger, repository Repository, activityService ActivityService) *Service
func (Service) CreateMetadataKey ¶
func (s Service) CreateMetadataKey(ctx context.Context, key UserMetadataKey) (UserMetadataKey, error)
func (Service) FetchCurrentUser ¶
func (Service) GetByEmail ¶
func (Service) UpdateByEmail ¶
type User ¶
type User struct {
ID string
Name string
Email string
Metadata metadata.Metadata
CreatedAt time.Time
UpdatedAt time.Time
}
func (User) ToUserLogData ¶ added in v0.6.15
func (user User) ToUserLogData() UserLogData
type UserLogData ¶ added in v0.6.15
type UserMetadataKey ¶
type UserMetadataKey struct {
Key string
Description string
CreatedAt time.Time
UpdatedAt time.Time
}
func (UserMetadataKey) ToUserMetadataKeyLogData ¶ added in v0.6.15
func (userMetadataKey UserMetadataKey) ToUserMetadataKeyLogData() UserMetadataKeyLogData
type UserMetadataKeyLogData ¶ added in v0.6.15
Click to show internal directories.
Click to hide internal directories.