aboutsummaryrefslogtreecommitdiff
path: root/anime_list.go
diff options
context:
space:
mode:
Diffstat (limited to 'anime_list.go')
-rw-r--r--anime_list.go27
1 files changed, 25 insertions, 2 deletions
diff --git a/anime_list.go b/anime_list.go
index 9d0f370..440e672 100644
--- a/anime_list.go
+++ b/anime_list.go
@@ -77,10 +77,33 @@ func (c Client) GetAnimeList(animes *[]Anime, params *ListParams) (bool, error)
}
func (c Client) UpdateAnime(res *AnimeUpdateResponse, id int, params map[string]interface{}) error {
- // TODO: validate params
p := url.Values{}
for k, v := range params {
- p.Set(k, fmt.Sprint(v))
+ vString := fmt.Sprint(v)
+ var err error
+
+ // validate params
+ switch(k) {
+ case Status:
+ err = validateAnimeListStatus(vString)
+ case Score:
+ err = validateScore(v.(int))
+ case Priority:
+ err = validatePriority(v.(int))
+ case RewatchValue:
+ err = validateRewatchValue(v.(int))
+ case Tags, Comments, IsRewatching, EpisodesWatched, TimesRewatched:
+ // these ones don't need to be validated
+ err = nil
+ default:
+ err = ErrUnknownUpdateParam
+ }
+
+ if err != nil {
+ return err
+ }
+
+ p.Set(k, vString)
}
body, err := c.put(getUpdateQuery(id, "anime"), p)