flushAnalytics method

  1. @override
Future flushAnalytics(
  1. FlushAnalyticsFormData formData
)
override

Implementation

@override
Future flushAnalytics(FlushAnalyticsFormData formData) async {
  try {
    await _dio.post(_flushAnalytics, data: formData.toJson());
  } on DioException catch (ex) {
    if (kDebugMode) {
      debugPrint("[MAYYA CORE DIO ERROR]");
      debugPrint("[MAYYA CORE ERROR ON FLUSH ANALYTICS]");
    }
    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 CoreExceptions(
          statusCode: CoreExceptions.badResponse,
          description: "badResponse",
          stackTrace: ex.stackTrace,
        );
      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 FLUSH ANALYTICS]");
    }
    throw CoreExceptions(
      statusCode: CoreExceptions.implementationError,
      description: "ERROR ON FLUSH ANALYTICS",
    );
  }
}