getDocInfo method
Returns information about a document docname
of type doctype
defined by FrappeDocInfo.
Returns a failed RequestResponse in case the doctype
and/or docname
do not exist in the backend.
Implementation
@override
Future<RequestResponse<FrappeDocInfo?>> getDocInfo(
{required String? doctype, required String docname}) async {
final response = await Request.initiateRequest(
url: '${config.hostUrl}',
method: HttpMethod.GET,
contentType: ContentTypeLiterals.QUERY_STRING,
isFrappeResponse: false,
queryParams: <String, dynamic>{
'cmd': 'frappe.desk.form.load.get_docinfo',
'doctype': doctype,
'name': docname
});
if (response.isSuccess) {
final Map<String, dynamic>? result = response.data!.message;
if (result != null) {
return RequestResponse.success(
FrappeDocInfo.fromJson(result['docinfo']),
rawResponse: response.rawResponse);
} else {
response.isSuccess = false;
final error = ErrorDetail(
title: 'DocInfo Not Found',
info: Information(
data: response.data,
httpCode: response.httpCode,
));
return RequestResponse.fail(handleError('get_doc_info', error));
}
} else {
return RequestResponse.fail(handleError(
'get_doc_info', response.error ?? response.data as ErrorDetail?));
}
}