urlRequest static method
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 lastUriPart = apiUrl.split('/').last;
final needsParamSpecifier = !lastUriPart.contains('?');
apiUrl =
'$apiUrl${needsParamSpecifier ? '?' : ''}${asQueryParams(params)}';
}
final makeRequest = callType == ApiCallType.GET ? http.get : http.delete;
final response =
await makeRequest(Uri.parse(apiUrl), headers: toStringMap(headers));
return ApiCallResponse.fromHttpResponse(response, returnBody, decodeUtf8);
}