batchCreateTeamMember method
Future<Map<String, TeamMember> >
batchCreateTeamMember({
- required TeamMemberBatchUpsertRequest request,
- String? authToken,
Creates multiple TeamMember objects.
The created TeamMember objects are returned on successful creates. This process is non-transactional and processes as much of the request as possible. If one of the creates in the request cannot be successfully processed, the request is not marked as failed, but the body of the response contains explicit error information for the failed create.
Implementation
Future<Map<String, TeamMember>> batchCreateTeamMember({
required TeamMemberBatchUpsertRequest request,
String? authToken,
}) async {
authToken ??= authenticationService.getCachedToken()?.accessToken;
Map<String, String> headers = {
"Authorization": "Bearer ${authToken ?? ""}",
'Content-Type': 'application/json; charset=UTF-8',
'Accept': 'application/json',
};
Uri endpoint = Uri.https(
baseUrl, "/v2/team-members/bulk-create");
//print (endpoint.toString());
var response = await
http.post(endpoint, body: jsonEncode(request.toJson()), headers: headers);
if (response.statusCode == 200) {
print (jsonDecode(response.body));
return TeamMemberBatchResponse.fromJson(jsonDecode(response.body)).teamMembers!.map((key, value) => MapEntry(key, value.teamMember!));
}
else {
print (response.body);
throw TeamMemberException(statusCode: response.statusCode, message: TeamMemberBatchResponse.fromJson(jsonDecode(response.body)).errors?[0].detail?.toString());
}
}