listMemberships method

Future<MembershipList> listMemberships({
  1. required String userId,
  2. List<String>? queries,
  3. String? search,
  4. bool? total,
})

Get the user membership list by its unique ID.

Implementation

Future<models.MembershipList> listMemberships({
  required String userId,
  List<String>? queries,
  String? search,
  bool? total,
}) async {
  final String apiPath = '/users/{userId}/memberships'.replaceAll(
    '{userId}',
    userId,
  );

  final Map<String, dynamic> apiParams = {
    if (queries != null) 'queries': queries,
    if (search != null) 'search': search,
    if (total != null) 'total': total,
  };

  final Map<String, String> apiHeaders = {
    'X-Appwrite-Project': client.config['project'] ?? '',
    'accept': 'application/json',
  };

  final res = await client.call(
    HttpMethod.get,
    path: apiPath,
    params: apiParams,
    headers: apiHeaders,
  );

  return models.MembershipList.fromMap(res.data);
}