aboutsummaryrefslogtreecommitdiff
path: root/user
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@protonmail.ch>2022-02-28 13:06:16 +0530
committerVidhu Kant Sharma <vidhukant@protonmail.ch>2022-02-28 13:06:16 +0530
commit95b8ab702708538ccaf26efd141b448148ac6d6d (patch)
tree62d41395d8d45f9045c64974f7dcf7c15b7755ef /user
parent2bf5302f9a653f46f7932329fd03aa3688afc35b (diff)
documented manga package and fixed errors in anime README
Diffstat (limited to 'user')
-rw-r--r--user/anime/README.md7
-rw-r--r--user/manga/README.md194
-rw-r--r--user/manga/update_mangalist.go12
3 files changed, 204 insertions, 9 deletions
diff --git a/user/anime/README.md b/user/anime/README.md
index e2194e0..80ce4e6 100644
--- a/user/anime/README.md
+++ b/user/anime/README.md
@@ -1,4 +1,4 @@
-# MAL2Go/user
+# MAL2Go/user/anime
MAL2Go `user/anime` package has functionality related to updating the user's anime list.
To *get* anime data, refer to the [`anime`](../../anime) package.
@@ -39,14 +39,13 @@ fmt.Println(resp)
- ### Get user's anime list
Possible statuses are:
-- ``
- `watching`
- `completed`
- `on_hold`
- `dropped`
- `plan_to_watch`
-Leaving blank (``) gets all the anime
+Leaving blank (`""`) gets all the anime
Possible sorts are:
- `list_score`
@@ -55,7 +54,7 @@ Possible sorts are:
- `anime_start_date`
- `anime_id` (beta)
-Leaving user blank or as `"@me"` returns the authenticated user's list
+Leaving user blank (`""`) or as `"@me"` returns the authenticated user's list
``` go
user := "0ZeroTsu"
diff --git a/user/manga/README.md b/user/manga/README.md
index 1a6c636..db4ed5c 100644
--- a/user/manga/README.md
+++ b/user/manga/README.md
@@ -1,19 +1,203 @@
-# MAL2Go/user
-MAL2Go `user/anime` package has functionality related to updating the user's anime list.
+# MAL2Go/user/manga
+MAL2Go `user/manga` package has functionality related to updating the user's manga list.
+
+To *get* anime data, refer to the [`manga`](../../manga) package.
+
+**There are multiple possible server responses and errors currently haven't been implemented yet.**
+
+## Installation
+In a terminal, run
+``` fish
+go get "github.com/MikunoNaka/MAL2Go/user/manga"
+```
## Usage
Firstly, import this package and instanciate the client.
``` go
import (
- "github.com/MikunoNaka/MAL2Go/user/anime"
+ "github.com/MikunoNaka/MAL2Go/user/manga"
)
```
Now instanciate with
``` go
-myClient := anime.Client {
+myClient := manga.Client {
AuthToken: "Bearer " + yourTokenHere,
}
```
-**More to be added later**
+- ### Delete a manga from user's anime list
+``` go
+mangaId := 108407 // manga's ID
+
+resp := myClient.DeleteManga(mangaId)
+
+/* if manga is successfully deleted, resp is 200
+ * if manga isn't in the list resp is 404 */
+fmt.Println(resp)
+```
+
+- ### Get user's manga list
+Possible statuses are:
+- `reading`
+- `completed`
+- `on_hold`
+- `dropped`
+- `plan_to_watch`
+
+Leaving blank (`""`) gets all the anime
+
+Possible sorts are:
+- `list_score`
+- `list_updated_at`
+- `manga_title`
+- `manga_start_date`
+- `manga_id` (beta)
+
+Leaving user blank (`""`) or as `"@me"` returns the authenticated user's list
+
+``` go
+user := "0ZeroTsu"
+status := "reading"
+sort := "list_score"
+
+limit := 1000 // max is 1000
+offset := 0
+
+// fields := []string{} means get all the fields
+fields := []string{"title"}
+
+mangaList, err := myClient.GetMangaList(user, status, sort, limit, offset, fields)
+if err != nil {
+ fmt.Println(err)
+}
+
+// mangaList.Mangas is an array of the mangas in the list
+for _, manga := range mangaList.Mangas {
+ fmt.Println(manga.Title)
+}
+
+fmt.Println(mangaList.Paging.NextPage, mangaList.Paging.PrevPage)
+```
+
+- ### Set a manga's status
+``` go
+mangaId := 108407 // manga's ID
+status := "dropped"
+resp, _ := myClient.SetStatus(mangaId, status)
+fmt.Println(resp.Error, resp.Message)
+```
+
+- ### Set read volumes
+``` go
+mangaId := 108407 // manga's ID
+volumesRead := 10
+resp, _ := myClient.SetVolumesRead(mangaId, volumesRead)
+fmt.Println(resp.Error, resp.Message)
+```
+
+- ### Set read chapters
+``` go
+mangaId := 108407 // manga's ID
+chaptersRead := 150
+resp, _ := myClient.SetChaptersread(mangaId, chaptersRead)
+fmt.Println(resp.Error, resp.Message)
+```
+
+- ### Set is rereading status
+``` go
+mangaId := 108407 // manga's ID
+isRereading := true
+_, _ := myClient.SetIsRereading(mangaId, isRereading)
+```
+
+- ### Set a manga's score
+``` go
+mangaId := 108407 // manga's ID
+score := 1
+_, _ := myClient.SetScore(mangaId, score)
+```
+
+- ### Set a manga's priority
+Priority on MyAnimeList ranges from 0 to 2
+``` go
+mangaId := 108407 // manga's ID
+priority := 2
+_, _ := myClient.SetPriority(mangaId, priority)
+```
+
+- ### Set a manga's reread value
+Reread value on MyAnimeList ranges from 0 to 5
+``` go
+mangaId := 108407 // manga's ID
+rereadValue := 4
+_, _ := myClient.SetRereadValue(mangaId, rereadValue)
+```
+
+- ### Set a manga's reread count
+Number of times user has reread the manga. There is no limit
+``` go
+mangaId := 108407 // manga's ID
+rereadCount := 69
+_, _ := myClient.SetRereadCount(mangaId, rereadCount)
+```
+
+- ### Set a manga's tags
+``` go
+mangaId := 108407 // manga's ID
+tags := "tags"
+_, _ := myClient.UpdateTags(mangaId, tags)
+```
+
+- ### Set a manga's comments
+``` go
+mangaId := 108407 // manga's ID
+comments := "I hate but love this"
+_, _ := myClient.UpdateComments(mangaId, comments)
+```
+
+- ### Update all fields of a manga
+WARNING: this function can overwrite any data and set it to null
+if you don't specify a value to it.
+
+Refrain/use it carefully to avoid data loss.
+
+``` go
+updateData := manga.UpdateMangaData {
+ Status: "dropped",
+ IsRereading: true,
+ Score: 1,
+ VolumesRead: 10,
+ ChaptersRead: 150,
+ Priority: 2,
+ TimesReread: 69,
+ RereadValue: 4,
+ Tags: "tags",
+ Comments: "I hate but love this",
+}
+
+mangaId := 108407 // manga's ID
+
+resp, err := myClient.UpdateManga(mangaId, updateData)
+if err != nil {
+ fmt.Println(err)
+}
+
+fmt.Println(resp.Error, resp.Message)
+```
+
+## Structure
+- [mangalist.go](mangalist.go)
+Contains the exported functions to do some basic functions with manga lists.
+
+- [mangalist.structs.go](mangalist.structs.go)
+Contains all the structs representing mangalist data pulled from MyAnimeList.
+
+- [client.go](client.go)
+The Client for accessing the API with this package.
+
+- [request_handler.go](request_handler.go)
+Responsible for making HTTP requests
+
+- [update_mangalist.go](update_mangalist.go)
+Contains all the exported functions to update a manga entry in user's mangalist.
diff --git a/user/manga/update_mangalist.go b/user/manga/update_mangalist.go
index cac27e8..423a919 100644
--- a/user/manga/update_mangalist.go
+++ b/user/manga/update_mangalist.go
@@ -45,6 +45,18 @@ func (c Client)SetStatus(id int, status string) (serverResponse, error) {
return c.putRequestHandler(endpoint, params), nil
}
+// update just a manga's num of volumes read
+func (c Client)SetVolumesRead(id int, volumes int) (serverResponse, error) {
+ endpoint := endpointGenerator(id)
+
+ // data to be sent to the server
+ params := url.Values{}
+ params.Set("num_volumes_read", strconv.Itoa(volumes))
+
+ // make API request
+ return c.putRequestHandler(endpoint, params), nil
+}
+
// update just a manga's num of chapters read
func (c Client)SetChaptersRead(id int, chapters int) (serverResponse, error) {
endpoint := endpointGenerator(id)