queryReport method
Future<ProfitAndLoss>
queryReport({
- required ProfitAndLossQuery query,
- String? realmId,
- String? authToken,
Returns the report for the query
Implementation
Future<ProfitAndLoss> queryReport({
required ProfitAndLossQuery query,
String? realmId,
String? authToken,
}) async {
authToken ??= authenticationService.getCachedToken()?.access_token;
realmId ??= authenticationService.getCachedRealmId();
Map<String, String> headers = {
"Authorization": "Bearer ${authToken ?? ""}",
//'Content-Type': 'application/json; charset=UTF-8',
'Accept': 'application/json',
};
Map<String, String> params = {
"minorversion": minorVersion.toString()
}..addAll(query.toJson().map((key, value) => MapEntry(key, value.toString())));
Uri endpoint = Uri.https(
baseUrl, "/v3/company/$realmId/reports/ProfitAndLoss", params);
//print (endpoint.toString());
var response = await
http.get(endpoint, headers: headers);
if (response.statusCode == 200) {
//print (jsonDecode(response.body));
return ProfitAndLoss.fromJson(jsonDecode(response.body));
}
else {
throw ProfitAndLossException(statusCode: response.statusCode, message: response.body);
}
}