import 'package:dio/dio.dart';

class DioClient {
  final Dio dio;

  DioClient({required String baseUrl}): dio = Dio(BaseOptions(
    baseUrl: baseUrl,
    connectTimeout: const Duration(seconds: 5),
    receiveTimeout: const Duration(seconds: 120),
    // also accept 500 errors, since we cannot rule out that the server is at fault. We still want to gracefully handle these errors
    validateStatus: (status) => status! <= 500,
    receiveDataWhenStatusError: true,
    contentType: Headers.jsonContentType,
    responseType: ResponseType.json,
  ));
}
