addToWatchlist method

Future<AddToSyncResponse> addToWatchlist({
  1. List<Movie> movies = const [],
  2. List<Show> shows = const [],
  3. List<Season> seasons = const [],
  4. List<Episode> episodes = const [],
})

Add one of more items to a user's watchlist.

Accepts shows, seasons, episodes and movies. If only a show is passed, only the show itself will be added. If seasons are specified, all of those seasons will be added.

movies - Movies to add shows - Shows to add seasons - Seasons to add episodes - Episodes to add

🔒 OAuth Required

Implementation

Future<AddToSyncResponse> addToWatchlist(
    {List<Movie> movies = const [],
    List<Show> shows = const [],
    List<Season> seasons = const [],
    List<Episode> episodes = const []}) async {
  Map<String, dynamic> body = {};
  if (movies.isNotEmpty) {
    body["movies"] = movies.map((movie) => movie.metadata).toList();
  }

  if (shows.isNotEmpty) {
    body["shows"] = shows.map((show) => show.metadata).toList();
  }

  if (seasons.isNotEmpty) {
    body["seasons"] = seasons.map((season) => season.metadata).toList();
  }

  if (episodes.isNotEmpty) {
    body["episodes"] = episodes.map((episode) => episode.metadata).toList();
  }

  return await _manager._authenticatedPost<AddToSyncResponse>(
      "sync/watchlist",
      body: jsonEncode(body));
}