addTeamMembers method

Future<List<MmTeamMember>?> addTeamMembers(
  1. String teamId,
  2. List<MmTeamMember> mmTeamMember, {
  3. bool? graceful,
})

Add multiple users to team

Add a number of users to the team by user_id. ##### Permissions Must be authenticated. Authenticated user must have the add_user_to_team permission.

Parameters:

  • String teamId (required): Team GUID

  • List<MmTeamMember> mmTeamMember (required):

  • bool graceful: Instead of aborting the operation if a user cannot be added, return an arrray that will contain both the success and added members and the ones with error, in form of [{\"member\": {...}, \"user_id\", \"...\", \"error\": {...}}]

Implementation

Future<List<MmTeamMember>?> addTeamMembers(
  String teamId,
  List<MmTeamMember> mmTeamMember, {
  bool? graceful,
}) async {
  final response = await addTeamMembersWithHttpInfo(
    teamId,
    mmTeamMember,
    graceful: graceful,
  );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw MmApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
    final responseBody = await _decodeBodyBytes(response);
    return (await apiClient.deserializeAsync(responseBody, 'List<MmTeamMember>') as List)
        .cast<MmTeamMember>()
        .toList();
  }
  return null;
}