contracts

package
v0.0.0-...-63997f1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AdminRole  = "admin"
	EditorRole = "editor"
	UserRole   = "user"
)

Variables

This section is empty.

Functions

func ValidateRole

func ValidateRole(role string) bool

func ValidateSortRequest

func ValidateSortRequest(sort string) error

Types

type AuthenticatedRequest

type AuthenticatedRequest[T any] struct {
	AccessToken string
	Request     T
}

func NewAuthenticated

func NewAuthenticated[T any](req T, accessToken string) *AuthenticatedRequest[T]

type CreateGenreRequest

type CreateGenreRequest struct {
	Name string `json:"name" validate:"min=3,max=32"`
}

type CreateMovieRequest

type CreateMovieRequest struct {
	Title        string            `json:"title" validate:"min=1,max=100"`
	ReleaseDate  time.Time         `json:"releaseDate" validate:"nonzero"`
	PosterURL    *string           `json:"posterUrl,omitempty"`
	IMDbRating   *float64          `json:"imdbRating,omitempty"`
	IMDbURL      *string           `json:"imdbUrl,omitempty"`
	Metascore    *int              `json:"metascore,omitempty"`
	MetascoreURL *string           `json:"metascoreUrl,omitempty"`
	Description  string            `json:"description"`
	GenreIDs     []int             `json:"genreIds" validate:"nonzero"`
	Cast         []MovieCreditInfo `json:"cast"`
}

type CreateReviewRequest

type CreateReviewRequest struct {
	UserID  int    `json:"-" param:"userId" validate:"nonzero"`
	MovieID int    `json:"movieId" validate:"nonzero"`
	Title   string `json:"title" validate:"max=100"`
	Content string `json:"description" validate:"max=1000"`
	Rating  int    `json:"rating" validate:"min=1,max=10"`
}

type CreateStarRequest

type CreateStarRequest struct {
	FirstName  string     `json:"firstName" validate:"min=1,max=50"`
	MiddleName *string    `json:"middleName,omitempty" validate:"max=50"`
	LastName   string     `json:"lastName" validate:"min=1,max=50"`
	AvatarURL  *string    `json:"avatarUrl,omitempty"`
	BirthDate  time.Time  `json:"birthDate" validate:"nonzero"`
	BirthPlace *string    `json:"birthPlace,omitempty" validate:"max=100"`
	DeathDate  *time.Time `json:"deathDate,omitempty"`
	Bio        *string    `json:"bio,omitempty"`
	IMDbURL    *string    `json:"imdbUrl,omitempty"`
}

type DeleteGenreRequest

type DeleteGenreRequest struct {
	GenreID int `json:"-" param:"genreId" validate:"nonzero"`
}

type DeleteMovieRequest

type DeleteMovieRequest struct {
	MovieID int `json:"-" param:"movieId" validate:"nonzero"`
}

type DeleteReviewRequest

type DeleteReviewRequest struct {
	UserID   int `json:"-" param:"userId" validate:"nonzero"`
	ReviewID int `json:"-" param:"reviewId" validate:"nonzero"`
}

type DeleteStarRequest

type DeleteStarRequest struct {
	StarID int `json:"-" param:"starId" validate:"nonzero"`
}

type DeleteUserRequest

type DeleteUserRequest struct {
	UserID int `json:"-" param:"userId" validate:"nonzero"`
}

type Genre

type Genre struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

type GetGenreRequest

type GetGenreRequest struct {
	GenreID int `json:"-" param:"genreId" validate:"nonzero"`
}

type GetMovieRequest

type GetMovieRequest struct {
	MovieID int `json:"-" param:"movieId" validate:"nonzero"`
}

type GetMoviesRequest

type GetMoviesRequest struct {
	PaginatedRequestOrdered
	SearchTerm *string `json:"-" query:"q"`
}

func (*GetMoviesRequest) ToQueryParams

func (r *GetMoviesRequest) ToQueryParams() map[string]string

type GetReviewRequest

