updateChatSessionDetails method
Implementation
Future<dynamic> updateChatSessionDetails(
{required String org,
required String userId,
required String sessionId,
required String title}) async {
// Construct the full URL for the PUT request
final String url =
'$dataBaseUrl/api/ai/mentor/orgs/$org/users/$userId/sessions/$sessionId/';
// Prepare the headers
Map<String, String> headers = _headers();
// Prepare the body of the PUT request
final body = json.encode({"title": title});
// Execute the PUT request
final response = await http.put(
Uri.parse(url),
headers: headers,
body: body,
);
// Check the response status code and return the result or throw an error
if (response.statusCode == 200) {
// If the server returns an OK response, parse the JSON
return json.decode(response.body);
} else {
// If the server did not return a 200 OK response,
// then throw an exception.
throw Exception(
'Failed to update chat session details. Status code: ${response.statusCode}');
}
}