aboutsummaryrefslogtreecommitdiff
path: root/user/manga/README.md
blob: db4ed5c44c042ff03b1aacfb3a7725f1aaa11f32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# 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/manga"
)
```

Now instanciate with
``` go
myClient := manga.Client {
  AuthToken: "Bearer " + yourTokenHere,
}
```

- ### 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.