getSingleModelRest method
dynamic
getSingleModelRest({})
Implementation
getSingleModelRest({
required String serviceOrEntityName,
required String methodName,
required Types type,
String? body,
required Function(Map<String, dynamic> json) fromMap,
}) async {
String urlStr = Kinfolk.createRestUrl(serviceOrEntityName, methodName, type);
oauth2.Client? client = await Authorization().client;
Uri url = Uri.parse(urlStr);
var response;
if (body != null) {
response = await getPostResponse(url: url, body: body, client: client!);
} else {
response = await getGetResponse(url: url, client: client!);
}
var respBody = response.body;
if (respBody.runtimeType == String && respBody.isEmpty) return null;
var source = jsonDecode(respBody);
assert(source is Map, 'Response is ${source.toString()}');
return fromMap(source);
}