type GetReviewRequest struct {
	ReviewID int `json:"-" param:"reviewId" validate:"nonzero"`
}

type GetReviewsByMovieIDRequest

type GetReviewsByMovieIDRequest struct {
	PaginatedRequestOrdered
	MovieID int `json:"-" param:"movieId" validate:"nonzero"`
}

type GetReviewsByUserIDRequest

type GetReviewsByUserIDRequest struct {
	PaginatedRequestOrdered
	UserID int `json:"-" param:"userId" validate:"nonzero"`
}

type GetStarRequest

type GetStarRequest struct {
	StarID int `json:"" param:"starId" validate:"nonzero"`
}

type GetStarsRequest

type GetStarsRequest struct {
	PaginatedRequestOrdered
}

type GetUserByIDRequest

type GetUserByIDRequest struct {
	UserID int `json:"-" param:"userId" validate:"nonzero"`
}

type GetUserByUsernameRequest

type GetUserByUsernameRequest struct {
	Username string `json:"-" param:"username" validate:"min=3,max=24,nonzero"`
}

type HTTPError

type HTTPError struct {
	Message    string `json:"message"`
	IncidentID string `json:"incident_id,omitempty"`
}

type LoginUserRequest

type LoginUserRequest struct {
	Email    string `json:"email" validate:"email"`
	Password string `json:"password" validate:"password"`
}

type LoginUserResponse

type LoginUserResponse struct {
	User        User   `json:"user"`
	AccessToken string `json:"access_token" nonzero:"true"`
}

type Movie

type Movie struct {
	ID          int        `json:"id"`
	Title       string     `json:"title"`
	PosterURL   *string    `json:"posterUrl,omitempty"`
	ReleaseDate time.Time  `json:"releaseDate"`
	AvgRating   *float64   `json:"avgRating,omitempty"`
	CreatedAt   time.Time  `json:"createdAt"`
	DeletedAt   *time.Time `json:"deletedAt,omitempty"`
}

type MovieCredit

type MovieCredit struct {
	Star     Star    `json:"star"`
	Role     string  `json:"role"`
	HeroName *string `json:"heroName,omitempty"`
	Details  string  `json:"details,omitempty"`
}

type MovieCreditInfo

type MovieCreditInfo struct {
	StarID   int     `json:"starId"`
	Role     string  `json:"role"`
	HeroName *string `json:"heroName,omitempty"`
	Details  string  `json:"details,omitempty"`
	IMDbURL  *string `json:"imdbUrl,omitempty"`
}

type MovieCreditV2

type MovieCreditV2 struct {
	Star     *StarV2 `json:"star"`
	Role     string  `json:"role"`
	HeroName *string `json:"heroName,omitempty"`
	Details  string  `json:"details,omitempty"`
}

type MovieDetails

type MovieDetails struct {
	Movie
	Description  string         `json:"description"`
	IMDbRating   *float64       `json:"imdbRating,omitempty"`
	IMDbURL      *string        `json:"imdbUrl,omitempty"`
	Metascore    *int           `json:"metascore,omitempty"`
	MetascoreURL *string        `json:"metascoreUrl,omitempty"`
	Version      int            `json:"version"`
	Genres       []*Genre       `json:"genres"`
	Cast         []*MovieCredit `json:"cast"`
}

type MovieDetailsV2

type MovieDetailsV2 struct {
	Movie
	Description  string           `json:"description"`
	IMDbRating   *float64         `json:"imdbRating,omitempty"`
	IMDbURL      *string          `json:"imdbUrl,omitempty"`
	Metascore    *int             `json:"metascore,omitempty"`
	MetascoreURL *string          `json:"metascoreUrl,omitempty"`
	Version      int              `json:"version"`
	Genres       []*Genre         `json:"genres"`
	Cast         []*MovieCreditV2 `json:"cast"`
}

type PaginatedRequest

type PaginatedRequest struct {
	Page int `json:"page" query:"page"`
	Size int `json:"size" query:"size"`
}

func (*PaginatedRequest) SetPage

