dcbot/internal/domain/monitor.go
Dawid Wysokiński e110807619
All checks were successful
continuous-integration/drone/push Build is passing
refactor: group & monitor refactor (#107)
Reviewed-on: #107
2023-06-18 06:47:51 +00:00

69 lines
1.3 KiB
Go

package domain
import (
"fmt"
"time"
)
type Monitor struct {
ID string
TribeID int64
GroupID string
CreatedAt time.Time
}
type MonitorWithTribe struct {
Monitor
Tribe TribeMeta
}
type MonitorAlreadyExistsError struct {
TribeID int64
GroupID string
}
func (e MonitorAlreadyExistsError) Error() string {
return fmt.Sprintf("monitor (groupID=%s,tribeID=%d) already exists", e.GroupID, e.TribeID)
}
func (e MonitorAlreadyExistsError) UserError() string {
return e.Error()
}
func (e MonitorAlreadyExistsError) Code() ErrorCode {
return ErrorCodeAlreadyExists
}
type MonitorLimitReachedError struct {
Current int // current number of groups
Limit int // maximum number of groups
}
func (e MonitorLimitReachedError) Error() string {
return fmt.Sprintf("monitor limit has been reached (%d/%d)", e.Current, e.Limit)
}
func (e MonitorLimitReachedError) UserError() string {
return e.Error()
}
func (e MonitorLimitReachedError) Code() ErrorCode {
return ErrorCodeValidationError
}
type MonitorNotFoundError struct {
ID string
}
func (e MonitorNotFoundError) Error() string {
return fmt.Sprintf("monitor (id=%s) not found", e.ID)
}
func (e MonitorNotFoundError) UserError() string {
return e.Error()
}
func (e MonitorNotFoundError) Code() ErrorCode {
return ErrorCodeEntityNotFound
}