mirror of
https://gitlab.com/foxixus/neomovies-api.git
synced 2025-10-28 09:58:50 +05:00
feat(api): add unified models, mappers, and prefixed routes (movie/tv/search)
This commit is contained in:
88
pkg/models/unified.go
Normal file
88
pkg/models/unified.go
Normal file
@@ -0,0 +1,88 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// Unified entities and response envelopes for prefixed-source API
|
||||
|
||||
type UnifiedGenre struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type UnifiedCastMember struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Character string `json:"character,omitempty"`
|
||||
}
|
||||
|
||||
type UnifiedExternalIDs struct {
|
||||
KP *int `json:"kp"`
|
||||
TMDB *int `json:"tmdb"`
|
||||
IMDb string `json:"imdb"`
|
||||
}
|
||||
|
||||
type UnifiedContent struct {
|
||||
ID string `json:"id"`
|
||||
SourceID string `json:"sourceId"`
|
||||
Title string `json:"title"`
|
||||
OriginalTitle string `json:"originalTitle"`
|
||||
Description string `json:"description"`
|
||||
ReleaseDate string `json:"releaseDate"`
|
||||
EndDate *string `json:"endDate"`
|
||||
Type string `json:"type"` // movie | tv
|
||||
Genres []UnifiedGenre `json:"genres"`
|
||||
Rating float64 `json:"rating"`
|
||||
PosterURL string `json:"posterUrl"`
|
||||
BackdropURL string `json:"backdropUrl"`
|
||||
Director string `json:"director"`
|
||||
Cast []UnifiedCastMember `json:"cast"`
|
||||
Duration int `json:"duration"`
|
||||
Country string `json:"country"`
|
||||
Language string `json:"language"`
|
||||
Budget *int64 `json:"budget"`
|
||||
Revenue *int64 `json:"revenue"`
|
||||
IMDbID string `json:"imdbId"`
|
||||
ExternalIDs UnifiedExternalIDs `json:"externalIds"`
|
||||
}
|
||||
|
||||
type UnifiedSearchItem struct {
|
||||
ID string `json:"id"`
|
||||
SourceID string `json:"sourceId"`
|
||||
Title string `json:"title"`
|
||||
Type string `json:"type"`
|
||||
ReleaseDate string `json:"releaseDate"`
|
||||
PosterURL string `json:"posterUrl"`
|
||||
Rating float64 `json:"rating"`
|
||||
Description string `json:"description"`
|
||||
ExternalIDs UnifiedExternalIDs `json:"externalIds"`
|
||||
}
|
||||
|
||||
type UnifiedPagination struct {
|
||||
Page int `json:"page"`
|
||||
TotalPages int `json:"totalPages"`
|
||||
TotalResults int `json:"totalResults"`
|
||||
PageSize int `json:"pageSize"`
|
||||
}
|
||||
|
||||
type UnifiedMetadata struct {
|
||||
FetchedAt time.Time `json:"fetchedAt"`
|
||||
APIVersion string `json:"apiVersion"`
|
||||
ResponseTime int64 `json:"responseTime"`
|
||||
Query string `json:"query,omitempty"`
|
||||
}
|
||||
|
||||
type UnifiedAPIResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
Source string `json:"source,omitempty"`
|
||||
Metadata UnifiedMetadata `json:"metadata"`
|
||||
}
|
||||
|
||||
type UnifiedSearchResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Data []UnifiedSearchItem `json:"data"`
|
||||
Source string `json:"source"`
|
||||
Pagination UnifiedPagination `json:"pagination"`
|
||||
Metadata UnifiedMetadata `json:"metadata"`
|
||||
}
|
||||
Reference in New Issue
Block a user