delete method
Executes a HTTP DELETE request for the given apiPath.
Supports an optional request body and JSON encoding.
Implementation
Future<Response?> delete(String apiPath, {Object? body, bool jsonEncodeBody = true}) async {
Object? requestBody = body;
if (jsonEncodeBody && body != null) {
requestBody = jsonEncode(body);
}
Uri apiUri = _generateApiUri(apiPath);
return _processApiCall(
apiPath: apiPath,
httpApiConfig.maxRetryAttempts,
apiCall: () async {
return await httpClient
.delete(apiUri, encoding: httpApiConfig.encoding, body: requestBody, headers: httpApiConfig.headers)
.timeout(
Duration(seconds: httpApiConfig.timeout),
onTimeout: () => throw Exception("API Timeout exception, no response from the server for: $apiPath"),
);
},
);
}