getDefault method
Gets the value given the key
. Can specify the parent
if the key is duplicated under a different parent.
Returns the value within RequestResponse and since the data can be saved in multiple data forms the type is dynamic
.
If the key doesn't exist, data will be null
.
Throws NotLoggedInUser if the user is not logged in.
Implementation
@override
Future<RequestResponse<dynamic>> getDefault(
{required String key, String? parent = '__default'}) async {
await getFrappe().checkAppInstalled(features: ['getDefault']);
if (!config.coreInstance.auth.isLoggedIn) throw NotLoggedInUser();
if (_renovationCustomSettings.contains(key)) {
key = 'renovation:$key';
}
final response = await Request.initiateRequest(
url:
'${config.hostUrl}/api/method/renovation_core.utils.client.get_default',
method: HttpMethod.POST,
contentType: ContentTypeLiterals.APPLICATION_X_WWW_FORM_URLENCODED,
data: <String, dynamic>{'key': key, 'parent': parent});
if (response.isSuccess) {
return RequestResponse.success<dynamic>(response.data!.message,
rawResponse: response.rawResponse);
} else {
return RequestResponse.fail<dynamic>(handleError(null, response.error!));
}
}