getLastConsultation method
Retrieves the last consultation from the API. Returns the last consultation object if the API call is successful.
Implementation
Future<Consultation> getLastConsultation() async {
final response =
await callApi(endpoint: 'consultations', method: 'get', body: {
"per-page": 1,
"sort": "-id",
"expand":
"pusherAppKey,parentConsultation,consultations,user,media,pusherChannel,"
"chatConfig,chatHistory,voipConfig,videoConfig,recommendation"
});
if (response.statusCode == 200) {
final responseData = json.decode(response.body);
final consultation = Consultation.fromJson(responseData[0]);
return consultation;
} else {
throw Exception(response);
}
}