getCallDetails static method
void
getCallDetails(
- String sessionId, {
- required dynamic onSuccess(),
- required dynamic onError(),
Retrieves the call details for a given session ID. All validation is done here in the Dart layer using InputValidator.
Implementation
static void getCallDetails(String sessionId,
{required Function(List<CallLog> callLogs) onSuccess,
required Function(CometChatCallsException error) onError}) async {
try {
// Validation - business logic in Dart layer using centralized validator
final sessionIdError = InputValidator.validateSessionId(sessionId);
if (sessionIdError != null) {
onError(sessionIdError);
return;
}
final userAuthToken = await getUserAuthToken();
if (userAuthToken == null || userAuthToken.isEmpty) {
onError(CometChatCallsException.userAuthTokenNull());
return;
}
ApiConnection().getCallDetails(
sessionID: sessionId,
authToken: userAuthToken,
onSuccess: (String response) {
try {
List<CallLog> data = <CallLog>[];
jsonDecode(response)["data"].forEach((v) {
data.add(CallLog.fromJson(v));
});
onSuccess(data);
} catch (e) {
onError(CometChatCallsException.jsonParseError(e.toString()));
}
},
onError: (CometChatCallsException e) {
onError(e);
});
} catch (e) {
onError(CometChatCallsException.wrapUnhandled(e));
}
}