getApi method
Future<ActiveResponse>
getApi(
- Params params,
- RequestSetUp setUp, {
- String savedResponseName = '',
- bool saveResponse = false,
Implementation
Future<ActiveResponse> getApi(Params params, RequestSetUp setUp, {
String savedResponseName = '',
bool saveResponse = false,
}) async {
html.HttpRequest apiRequest = _httpClientSetup(setUp.idleTimeout, setUp.withTrustedRoots,
setUp.connectionTimeout, setUp.privateKeyPath, setUp.privateKeyPassword);
await html.HttpRequest.request(params.endpoint, method: 'GET', sendData: params.queryParameters)
.then((html.HttpRequest httpRequest) {
apiRequest = httpRequest;
});
ActiveResponse activeResponse = ActiveResponse(
statusCode: apiRequest.status ?? 404,
data: apiRequest.response,
errors: null,
endpoint: params.endpoint
);
if(setUp.logResponse == true) {
_logApiRequests(activeResponse);
}
if(saveResponse == true) {
savedResponseName = savedResponseName == '' ? params.endpoint : savedResponseName;
await _saveApiRequests(savedResponseName, activeResponse);
}
return activeResponse;
}