From 208cb52b47278315b5227251d5b65c07908cde23 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Sun, 13 Feb 2022 16:15:47 +0530 Subject: added support to get all anime from user's anime list --- user/anime/animelist.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'user') 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 -- cgit v1.2.3