func (req *PaginatedRequest) SetPage(page int)

func (*PaginatedRequest) SetSize

func (req *PaginatedRequest) SetSize(size int)

func (*PaginatedRequest) ToQueryParams

func (req *PaginatedRequest) ToQueryParams() map[string]string

type PaginatedRequestOrdered

type PaginatedRequestOrdered struct {
	PaginatedRequest
	Sort  string `json:"sort" query:"sort"`
	Order string `json:"order" query:"order"`
}

func (*PaginatedRequestOrdered) SetPage

func (req *PaginatedRequestOrdered) SetPage(page int)

func (*PaginatedRequestOrdered) SetSize

func (req *PaginatedRequestOrdered) SetSize(size int)

func (*PaginatedRequestOrdered) ToQueryParams

func (req *PaginatedRequestOrdered) ToQueryParams() map[string]string

type PaginatedResponse

type PaginatedResponse[T any] struct {
	Page  int `json:"page" validate:"min=0"`
	Size  int `json:"size" validate:"min=0"`
	Total int `json:"total"`
	Items []T `json:"items"`
}

func (*PaginatedResponse[T]) GetItems

func (res *PaginatedResponse[T]) GetItems() []T

func (*PaginatedResponse[T]) GetPage

func (res *PaginatedResponse[T]) GetPage() int

func (*PaginatedResponse[T]) GetSize

func (res *PaginatedResponse[T]) GetSize() int

func (*PaginatedResponse[T]) GetTotal

func (res *PaginatedResponse[T]) GetTotal() int

type PaginatedResponseOrdered

type PaginatedResponseOrdered[T any] struct {
	PaginatedResponse[T]
	Sort  string `json:"sort"`
	Order string `json:"order"`
}

func (*PaginatedResponseOrdered[T]) GetItems

func (res *PaginatedResponseOrdered[T]) GetItems() []T

func (*PaginatedResponseOrdered[T]) GetPage

func (res *PaginatedResponseOrdered[T]) GetPage() int

func (*PaginatedResponseOrdered[T]) GetSize

func (res *PaginatedResponseOrdered[T]) GetSize() int

func (*PaginatedResponseOrdered[T]) GetTotal

func (res *PaginatedResponseOrdered[T]) GetTotal() int

type PaginationGetter

type PaginationGetter[T any] interface {
	GetPage() int
	GetSize() int
	GetTotal() int
	GetItems() []T
}

type PaginationSetter

type PaginationSetter interface {
	SetPage(page int)
	SetSize(size int)
}

type RegisterUserRequest

type RegisterUserRequest struct {
	Username string `json:"username" validate:"min=3,max=24"`
	Email    string `json:"email" validate:"email"`
	Password string `json:"password" validate:"password"`
}

type Review

type Review struct {
	ID        int        `json:"id"`
	MovieID   int        `json:"movieId"`
	UserID    int        `json:"userId"`
	Rating    int        `json:"rating"`
	Title     string     `json:"title"`
	Content   string     `json:"description"`
	CreatedAt time.Time  `json:"createdAt"`
	UpdatedAt *time.Time `json:"updatedAt,omitempty"`
	DeletedAt *time.Time `json:"deletedAt,omitempty"`
}

type Star

type Star struct {
	ID         int        `json:"id"`
	FirstName  string     `json:"firstName"`
	MiddleName *string    `json:"middleName,omitempty"`
	LastName   string     `json:"lastName"`
	AvatarURL  *string    `json:"avatarUrl,omitempty"`
	BirthDate  time.Time  `json:"birthDate"`
	BirthPlace *string    `json:"birthPlace,omitempty"`
	DeathDate  *time.Time `json:"deathDate,omitempty"`
	Bio        *string    `json:"bio,omitempty"`
	IMDbURL    *string    `json:"imdbUrl,omitempty"`
	CreatedAt  time.Time  `json:"createdAt"`
	DeletedAt  *time.Time `json:"deletedAt,omitempty"`
}

type StarV2

