sendSinaMessage method

Future<ChatResponse> sendSinaMessage(
  1. String text,
  2. String sessionId
)

Creates a new chat. Returns the session ID if the API call is successful.

Implementation

Future<ChatResponse> sendSinaMessage(String text, String sessionId) async {
  final Map<String, dynamic> body = {
    "text": text,
  };
  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 {
    throw Exception(response);
  }
}