call method

Implementation

Future<Http4Response> call() async {
  try {
    final response = await client.get(
      baseUrl,
      headers: headers,
      params: params,
    );

    client.close();

    return Http4Response(
      httpResponse: response,
      isSuccessed: true,
      isOkey: [200, 201, 202, 203, 204, 205, 206, 207]
          .contains(response.statusCode),
      decodedBody: jsonDecode(response.body),
    );
  } catch (exception) {
    if (Http4Config().debugMode) {
      debugPrint('\nHTTP4 Exception: ');
      debugPrint('Endpoint: (GET) $baseUrl');
      debugPrint('Exception: $exception');
      debugPrint('\n\n');
    }

    client.close();

    return Http4Response(
      httpResponse: null,
      isSuccessed: false,
      isOkey: false,
      decodedBody: null,
    );
  }
}