getDocsAssignedToUser method

  1. @override
Future<RequestResponse<List<GetDocsAssignedToUserResponse>?>> getDocsAssignedToUser({
  1. required String assignedTo,
  2. String? doctype,
  3. Status? status,
})
override

Returns the list of documents assigned to a user.

Optionally can filter the list by specifying doctype and status.

Implementation

@override
Future<RequestResponse<List<GetDocsAssignedToUserResponse>?>>
    getDocsAssignedToUser(
        {required String assignedTo, String? doctype, Status? status}) async {
  await getFrappe().checkAppInstalled(features: ['getDocsAssignedToUser']);

  final args = GetDocsAssignedToUserParams(
      assignedTo: assignedTo, doctype: doctype, status: status)
    ..cmd = 'renovation_core.utils.assign_doc.getDocsAssignedToUser';

  final response = await Request.initiateRequest(
      url: config.hostUrl,
      method: HttpMethod.POST,
      contentType: ContentTypeLiterals.APPLICATION_JSON,
      data: args.toJson());
  if (response.isSuccess) {
    List result = response.data!.message;

    return RequestResponse.success(
        result.isNotEmpty
            ? GetDocsAssignedToUserResponse().deserializeList(result)
            : [],
        rawResponse: response.rawResponse);
  } else {
    return RequestResponse.fail(
        handleError('get_docs_assigned_to_user', response.error));
  }
}