stuladhar | Posts: 27

Download the completed package

0 votes
I have seen the example of GetCompletedPackagesWithinDateRangeExample.cs in github from the following link https://github.com/eSignLive/esl.sdk.net/blob/master/sdk/SDK.Examples/src/GetCompletedPackagesWithinDateRangeExample.cs I have seen the following lines of code completedPackages = getPackagesByPackageStatus(DocumentPackageStatus.COMPLETED, START_DATE, END_DATE); What will be next step in order to download all the documents inside of that package? Can this be done using one your .Net SDKs. Thanks, Sumit

Approved Answer
mwilliams | Posts: 957

Reply to: Download the completed package

0 votes
This code will download all documents within the last 30 days:
EslClient eslClient = new EslClient(apiKey, apiUrl);

            Page CompletedPackagePage = eslClient.PackageService.GetUpdatedPackagesWithinDateRange(DocumentPackageStatus.COMPLETED, new PageRequest(1, 50), DateTime.Now.AddDays(-30), DateTime.Now);
            int completedPackagesInRange = CompletedPackagePage.TotalElements;
            int currentPackage = 1;
            while (currentPackage = completedPackagesInRange)
            {
                foreach (DocumentPackage docPackage in CompletedPackagePage)
                {
                    PackageId packageId = docPackage.Id;
                    foreach (Document mydoc in docPackage.Documents)
                    {
                        string DocumentId = mydoc.Id;
                        byte[] myDocument = eslClient.DownloadDocument(packageId, DocumentId);
                        
                        //TO DO: Do something with the document
                    }
                }
                currentPackage++;
                CompletedPackagePage = eslClient.PackageService.GetUpdatedPackagesWithinDateRange(DocumentPackageStatus.COMPLETED, new PageRequest(currentPackage, 50), DateTime.Now.AddDays(-30), DateTime.Now);
            }
In the TO DO section, you'd just need to save the document bytes to file somewhere. Hopefully this gives you all you need. Let me know.

mwilliams | Posts: 957

Reply to: Download the completed package

0 votes
Hey Sumit, You would just need to step through each package on each page and download the documents. This can be done by downloading each document individually from the package or by downloading the zip file with all documents in it. I can find/create you an example. Just let me know how you'd like to download them.

stuladhar | Posts: 27

Reply to: Download the completed package

0 votes
Hi Williams, Thanks for the reply. I would like to download each document individually in a pdf format. Can you please give me a full sample for this example. The code after completedPackages = getPackagesByPackageStatus(DocumentPackageStatus.COMPLETED, START_DATE, END_DATE); How do we download the documents from the object completedPackages? -Sumit

mwilliams | Posts: 957

Reply to: Download the completed package

0 votes
Okay. I'll get something to you, today (on this and your other question). :)

stuladhar | Posts: 27

Reply to: Download the completed package

0 votes
Thanks Williams for the reply. I have tried your code an it worked. Thanks, Sumit

mnascimento | Posts: 2

Reply to: Download the completed package

0 votes

Would like assistance to download all of our packages organized by user packages. I am not an API expert, please provide or direct me on how to start this process, leaning towards automating the packages download once a week if possible to google drive if not then provide alternatives.

 

Thank you,

 

Marclem Nascimento


Duo_Liang | Posts: 3776

Reply to: Download the completed package

0 votes

Hi Marclem,

 

Are you developing with .Net or any other programming language? And per your description "download packages organized by user", do you refer to the "senders" under your main account? Despite of these questions, below are the common steps to download all packages under an account:

(1)get all senders' IDs by their email:

you'd pull all the senders under the account, step through the list and match the email with their sender ID. (guide here)

GET /api/account/senders?from=1&to=100

This function is available for both SDK and API

(2)get each sender's API Key:

For each sender, get their API Key by using sender ID, this step is only available via API (guide here):

GET /api/account/senders/{senderId}/apiKey
(3)get the latest updated packages in a time range, per sender API Key:

Build different EslClient objects switching to sender's API Key, with corresponding parameters(guide here)

GET /api/packages?query={status}&from={from}&to={to}&lastUpdatedStartDate={lastUpdatedStartDate}&lastUpdatedEndDate={lastUpdatedEndDate}

This function is available for both SDK and API

 (4)OneSpan Sign doesn't offer integration to download to Google Drive directly, you'd download the byte array first, then push to Google Drive using Google's integrations.

 

Duo


mnascimento | Posts: 2

Reply to:

0 votes

Hi Duo Liang,

 

Thank you for the reply.

 

Your question "Are you developing with .Net or any other programming language?" I am not a programmer so I need assistance what to use (easier to setup) and how to setup.

Your other question: "And per your description "download packages organized by user", do you refer to the "senders" under your main account? " Would like to download all packages created by all users exporting them by user packages (right now we have 2 instances).

 

Thanks,

Marc Nascimento

 


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