user

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRunescapeNameTracked = errors.New("runescape name tracked")
View Source
var ErrUserGeneric = errors.New("an service_error occurred while performing the user operation")
View Source
var ErrUserNotFound = errors.New("user not found")
View Source
var ErrUserValidation = errors.New("user is invalid")

Functions

This section is empty.

Types

type AccountType

type AccountType string
const (
	AccountTypeNormal          AccountType = "NORMAL"
	AccountTypeIronman         AccountType = "IRONMAN"
	AccountTypeHardcoreIronman AccountType = "HARDCORE_IRONMAN"
	AccountTypeUltimateIronman AccountType = "ULTIMATE_IRONMAN"
	AccountTypeGroupIronman    AccountType = "GROUP_IRONMAN"
)

func AccountTypeFromValue

func AccountTypeFromValue(value string) AccountType

type TrackingStatus

type TrackingStatus string
const (
	TrackingStatusEnabled  TrackingStatus = "ENABLED"
	TrackingStatusDisabled TrackingStatus = "DISABLED"
)

func TrackingStatusFromValue

func TrackingStatusFromValue(value string) TrackingStatus

type User

type User struct {
	Id             string         `json:"id"`
	RunescapeName  string         `json:"runescapeName"`
	TrackingStatus TrackingStatus `json:"trackingStatus"`
	AccountType    AccountType    `json:"accountType"`
}

func (User) FromAPI

func (User) FromAPI(user api.User) User

FromAPI creates a domain User from an API User (call as User{}.FromAPI(...))

func (User) FromCreateRequest

func (User) FromCreateRequest(request api.CreateUserRequest) User

FromCreateRequest creates a domain User from a CreateUserRequest (call as User{}.FromCreateRequest(...))

func (User) FromData

func (User) FromData(userData UserData) User

FromData creates a domain User from data layer UserData (call as User{}.FromData(...))

func (User) FromUpdateRequest

func (User) FromUpdateRequest(request api.UpdateUserRequest) User

FromUpdateRequest creates a domain User from an UpdateUserRequest (call as User{}.FromUpdateRequest(...))

func (User) ManyFromData

func (User) ManyFromData(userData []UserData) []User

ManyFromData converts a slice of UserData to domain Users (call as User{}.ManyFromData(...))

func (User) ManyToAPI

func (User) ManyToAPI(users []User) []api.User

ManyToAPI converts a slice of domain Users to API Users (call as User{}.ManyToAPI(...))

func (User) ToAPI

func (u User) ToAPI() api.User

ToAPI converts the domain User to an API User

func (User) ToData

func (u User) ToData() UserData

ToData converts the domain User to a data layer UserData

type UserData

type UserData struct {
	Id             string `bson:"_id"`
	RunescapeName  string `bson:"runescapeName"`
	TrackingStatus string `bson:"trackingStatus"`
	AccountType    string `bson:"accountType"`
}

type UserRepository

type UserRepository interface {
	GetUserById(ctx context.Context, id string) (UserData, error)
	GetUserByRunescapeName(ctx context.Context, runescapeName string) (UserData, error)
	GetAllUsers(ctx context.Context) ([]UserData, error)
	GetUsersWithTrackingEnabled(ctx context.Context) ([]UserData, error)
	CreateUser(ctx context.Context, user UserData) (UserData, error)
	UpdateUser(ctx context.Context, user UserData) (UserData, error)
}

func NewUserRepository

func NewUserRepository(userCollection *mongo.Collection, mon *monitor.Monitor) UserRepository

type UserService

type UserService interface {
	GetUserById(ctx context.Context, id string) (User, error)
	GetAllUsers(ctx context.Context) ([]User, error)
	CreateUser(ctx context.Context, user User) (User, error)
	UpdateUser(ctx context.Context, user User) (User, error)
}

func NewUserService

func NewUserService(mon *monitor.Monitor, repository UserRepository, validator UserValidator) UserService

type UserValidator

type UserValidator interface {
	ValidateUser(user User) error
}

func NewUserValidator

func NewUserValidator() UserValidator

Jump to

Keyboard shortcuts

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