Add custom error for internal request

This commit is contained in:
bytedream 2022-06-19 00:36:27 +02:00
parent c5f2b55f34
commit 5709012dfe
4 changed files with 29 additions and 9 deletions

View file

@ -195,6 +195,7 @@ func SeriesFromID(crunchy *Crunchyroll, id string) (*Series, error) {
}
// AddToWatchlist adds the current episode to the watchlist.
// Will return an RequestError with the response status code of 409 if the series was already on the watchlist before.
func (s *Series) AddToWatchlist() error {
endpoint := fmt.Sprintf("https://beta.crunchyroll.com/content/v1/watchlist/%s?locale=%s", s.crunchy.Config.AccountID, s.crunchy.Locale)
body, _ := json.Marshal(map[string]string{"content_id": s.ID})
@ -208,6 +209,7 @@ func (s *Series) AddToWatchlist() error {
}
// RemoveFromWatchlist removes the current episode from the watchlist.
// Will return an RequestError with the response status code of 404 if the series was not on the watchlist before.
func (s *Series) RemoveFromWatchlist() error {
endpoint := fmt.Sprintf("https://beta.crunchyroll.com/content/v1/watchlist/%s/%s?locale=%s", s.crunchy.Config.AccountID, s.ID, s.crunchy.Locale)
_, err := s.crunchy.request(endpoint, http.MethodDelete)