getCollection method

Future<List<UserCollectionItem>> getCollection(
  1. String id,
  2. UserCollectionType type, {
  3. bool extendedFull = false,
  4. bool? extendedMetadata,
  5. bool useOAuth = false,
})

Get all collected items in a user's collection.

A collected item indicates availability to watch digitally or on physical media.

Each movie object contains collected_at and updated_at timestamps. Since users can set custom dates when they collected movies, it is possible for collected_at to be in the past. We also include updated_at to help sync Trakt data with your app. Cache this timestamp locally and only re-process the movie if you see a newer timestamp.

Each show object contains last_collected_at and last_updated_at timestamps. Since users can set custom dates when they collected episodes, it is possible for last_collected_at to be in the past. We also include last_updated_at to help sync Trakt data with your app. Cache this timestamp locally and only re-process the show if you see a newer timestamp.

If you add ?extended=metadata to the URL, it will return the additional media_type, resolution, hdr, audio, audio_channels and '3d' metadata. It will use null if the metadata isn't set for an item.

id - User slug type - Possible values: movies , shows . useOAuth - whether to make the request using OAuth header

🔓 OAuth Optional ✨ Extended Info

Implementation

Future<List<UserCollectionItem>> getCollection(String id, UserCollectionType type,
    {bool extendedFull = false, bool? extendedMetadata, bool useOAuth = false}) async {
  Map<String, dynamic>? params;
  List<String> extended = [];
  if (extendedFull) {
    extended.add("full");
  }
  if (extendedMetadata ?? false) {
    extended.add("metadata");
  }
  if (extended.isNotEmpty) {
    params = {};
    params["extended"] = extended.join(",");
  }

  if (useOAuth) {
    return await _manager._authenticatedGetList<UserCollectionItem>("users/$id/collection/${type.value}",
        queryParamameters: params);
  }

  return await _manager._getList<UserCollectionItem>("users/$id/collection/${type.value}", queryParamameters: params);
}