aboutsummaryrefslogtreecommitdiff
path: root/user/anime
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@protonmail.ch>2022-02-13 16:15:47 +0530
committerVidhu Kant Sharma <vidhukant@protonmail.ch>2022-02-13 16:15:47 +0530
commit208cb52b47278315b5227251d5b65c07908cde23 (patch)
tree798926c56b786a98d9908f53562c66969effe699 /user/anime
parent032469fc1c43fb76fdf8882371391672dcfb87f0 (diff)
added support to get all anime from user's anime list
Diffstat (limited to 'user/anime')
-rw-r--r--user/anime/animelist.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/user/anime/animelist.go b/user/anime/animelist.go
index 7fe81b8..120bdea 100644
--- a/user/anime/animelist.go
+++ b/user/anime/animelist.go
@@ -36,6 +36,11 @@ func (c AnimeListClient)DeleteAnime(id int) string {
return c.requestHandler(endpoint, "DELETE")
}
+// Update/Add an anime to user's anime list
+// func UpdateAnime(id int) {
+
+// }
+
// Get authenticated user's anime list
func (c AnimeListClient) GetAnimeList(user, status, sort string, limit, offset int) (a.AnimeList, error){
var userAnimeList a.AnimeList
@@ -51,7 +56,7 @@ func (c AnimeListClient) GetAnimeList(user, status, sort string, limit, offset i
}
// checks if valid status is specified
- if !e.IsValidListStatus(status) {
+ if status != "" && !e.IsValidListStatus(status) {
return userAnimeList, errors.New(fmt.Sprintf("GetAnimeList: Invalid status specified: \"%s\"", status))
}
@@ -60,7 +65,13 @@ func (c AnimeListClient) GetAnimeList(user, status, sort string, limit, offset i
user = "@me"
}
- endpoint := BASE_URL + "/users/" + user + "/animelist?status=" + status + "&sort=" + sort + "&limit=" + strconv.Itoa(limit) + "&offset=" + strconv.Itoa(offset)
+ // if status is "" it returns all anime
+ var endpoint string
+ if status == "" {
+ endpoint = BASE_URL + "/users/" + user + "/animelist?sort=" + sort + "&limit=" + strconv.Itoa(limit) + "&offset=" + strconv.Itoa(offset)
+ } else {
+ endpoint = BASE_URL + "/users/" + user + "/animelist?status=" + status + "&sort=" + sort + "&limit=" + strconv.Itoa(limit) + "&offset=" + strconv.Itoa(offset)
+ }
// get data from API
var animeListData AnimeListRaw