urlRequest static method

Future<ApiCallResponse> urlRequest(
  1. ApiCallType callType,
  2. String apiUrl,
  3. Map<String, dynamic> headers,
  4. Map<String, dynamic> params,
  5. bool returnBody,
  6. bool decodeUtf8,
)

Implementation

static Future<ApiCallResponse> urlRequest(
  ApiCallType callType,
  String apiUrl,
  Map<String, dynamic> headers,
  Map<String, dynamic> params,
  bool returnBody,
  bool decodeUtf8,
) async {
  if (params.isNotEmpty) {
    final specifier = Uri.parse(apiUrl).queryParameters.isNotEmpty ? '&' : '?';
    apiUrl = '$apiUrl$specifier${asQueryParams(params)}';
  }
  final makeRequest = callType == ApiCallType.GET ? http.get : http.delete;
  final response = await makeRequest(
    Uri.parse(apiUrl),
    headers: toStringMap(headers),
  ).timeout(_effectiveTimeout);
  return ApiCallResponse.fromHttpResponse(response, returnBody, decodeUtf8);
}