list method

Future<List<Entitlement>> list(
  1. {Snowflake? userId,
  2. List<Snowflake>? skuIds,
  3. Snowflake? before,
  4. Snowflake? after,
  5. int? limit,
  6. Snowflake? guildId,
  7. bool? excludeEnded}
)

List all the entitlements for this application.

Implementation

Future<List<Entitlement>> list({
  Snowflake? userId,
  List<Snowflake>? skuIds,
  Snowflake? before,
  Snowflake? after,
  int? limit,
  Snowflake? guildId,
  bool? excludeEnded,
}) async {
  final route = HttpRoute()
    ..applications(id: applicationId.toString())
    ..entitlements();
  final request = BasicRequest(route, queryParameters: {
    if (userId != null) 'user_id': userId.toString(),
    if (skuIds != null) 'sku_ids': skuIds.join(','),
    if (before != null) 'before': before.toString(),
    if (after != null) 'after': after.toString(),
    if (limit != null) 'limit': limit.toString(),
    if (guildId != null) 'guild_id': guildId.toString(),
    if (excludeEnded != null) 'exclude_ended': excludeEnded.toString(),
  });

  final response = await client.httpHandler.executeSafe(request);
  final entitlements = parseMany(response.jsonBody as List<Object?>, parse);

  entitlements.forEach(client.updateCacheWith);
  return entitlements;
}