removed cursor in favor of context and channels
This commit is contained in:
109
nu_types.go
Normal file
109
nu_types.go
Normal file
@ -0,0 +1,109 @@
|
||||
package nuapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
type NovelID = string
|
||||
type ChapterID = string
|
||||
type ReadingListID = string
|
||||
type GroupID = string
|
||||
|
||||
type ReadingList struct {
|
||||
ID ReadingListID `json:"id"`
|
||||
Entries []ReadingListEntry `json:"entries"`
|
||||
}
|
||||
|
||||
func (l ReadingList) String() string {
|
||||
data, _ := json.MarshalIndent(l, "", "\t")
|
||||
return string(data)
|
||||
}
|
||||
|
||||
type ReadingListEntry struct {
|
||||
Novel NovelEntry `json:"novel"`
|
||||
CurrentChapter ReadingListChapterEntry `json:"current_chapter"`
|
||||
LatestChapter ReadingListChapterEntry `json:"latest_chapter"`
|
||||
}
|
||||
|
||||
func (e ReadingListEntry) String() string {
|
||||
data, _ := json.MarshalIndent(e, "", "\t")
|
||||
return string(data)
|
||||
}
|
||||
|
||||
func (e ReadingListEntry) NewChapterAvailable() bool {
|
||||
return e.CurrentChapter.ID != e.LatestChapter.ID
|
||||
}
|
||||
|
||||
type ReadingListChapterEntry struct {
|
||||
NovelID NovelID `json:"novel_id"`
|
||||
ID ChapterID `json:"id"`
|
||||
Link string `json:"link"`
|
||||
}
|
||||
|
||||
func (e ReadingListChapterEntry) String() string {
|
||||
data, _ := json.MarshalIndent(e, "", "\t")
|
||||
return string(data)
|
||||
}
|
||||
|
||||
type NovelEntry struct {
|
||||
NovelID NovelID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (e NovelEntry) String() string {
|
||||
data, _ := json.MarshalIndent(e, "", "\t")
|
||||
return string(data)
|
||||
}
|
||||
|
||||
type Novel struct {
|
||||
ID NovelID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
AssociatedNames []string `json:"associated_names"`
|
||||
Description string `json:"description"`
|
||||
Cover string `json:"cover"`
|
||||
Type NovelType `json:"type"`
|
||||
OriginalLanguage Language `json:"original_language"`
|
||||
Genres []GenreID `json:"genres"`
|
||||
Tags []TagID `json:"tags"`
|
||||
}
|
||||
|
||||
func (n Novel) String() string {
|
||||
data, _ := json.MarshalIndent(n, "", "\t")
|
||||
return string(data)
|
||||
}
|
||||
|
||||
type NovelType string
|
||||
|
||||
const (
|
||||
TypeLightNovel NovelType = "Light Novel"
|
||||
TypePublishedNovel NovelType = "Published Novel"
|
||||
TypeWebNovel NovelType = "Web Novel"
|
||||
)
|
||||
|
||||
type Language string
|
||||
|
||||
const (
|
||||
LanguageJapanese Language = "jp"
|
||||
LanguageChinese Language = "cn"
|
||||
LanguageMalaysian Language = "my"
|
||||
LanguageFilipino Language = "fil"
|
||||
LanguageKhmer Language = "khm"
|
||||
LanguageThai Language = "th"
|
||||
LanguageIndonesian Language = "id"
|
||||
LanguageKorean Language = "kr"
|
||||
LanguageVietnamese Language = "vn"
|
||||
)
|
||||
|
||||
type NovelChapterEntry struct {
|
||||
ID ChapterID `json:"id"`
|
||||
Link string `json:"link"`
|
||||
NovelID NovelID `json:"novel_id"`
|
||||
Date time.Time `json:"date"`
|
||||
Group GroupID `json:"group"`
|
||||
}
|
||||
|
||||
func (nce NovelChapterEntry) String() string {
|
||||
data, _ := json.MarshalIndent(nce, "", "\t")
|
||||
return string(data)
|
||||
}
|
Reference in New Issue
Block a user