Something went wrong. Try again.
Discover books, shows, and movies at your level. Track your progress by filling your Shelf with what you find, and share with other language shlf.space
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354package types
import ( "fmt")
const ( PlatformYes24 string = "yes24")
type Book struct { ID string `json:"id"` Platform string `json:"platform"` Title string `json:"title"` Author string `json:"author"` Description string `json:"description"`}
func (book Book) SpineImageURL() string { switch book.Platform { case PlatformYes24: return fmt.Sprintf("https://image.yes24.com/goods/%s/SIDE/XL", book.ID) } return ""}
func (book Book) CoverImageURL() string { switch book.Platform { case PlatformYes24: return fmt.Sprintf("https://image.yes24.com/goods/%s/XL", book.ID) } return ""}
// Used when the book struct is needed to be serialized for JS / templ// interactions.type BookView struct { Title string `json:"title"` Author string `json:"author"` Description string `json:"description"` SpineURL string `json:"spineUrl"` CoverURL string `json:"coverUrl"`}
func (book Book) View() BookView { return BookView{ Title: book.Title, Author: book.Author, Description: book.Description, SpineURL: book.SpineImageURL(), CoverURL: book.CoverImageURL(), }}