Documentation
¶
Overview ¶
Package anny integrates the Anny room-booking system (anny.eu): it fetches the bookings from the Anny API, stores them, and answers queries about them and about the personalization configuration that decides which bookings are "ours". It is deliberately narrow: it depends only on a small DB interface (satisfied by *db.DB), a Reporter for progress output, and a static Config injected by the caller (so viper stays in plexams). The room-capacity views that consume Anny bookings (e.g. booked seats per slot) live in the plexams package; they call this service for the raw bookings and the configuration.
Index ¶
- func IsApprovedStatus(status string) bool
- func MatchesAnyPersonalization(name string, names []string) bool
- type Config
- type DB
- type Reporter
- type Service
- func (s *Service) AllBookings(ctx context.Context) ([]*model.AnnyBooking, error)
- func (s *Service) Bookings(ctx context.Context, room *string) ([]*model.AnnyBooking, error)
- func (s *Service) Config(ctx context.Context) (*model.AnnyConfig, error)
- func (s *Service) Fetch(ctx context.Context, reporter Reporter) error
- func (s *Service) PersonalizationNames(ctx context.Context) []string
- func (s *Service) RoomNames(ctx context.Context) (map[string]struct{}, error)
- func (s *Service) SetPersonalizationNames(ctx context.Context, names []string) (*model.AnnyConfig, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsApprovedStatus ¶
IsApprovedStatus reports whether an Anny booking status counts as approved.
func MatchesAnyPersonalization ¶
MatchesAnyPersonalization reports whether name equals (case-insensitively) any of the configured names. An empty list means "keep everything".
Types ¶
type Config ¶
type Config struct {
// Token is the Anny API bearer token (anny.token).
Token string
// URL is the bookings endpoint (anny.url); a default is used when empty.
URL string
// SeedPersonalizationNames is the config-file fallback used as the personalization
// configuration when the DB holds none yet.
SeedPersonalizationNames []string
}
Config holds the static configuration (from the config file) the service needs.
type DB ¶
type DB interface {
SaveAnnyBookings(ctx context.Context, bookings []*model.AnnyBooking) error
GetAnnyConfig(ctx context.Context) (*model.AnnyConfig, error)
SetAnnyConfig(ctx context.Context, cfg *model.AnnyConfig) error
AnnyBookings(ctx context.Context, room *string) ([]*model.AnnyBooking, error)
AllAnnyBookings(ctx context.Context) ([]*model.AnnyBooking, error)
Rooms(ctx context.Context) ([]*model.Room, error)
AddSyncLogEntry(ctx context.Context, entry *model.SyncLogEntry) error
}
DB is the persistence the anny service needs; *db.DB satisfies it.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the Anny integration.
func New ¶
New builds an Anny service. db may be nil when no database is configured; the methods that need it guard against that.
func (*Service) AllBookings ¶
AllBookings returns all stored Anny bookings, each flagged with Mine.
func (*Service) Bookings ¶
Bookings returns the stored Anny bookings for a room (nil = all rooms), each flagged with Mine when its personalization name is one of ours.
func (*Service) Config ¶
Config returns the Anny settings from the DB, seeded from the config file (anny.personalization_name) when nothing is stored yet.
func (*Service) Fetch ¶
Fetch fetches the bookings from the Anny API and stores them in the database. All bookings (all rooms, all people) are kept; "ours" is flagged via the personalization names at query time, not filtered away here.
func (*Service) PersonalizationNames ¶
PersonalizationNames returns the configured personalization names (DB, else config-file seed).
func (*Service) RoomNames ¶
RoomNames returns the normalized names of the rooms marked as Anny rooms in the global rooms master data (RequestWith == ANNY).
func (*Service) SetPersonalizationNames ¶
func (s *Service) SetPersonalizationNames(ctx context.Context, names []string) (*model.AnnyConfig, error)
SetPersonalizationNames stores the personalization names used to flag our bookings.