callRestAPI static method
callRestAPI method to call REST API
Implementation
static Future<dynamic> callRestAPI({
required String endpoint,
required String method,
required IGraphQlClient graphClient,
Map<String, dynamic>? variables,
bool raw = false,
}) async {
final Response result = await graphClient.callRESTAPI(
endpoint: endpoint, method: method, variables: variables);
// returns the raw http response without preprocessing
if (raw) {
return result;
}
final Map<String, dynamic> body = graphClient.toMap(result);
if (graphClient.parseError(body) != null) {
return <String, dynamic>{'error': graphClient.parseError(body)};
} else {
return body;
}
}