addToCollection method
- List<
Tuple2< movies = const [],Movie, CollectionItemPostData?> > - List<
Tuple2< shows = const [],Show, CollectionItemPostData?> > - List<
Tuple2< seasons = const [],Season, CollectionItemPostData?> > - List<
Tuple2< episodes = const [],Episode, CollectionItemPostData?> >
Add items to a user's collection. Accepts shows, seasons, episodes and movies.
If only a show is passed, all episodes for the show will be collected. If seasons are specified, all episodes in those seasons will be collected.
Send a collected_at UTC datetime to mark items as collected in the past. You can also send additional metadata about the media itself to have a very accurate collection. Showcase what is available to watch from your epic HD DVD collection down to your downloaded iTunes movies.
Note: You can resend items already in your collection and they will be updated with any new values. This includes the collected_at and any other metadata.
movies
- a list of tuples consisting of a Movie and optional fields to be added.
shows
- a list of tuples consisting of a Movie and optional fields to be added.
seasons
- a list of tuples consisting of a Movie and optional fields to be added.
episodes
- a list of tuples consisting of a Movie and optional fields to be added.
🔒 OAuth Required
Implementation
Future<AddToSyncResponse> addToCollection({
List<Tuple2<Movie, CollectionItemPostData?>> movies = const [],
List<Tuple2<Show, CollectionItemPostData?>> shows = const [],
List<Tuple2<Season, CollectionItemPostData?>> seasons = const [],
List<Tuple2<Episode, CollectionItemPostData?>> episodes = const [],
}) async {
Map<String, dynamic> body = {};
if (movies.isNotEmpty) {
body["movies"] = movies.map((tuple) {
final meta = tuple.item1.metadata;
if (tuple.item2 != null) {
meta.addAll(tuple.item2!.toMap());
}
return meta;
}).toList();
}
if (shows.isNotEmpty) {
body["shows"] = shows.map((tuple) {
final meta = tuple.item1.metadata;
if (tuple.item2 != null) {
meta.addAll(tuple.item2!.toMap());
}
return meta;
}).toList();
}
if (seasons.isNotEmpty) {
body["seasons"] = seasons.map((tuple) {
final meta = tuple.item1.metadata;
if (tuple.item2 != null) {
meta.addAll(tuple.item2!.toMap());
}
return meta;
}).toList();
}
if (episodes.isNotEmpty) {
body["episodes"] = episodes.map((tuple) {
final meta = tuple.item1.metadata;
if (tuple.item2 != null) {
meta.addAll(tuple.item2!.toMap());
}
return meta;
}).toList();
}
return await _manager._authenticatedPost<AddToSyncResponse>(
"sync/collection",
body: jsonEncode(body));
}