addTag method
Adds a tag to document docName
of a doctype
.
If the document is tagged with the same tag, it will silently return success.
Returns failure if the doctype or docname are invalid.
Implementation
@override
Future<RequestResponse<String?>> addTag(
{required String doctype,
required String docName,
required String tag}) async {
EmptyDoctypeError.verify(doctype);
EmptyDocNameError.verify(docName);
final args = {
'cmd': config.coreInstance.frappe.frappeVersion!.major == 12
? 'frappe.desk.doctype.tag.tag.add_tag'
: 'frappe.desk.tags.add_tag',
'dt': doctype,
'dn': docName,
'tag': tag
};
final response = await Request.initiateRequest(
url: config.hostUrl,
method: HttpMethod.POST,
contentType: ContentTypeLiterals.APPLICATION_JSON,
data: args);
if (response.isSuccess) {
return RequestResponse.success(response.data!.message,
rawResponse: response.rawResponse);
} else {
return RequestResponse.fail(handleError('add_tag', response.error));
}
}