invitation

package
v0.0.2-rc-ci Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrderAsc  = SortOrder("ASC")
	OrderDesc = SortOrder("DESC")
)

Possible values for SortOrder.

Variables

View Source
var ErrInvalidInvitationToken = xerror.BadInputError{Err: fmt.Errorf("invalid invitation token")}
View Source
var ErrInvitationLimit = fmt.Errorf("invitation limit")
View Source
var ErrInvitationTokenAlreadyUsed = xerror.BadInputError{Err: fmt.Errorf("invitation token already used")}
View Source
var ErrNoInvitationYet = fmt.Errorf("no invitation yet")

Functions

func Router

func Router(service Service, authService auth.Service) func(chi.Router)

Router returns a new http router that handles requests for a given Service.

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

func NewAuthorizer(service Service) Service

func NewService

func NewService(store Storer, userService user.Service) Service

type SortOrder

type SortOrder string

SortOrder defines the order of sorting.

type SqlStore

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

func NewSqlStore

func NewSqlStore(db *sqlx.DB) *SqlStore

NewSqlStore returns a new sql db invitation store.

func (*SqlStore) Create

func (s *SqlStore) Create(ctx context.Context, newInvitation *NewInvitation) (*Invitation, error)

func (*SqlStore) Delete

func (s *SqlStore) Delete(ctx context.Context, id string) error

func (*SqlStore) Find

func (s *SqlStore) Find(ctx context.Context, params *FindParams) ([]Invitation, int, error)

func (*SqlStore) FindByID

func (s *SqlStore) FindByID(ctx context.Context, id string) (*Invitation, error)

func (*SqlStore) RunMigrations

func (s *SqlStore) RunMigrations(ctx context.Context) 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.

Jump to

Keyboard shortcuts

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