getCallLogList method

dynamic getCallLogList(
  1. dynamic onSuccess(
    1. List<CallLog> callLogs
    ),
  2. dynamic onError(
    1. CometChatCallsException excep
    ),
  3. String response
)

Processes the response from a getCallLogList request.

onSuccess: A function to be called when the call logs are successfully retrieved. onError: A function to be called when there is an exception. response: The raw response from the API call.

Implementation

getCallLogList(Function(List<CallLog> callLogs) onSuccess,
    Function(CometChatCallsException excep) onError, String response) {
  List<CallLog> data = <CallLog>[];
  try {
    totalPages = jsonDecode(response)['meta']['pagination']["total_pages"];
    currentPage = jsonDecode(response)['meta']['pagination']["current_page"];
    if (jsonDecode(response)["data"] != null) {
      data = <CallLog>[];
      jsonDecode(response)["data"].forEach((v) {
        data.add(CallLog.fromJson(v));
      });
      onSuccess(data);
    }
  } catch (e) {
    CometChatCallsUtils.showLog(_tag, "Error: $e");
    onError(CometChatCallsException(
        CometChatCallsConstants.codeError, e.toString(), e.toString()));
  }
}