refreshSession method
Implementation
@override
Future<RefreshSessionResponse> refreshSession(
RefreshSessionFormData formData,
) async {
try {
final response = await _dio.post(
_refreshSession,
data: formData.toJson(),
);
if (response.data != null) {
final refreshSessionResponse = RefreshSessionResponse.fromJson(
response.data,
);
return refreshSessionResponse;
} else {
if (kDebugMode) {
debugPrint("[MAYYA CORE ERROR ON RESPONSE]");
debugPrint("[MAYYA CORE ERROR ON REFRESH SESSION]");
}
throw CoreExceptions(
statusCode: CoreExceptions.emptyResponse,
description: 'refresh session error occurred empty response',
);
}
} on DioException catch (ex) {
if (kDebugMode) {
debugPrint("[MAYYA CORE DIO ERROR]");
debugPrint("[MAYYA CORE ERROR ON REFRESH SESSION]");
}
switch (ex.type) {
case DioExceptionType.connectionTimeout:
throw CoreExceptions(
statusCode: CoreExceptions.connectionTimeout,
description: "connectionTimeout",
stackTrace: ex.stackTrace,
);
case DioExceptionType.sendTimeout:
throw CoreExceptions(
statusCode: CoreExceptions.sendTimeout,
description: "sendTimeout",
stackTrace: ex.stackTrace,
);
case DioExceptionType.receiveTimeout:
throw CoreExceptions(
statusCode: CoreExceptions.receiveTimeout,
description: "receiveTimeout",
stackTrace: ex.stackTrace,
);
case DioExceptionType.badCertificate:
throw CoreExceptions(
statusCode: CoreExceptions.badCertificate,
description: "badCertificate",
stackTrace: ex.stackTrace,
);
case DioExceptionType.badResponse:
throw _handleBadResponse(ex);
case DioExceptionType.cancel:
throw CoreExceptions(
statusCode: CoreExceptions.cancel,
description: "cancel",
stackTrace: ex.stackTrace,
);
case DioExceptionType.connectionError:
throw CoreExceptions(
statusCode: CoreExceptions.connectionError,
description: "connectionError",
stackTrace: ex.stackTrace,
);
case DioExceptionType.unknown:
throw CoreExceptions(
statusCode: CoreExceptions.unknown,
description: "unknown",
stackTrace: ex.stackTrace,
);
}
} catch (e) {
if (kDebugMode) {
debugPrint("[MAYYA CORE ERROR]");
debugPrint("[MAYYA CORE ERROR ON REFRESH SESSION]");
}
throw CoreExceptions(
statusCode: CoreExceptions.implementationError,
description: "ERROR ON REFRESH SESSION",
);
}
}