type StarV2 struct {
	ID         int        `json:"id"`
	FirstName  string     `json:"firstName"`
	MiddleName *string    `json:"middleName,omitempty"`
	LastName   string     `json:"lastName"`
	AvatarURL  *string    `json:"avatarUrl,omitempty"`
	CreatedAt  time.Time  `json:"createdAt"`
	DeletedAt  *time.Time `json:"deletedAt,omitempty"`
}

type UpdateGenreRequest

type UpdateGenreRequest struct {
	GenreID int    `json:"-" param:"genreId" validate:"nonzero"`
	Name    string `json:"name" validate:"min=3,max=32"`
}

type UpdateMovieRequest

type UpdateMovieRequest struct {
	MovieID      int                `json:"-" param:"movieId" validate:"nonzero"`
	Title        *string            `json:"title,omitempty" validate:"max=100"`
	ReleaseDate  *time.Time         `json:"releaseDate,omitempty"`
	PosterURL    *string            `json:"posterUrl,omitempty"`
	IMDbRating   *float64           `json:"imdbRating,omitempty"`
	IMDbURL      *string            `json:"imdbUrl,omitempty"`
	Metascore    *int               `json:"metascore,omitempty"`
	MetascoreURL *string            `json:"metascoreUrl,omitempty"`
	Description  *string            `json:"description,omitempty"`
	Version      int                `json:"version"`
	GenreIDs     []*int             `json:"genreIds,omitempty"`
	Cast         []*MovieCreditInfo `json:"cast,omitempty"`
}

type UpdateReviewRequest

type UpdateReviewRequest struct {
	UserID   int     `json:"-" param:"userId" validate:"nonzero"`
	ReviewID int     `json:"-" param:"reviewId" validate:"nonzero"`
	MovieID  int     `json:"movieId" validate:"nonzero"`
	Title    *string `json:"title,omitempty" validate:"max=100"`
	Content  *string `json:"description,omitempty" validate:"max=1000"`
	Rating   *int    `json:"rating,omitempty" validate:"min=1,max=10"`
}

type UpdateStarRequest

type UpdateStarRequest struct {
	StarID     int        `json:"-" param:"starId" validate:"nonzero"`
	FirstName  *string    `json:"firstName,omitempty" validate:"max=50"`
	MiddleName *string    `json:"middleName,omitempty" validate:"max=50"`
	LastName   *string    `json:"lastName,omitempty" validate:"max=50"`
	AvatarURL  *string    `json:"avatarUrl,omitempty"`
	BirthDate  *time.Time `json:"birthDate,omitempty"`
	BirthPlace *string    `json:"birthPlace,omitempty" validate:"max=100"`
	DeathDate  *time.Time `json:"deathDate,omitempty"`
	Bio        *string    `json:"bio,omitempty"`
	IMDbURL    *string    `json:"imdbUrl,omitempty"`
}

type UpdateUserRequest

type UpdateUserRequest struct {
	UserID    int     `json:"-" param:"userId" validate:"nonzero"`
	Username  *string `json:"username,omitempty" validate:"username"`
	Password  *string `json:"password,omitempty" validate:"password"`
	AvatarURL *string `json:"avatarUrl,omitempty"`
	Bio       *string `json:"bio,omitempty"`
}

type UpdateUserRoleRequest

type UpdateUserRoleRequest struct {
	UserID int    `json:"-" param:"userId" validate:"nonzero"`
	Role   string `json:"-" param:"role" validate:"nonzero,role"`
}

type User

type User struct {
	ID        int        `json:"id"`
	Username  string     `json:"username"`
	Email     string     `json:"email"`
	AvatarURL string     `json:"avatarUrl"`
	Bio       *string    `json:"bio,omitempty"`
	Role      string     `json:"role"`
	CreatedAt time.Time  `json:"createdAt"`
	DeletedAt *time.Time `json:"deletedAt,omitempty"`
}

type UserWithPassword

type UserWithPassword struct {
	*User
	PasswordHash string
}

Jump to

Keyboard shortcuts

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