Fiona | Posts: 9

Get all Trashed packages

0 votes
Is there a way to retrieve a list of packages in the Trash folder using Java SDK? I understand Trashed is a property not a package status. But I need to purge all packages that are trashed. Getting a completion report on the package status such as Completed, Archived, Declined, etc does not return packages where trashed=true.

Duo_Liang | Posts: 3776

Reply to: Get all Trashed packages

0 votes
Hi Fiona, I don't think it's a function provided by SDK, but there's do have a query parameter to search for trashed packages in REST API: GET /api/packages?query=trashed And I can definitely create some sample codes for you by making REST calls. I will post in this thread within few minutes. Hope this could help! Duo

Duo_Liang | Posts: 3776

Reply to: Get all Trashed packages

0 votes
Here you go. If you don't need to detailed information of your trashed packages, you don't need to convert the JSON back to Object but read data directly from JSON. Duo

Attachments
asimao | Posts: 15

Reply to: Get all Trashed packages

0 votes

Hello Duo_Liang.

Im interested on getting the transactions trashed on the account (from all users) and runned into this post.

When I use the eslClient.ReportService.DownloadCompletionReport I iterate throw all senders and get all the packages, execept the the TRASHED. 

I thought that this post was the answer, but according to the script you shared, doing the "REST API: GET /api/packages?query=trashed" I only getting the packages from the administrator. How can I get all trashed packages from all users using the REST API?

 

Thanks in advanced.

 


Duo_Liang | Posts: 3776

Reply to:

0 votes

Hi Asimao,

 

If you are currently using completion report function and be aware that the Completion Report can at most return 100 packages within the time range, there's an easier way to get all trashed packages.

Although "Trashed" is not a package status, it's listed as a valid parameter value in the Completion Report API:

10-2-1

 

And below code allows you to create a custom status Enumeration (although the function has been deprecated and not suggested to be used):

        PackageStatus trashed = PackageStatus.UNRECOGNIZED("trashed");
        
        ......
        
        // Download the completion report for all senders
        CompletionReport sdkCompletionReport = eslClient.getReportService().downloadCompletionReport(trashed, from, to);
    

 

A more thorough solution is to use package retrieval API instead. But as you've mentioned, it only returns packages created by the API Key holder. So you need to first retrieve API Keys of each senders, then retrieve their respective trashed packages. I've open sourced my Package Download and Export Tool where you can find the relevant code sample there. Let me know if you need further assistant to go down this path.

 

Duo


asimao | Posts: 15

Reply to: Get all Trashed packages

0 votes

Hello, thanks for the reply      

"A more thorough solution is to use package retrieval API instead. But as you've mentioned, it only returns packages created by the API Key holder. So you need to first retrieve API Keys of each senders, then retrieve their respective trashed packages...."

Not a solution having to retrieve API Keys of each senders.

The completionReport solution you recomended, seemed more friendly.  I know trashed is a attribute and not a Status, but for CompletionReport effects I think is the best aproach, getting all transactions form all senders.

So the aproach

"PackageStatus trashed = PackageStatus.UNRECOGNIZED("trashed");
             
        // Download the completion report for all senders
        CompletionReport sdkCompletionReport = eslClient.getReportService().downloadCompletionReport(trashed, from, to);

"

seem to be the best but Im not getting the PackageStatus.UNRECOGNIZED("trashed"); using C# and SDK (11.23.0.0).

Can you help?

 


Duo_Liang | Posts: 3776

Reply to:

0 votes

 .NET SDK doesn't expose the function to initialize a customized package status instance, so I guess reflection has to be used here:

 

        public static T Construct<T>(Type[] paramTypes, object[] paramValues)
        {
            Type t = typeof(T);

            ConstructorInfo ci = t.GetConstructor(
                BindingFlags.Instance | BindingFlags.NonPublic,
                null, paramTypes, null);

            return (T)ci.Invoke(paramValues);
        }

 

          Type[] paramTypes = new Type[] { typeof(string), typeof(string), typeof(int) };
            object[] paramValues = new object[] { "trashed", "trashed", 7 };
            DocumentPackageStatus trashed = Construct<DocumentPackageStatus>(paramTypes, paramValues);

 

I found the sample code from this StackOverflow post and it works well at my side.

The source code of DocumentPackageStatus class can be found here.

 

Duo


asimao | Posts: 15

Reply to:

0 votes

Thanks a lot Duo Liang!

It worked.

About the limitations of 100 transactions in DownloadCompletionReport, I read in a post of Fev2019 (https://community.onespan.com/forum/retrieve-completion-list-limitation) that you answered 

"Hi guys, "The limitation of return 100 results" exists on all GET requests querying list from OneSpan Sign, it's due to the internal workings of OSS. In future, there'll be a new report API returning summary data of more than 100 results, which will be the best solution to this post"

Is there any date planned for the vew report API with more then 100 results?

 

 

 

 

 

 


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off