Documentation ¶
Index ¶
- Constants
- Variables
- func Router(service Service, authService auth.Service) func(chi.Router)
- type FindFilters
- type FindParams
- type Invitation
- type InviteResponse
- type NewInvitation
- type Service
- type SortOrder
- type SqlStore
- func (s *SqlStore) Create(ctx context.Context, newInvitation *NewInvitation) (*Invitation, error)
- func (s *SqlStore) Delete(ctx context.Context, id string) error
- func (s *SqlStore) Find(ctx context.Context, params *FindParams) ([]Invitation, int, error)
- func (s *SqlStore) FindByID(ctx context.Context, id string) (*Invitation, error)
- func (s *SqlStore) RunMigrations(ctx context.Context) error
- func (s *SqlStore) Update(ctx context.Context, invitation *Invitation) (*Invitation, error)
- type Storer
Constants ¶
const ( OrderAsc = SortOrder("ASC") OrderDesc = SortOrder("DESC") )
Possible values for SortOrder.
Variables ¶
var ErrInvalidInvitationToken = xerror.BadInputError{Err: fmt.Errorf("invalid invitation token")}
var ErrInvitationLimit = fmt.Errorf("invitation limit")
var ErrInvitationTokenAlreadyUsed = xerror.BadInputError{Err: fmt.Errorf("invitation token already used")}
var ErrNoInvitationYet = fmt.Errorf("no invitation yet")
Functions ¶
Types ¶
type FindFilters ¶
type FindFilters struct { ID *string Token *string CreatedAt *time.Time CreatedBy *string UsedBy *string }
FindFilters defines the possible filters for the find method.
type FindParams ¶
type FindParams struct { Offset int64 Limit int64 Sort string Order SortOrder Filters *FindFilters }
FindParams defines parameters used by the Find method.
type Invitation ¶
type Invitation struct { ID string `json:"id" db:"id"` Token string `json:"token" db:"token"` CreatedAt time.Time `json:"createdAt" db:"created_at"` CreatedBy string `json:"createdBy" db:"created_by"` UsedBy string `json:"usedBy" db:"used_by"` }
Invitation is an invitation model.
func InvitationFromNewInvitation ¶
func InvitationFromNewInvitation(newInvitation *NewInvitation, id string) *Invitation
InvitationFromNewInvitation converts a NewInvitation to an Invitation with a given id.
type InviteResponse ¶
type InviteResponse struct {
Token string `json:"token"`
}
type NewInvitation ¶
type NewInvitation struct { Token string `json:"token"` CreatedAt time.Time `json:"createdAt"` CreatedBy string `json:"createdBy"` }
NewInvitation is the model used to create new invitations by the storer.
type Service ¶
type Service interface { Storer Invite(ctx context.Context) (token string, err error) UseInvite(ctx context.Context, token string, user *user.NewUser) error }
Service defines an invitation services, that can handle crud operations on the Invitation model -go:generate go run github.com/petergtz/pegomock/pegomock generate eintopf.info/service/invitation Service --output=../../internal/mock/invitation_service.go --package=mock --mock-name=InvitationService
func NewAuthorizer ¶
type SqlStore ¶
type SqlStore struct {
// contains filtered or unexported fields
}
func NewSqlStore ¶
NewSqlStore returns a new sql db invitation store.
func (*SqlStore) Create ¶
func (s *SqlStore) Create(ctx context.Context, newInvitation *NewInvitation) (*Invitation, error)
func (*SqlStore) Find ¶
func (s *SqlStore) Find(ctx context.Context, params *FindParams) ([]Invitation, int, error)
func (*SqlStore) Update ¶
func (s *SqlStore) Update(ctx context.Context, invitation *Invitation) (*Invitation, error)
type Storer ¶
type Storer interface { Create(ctx context.Context, invitation *NewInvitation) (*Invitation, error) Update(ctx context.Context, invitation *Invitation) (*Invitation, error) Delete(ctx context.Context, id string) error FindByID(ctx context.Context, id string) (*Invitation, error) Find(ctx context.Context, params *FindParams) ([]Invitation, int, error) }
Storer defines an interface for crud operations on the invitation model.