added Not Reviewed so zero does not equal undefined
This commit is contained in:
@ -35,16 +35,38 @@ func AniListQuery(body interface{}, login bool) (json.RawMessage, string) {
|
||||
return returnedBody, ""
|
||||
}
|
||||
|
||||
func (a *App) GetAniListItem(aniId int) AniListGetSingleAnime {
|
||||
func (a *App) GetAniListItem(aniId int, login bool) AniListGetSingleAnime {
|
||||
var user = a.GetAniListLoggedInUserId()
|
||||
type Variables struct {
|
||||
UserId int `json:"userId"`
|
||||
MediaId int `json:"mediaId"`
|
||||
ListType string `json:"listType"`
|
||||
// type Variables struct {
|
||||
// UserId int `json:"userId"`
|
||||
// MediaId int `json:"mediaId"`
|
||||
// ListType string `json:"listType"`
|
||||
// }
|
||||
|
||||
var neededVariables interface{}
|
||||
|
||||
if login {
|
||||
neededVariables = struct{
|
||||
MediaId int `json:"mediaId"`
|
||||
UserId int `json:"userId"`
|
||||
ListType string `json:"listType"`
|
||||
} {
|
||||
MediaId: aniId,
|
||||
UserId: user.Data.Viewer.ID,
|
||||
ListType: "ANIME",
|
||||
}
|
||||
} else {
|
||||
neededVariables = struct {
|
||||
MediaId int `json:"mediaId"`
|
||||
ListType string `json:"listType"`
|
||||
} {
|
||||
MediaId: aniId,
|
||||
ListType: "ANIME",
|
||||
}
|
||||
}
|
||||
body := struct {
|
||||
Query string `json:"query"`
|
||||
Variables Variables `json:"variables"`
|
||||
Variables interface{} `json:"variables"`
|
||||
}{
|
||||
Query: `
|
||||
query($userId: Int, $mediaId: Int, $listType: MediaType) {
|
||||
@ -109,15 +131,11 @@ func (a *App) GetAniListItem(aniId int) AniListGetSingleAnime {
|
||||
}
|
||||
}
|
||||
`,
|
||||
Variables: Variables{
|
||||
MediaId: aniId,
|
||||
UserId: user.Data.Viewer.ID,
|
||||
ListType: "ANIME",
|
||||
},
|
||||
Variables: neededVariables,
|
||||
}
|
||||
|
||||
returnedBody, _ := AniListQuery(body, false)
|
||||
|
||||
|
||||
var post AniListGetSingleAnime
|
||||
err := json.Unmarshal(returnedBody, &post)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user