aboutsummaryrefslogtreecommitdiff
path: root/user
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@protonmail.ch>2022-02-13 16:05:15 +0530
committerVidhu Kant Sharma <vidhukant@protonmail.ch>2022-02-13 16:05:15 +0530
commit032469fc1c43fb76fdf8882371391672dcfb87f0 (patch)
tree1eea0bc4baf9cda5fbb51fdbfa3dd7493cbdc56c /user
parent7dcda8a7344ec5be2b93672ace638515708554de (diff)
added function to delete anime from MAL List
Diffstat (limited to 'user')
-rw-r--r--user/anime/animelist.go8
-rw-r--r--user/anime/request_handler.go6
2 files changed, 14 insertions, 0 deletions
diff --git a/user/anime/animelist.go b/user/anime/animelist.go
index 2099204..7fe81b8 100644
--- a/user/anime/animelist.go
+++ b/user/anime/animelist.go
@@ -28,6 +28,14 @@ import (
const BASE_URL string = "https://api.myanimelist.net/v2"
const maxListLimit int = 1000
+// Delete an anime from user's anime list
+func (c AnimeListClient)DeleteAnime(id int) string {
+ endpoint := fmt.Sprintf("%s/anime/%d/my_list_status", BASE_URL, id)
+ /* Returns 200 if anime successfully deleted
+ * Alternatively returns 404 if anime not in user's anime list */
+ return c.requestHandler(endpoint, "DELETE")
+}
+
// Get authenticated user's anime list
func (c AnimeListClient) GetAnimeList(user, status, sort string, limit, offset int) (a.AnimeList, error){
var userAnimeList a.AnimeList
diff --git a/user/anime/request_handler.go b/user/anime/request_handler.go
index f424c29..2007e56 100644
--- a/user/anime/request_handler.go
+++ b/user/anime/request_handler.go
@@ -20,6 +20,7 @@ import (
"io/ioutil"
"log"
"net/http"
+ "strconv"
)
// Handles HTTP request with your OAuth token as a Header
@@ -44,5 +45,10 @@ func (c AnimeListClient) requestHandler(endpoint, method string) string {
log.Fatal(err)
}
+ // for DeleteAnime, its endpoint returns null data
+ if method == "DELETE" {
+ return strconv.Itoa(res.StatusCode)
+ }
+
return string(body)
}