removeTag method

  1. @override
Future<RequestResponse<String?>> removeTag({
  1. required String doctype,
  2. required String docName,
  3. required String tag,
})
override

Removes a tag from a document.

If the document is not tagged with the tag sent, it will silently return success.

Returns failure if the doctype or docname are invalid.

Implementation

@override
Future<RequestResponse<String?>> removeTag(
    {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.remove_tag'
        : 'frappe.desk.tags.remove_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(tag, rawResponse: response.rawResponse);
  } else {
    return RequestResponse.fail(handleError('remove_tag', response.error));
  }
}