sendSinaMessage method
Creates a new chat. Returns the session ID if the API call is successful.
Implementation
Future<ChatResponse> sendSinaMessage(String text, String sessionId, String? mediaId) async {
final Map<String, dynamic> body = {
"text": text,
};
if (mediaId != null) {
body['media_id'] = mediaId;
}
final response =
await callApi(endpoint: 'chats/$sessionId/messages',
method: 'post',
body: body,
isSinaAPI: true);
if (response.statusCode == 200) {
final responseData = json.decode(response.body);
final createdUser = ChatResponse.fromJson(responseData);
return createdUser;
} else {
_throwApiError(response);
}
}