users

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextGetUserID

func ContextGetUserID(r *http.Request) *string

func ContextSetUserID

func ContextSetUserID(r *http.Request, uid *string) *http.Request

func ValidateUserPreferences

func ValidateUserPreferences(v *validator.Validator, pref *UsersPreferences)

Types

type Service

type Service struct {
	Models      UsersPreferencesModel
	Logger      *slog.Logger
	FirebaseApp *firebase.App
}

func NewService

func NewService(logger *slog.Logger, db *sql.DB, firebaseApp *firebase.App) *Service

func (*Service) DeleteUsersPreferencesHandler

func (as *Service) DeleteUsersPreferencesHandler(w http.ResponseWriter, r *http.Request)

func (*Service) GetUsersPreferencesHandler

func (us *Service) GetUsersPreferencesHandler(w http.ResponseWriter, r *http.Request)

func (*Service) UpdateUsersPreferencesHandler

func (us *Service) UpdateUsersPreferencesHandler(w http.ResponseWriter, r *http.Request)

type UsersPreferences

type UsersPreferences struct {
	UID                  string    `json:"uid"`
	ShowScores           bool      `json:"showScores"`
	FavoriteTeams        []int64   `json:"favoriteTeams"`
	FavoriteCompetitions []int64   `json:"favoriteCompetitions"`
	Timezone             string    `json:"timezone"`
	CreatedAt            time.Time `json:"createdAt"`
	UpdatedAt            time.Time `json:"updatedAt"`
	Version              int       `json:"version"`
}

type UsersPreferencesModel

type UsersPreferencesModel struct {
	DB *sql.DB
}

func (UsersPreferencesModel) DeleteUsersPreferencesByUID

func (m UsersPreferencesModel) DeleteUsersPreferencesByUID(uid string) error

func (UsersPreferencesModel) GetUsersPreferencesByUID

func (m UsersPreferencesModel) GetUsersPreferencesByUID(uid string) (*UsersPreferences, error)

func (UsersPreferencesModel) InsertUsersPreferences

func (m UsersPreferencesModel) InsertUsersPreferences(userPreferences *UsersPreferences) error

func (UsersPreferencesModel) UpdateUsersPreferences

func (m UsersPreferencesModel) UpdateUsersPreferences(userPreferences *UsersPreferences) error

Jump to

Keyboard shortcuts

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