Documentation
¶
Overview ¶
Package core provides the core domain modules and service interfaces for the Apollo library.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidEmailAddress = errors.New("invalid e-mail address") ErrEmailAddressEmpty = errors.New("e-mail address is empty") )
View Source
var ( ErrUserDoesNotExist = errors.New("user does not exist") ErrOrganisationDoesNotExist = errors.New("organisation does not exist") ErrNoActiveOrganisation = errors.New("user has not chosen an organisation") ErrNotFound = errors.New("not found") ErrUnauthenticated = errors.New("authentication required") ErrForbidden = errors.New("user is not authorized") ErrConflict = errors.New("conflict") )
Functions ¶
This section is empty.
Types ¶
type AddressService ¶
type AddressService interface {
// Creates an Address from an Address struct, the ID field of the struct gets ignored here
CreateAddress(ctx context.Context, address Address) (*Address, error)
GetAddress(ctx context.Context, addressID AddressID) (*Address, error)
DeleteAddress(ctx context.Context, addressID AddressID) error
UpdateAddress(ctx context.Context, addressID AddressID, update AddressUpdateData) (*Address, error)
ListAddresses(ctx context.Context) ([]Address, error)
}
type AddressUpdateData ¶
type EmailAddress ¶
type EmailAddress struct {
// contains filtered or unexported fields
}
func ParseEmailAddress ¶
func ParseEmailAddress(address string) (*EmailAddress, error)
ParseEmailAddress parses an e-mail address from any string. This uses RFC-5322 to determine valid e-mail addresses, e.g. "Biggie Smalls <notorious@example.com>"
func (*EmailAddress) String ¶
func (email *EmailAddress) String() string
func (*EmailAddress) UnmarshalText ¶
func (email *EmailAddress) UnmarshalText(text []byte) error
type EmailService ¶
type EmailService interface {
// SendEmail will build and send a basic e-mail message containing both a HTML template version
// (optional) as well as a plaintext alternative (required).
SendEmail(
ctx context.Context,
address EmailAddress,
subject string,
template *templ.Component,
plaintextMessage string,
) error
// SendNotification will send a specific plain-text notification to the configured notification
// address.
SendNotification(
ctx context.Context,
subject string,
message string,
args ...any,
) error
// SendRawMessage will send a raw gomail message using the existing configuration.
SendRawMessage(ctx context.Context, message *gomail.Message) error
}
type Organisation ¶
type Organisation struct {
ID OrganisationID
Name string
ParentID *OrganisationID
}
func ParseOrganisation ¶
func ParseOrganisation(id int32, name string, parentID *int32) (*Organisation, error)
type OrganisationID ¶
type OrganisationID = ID
type OrganisationService ¶
type OrganisationService interface {
// Create a new organisation with the specified data.
CreateOrganisation(ctx context.Context, name string, parentID *OrganisationID) (*Organisation, error)
// Retrieve the organisation with the specified id or ErrOrganisationDoesNotExist if no such organisation exists.
GetOrganisation(ctx context.Context, id OrganisationID) (*Organisation, error)
// Update an existing organisation and return the result.
UpdateOrganisation(ctx context.Context, id OrganisationID, name string) (*Organisation, error)
// Retrieve all existing organisations.
ListOrganisations(ctx context.Context) ([]Organisation, error)
// Retrieve the amount of existing organisations.
GetAmountOfOrganisations(ctx context.Context) (uint64, error)
// Delete the organisation with the specified id or ErrOrganisationDoesNotExist if no such organisation exists.
DeleteOrganisation(ctx context.Context, id OrganisationID) error
// List the organisations a user belongs to or ErrUserDoesNotExist if no such user exists
ListOrganisationsForUser(ctx context.Context, id UserID) ([]Organisation, error)
// List the users that belong to an organisation or ErrOrganisationDoesNotExist if no such organisation exists
ListUsersInOrganisation(ctx context.Context, id OrganisationID) ([]User, error)
// Get user for a specific organisation, throws ErrNotFound if the user is not a member
GetMember(ctx context.Context, UserID UserID, OrgID OrganisationID) (*User, error)
// Return a User for the given organisation and email or ErrNotFound if no such member exisits
GetMemberByEmail(ctx context.Context, OrgID OrganisationID, email EmailAddress) (*User, error)
// Add user to an existing organisation
AddUser(ctx context.Context, UserID UserID, OrgID OrganisationID) error
// Remove user from an organisation
RemoveUser(ctx context.Context, UserID UserID, OrgID OrganisationID) error
}
type UserService ¶
type UserService interface {
// Create a new user with the specified data.
CreateUser(ctx context.Context, name string, email EmailAddress, lang string) (*User, error)
// Retrieve the user with the specified id or ErrUserDoesNotExist if no such user exists.
GetUser(ctx context.Context, id UserID) (*User, error)
// Retrieve all existing users.
ListUsers(ctx context.Context) ([]User, error)
// Retrieve the amount of existing users.
GetAmountOfUsers(ctx context.Context) (uint64, error)
// Delete the user with the specified id or ErrUserDoesNotExist if no such user exists.
DeleteUser(ctx context.Context, id UserID) error
// Update the user's admin state to the specified state.
UpdateUserAdmin(ctx context.Context, id UserID, admin bool) error
// Update the user with the specified data.
UpdateUser(ctx context.Context, id UserID, data UserUpdate) (*User, error)
}
type UserUpdate ¶
Click to show internal directories.
Click to hide internal directories.