demellor

GetUpdatedPackagesWithinDateRange .NET 11.35 Public Sandbox

0 votes

Using the code below I only get 1 package back, but I can tell I should be getting multiple packages with multiple senders based on the date range.  Can someone please tell me what I'm doing wrong?  I don't see it?  Thx       

 

static public readonly DateTime START_DATE = DateTime.Today.AddDays(-120); // DateTime.Now;
        static public readonly DateTime END_DATE = DateTime.Now;


        static private void GetLastUpdate()
        {
            EslClient eslClient = new EslClient(Program.apiKey, Program.apiUrl);
            //OneSpan Sample code - https://community.onespan.com/documentation/onespan-sign/guides/feature-guides/developer/retrieve-list-packages
            PageRequest pageRequest = new PageRequest(1, 100);
            bool hasNext = false;
            do
            {
                Page<DocumentPackage> resultPage = eslClient.PackageService.GetUpdatedPackagesWithinDateRange(DocumentPackageStatus.COMPLETED, new PageRequest(1), START_DATE, END_DATE);
                hasNext = resultPage.HasNextPage();
                pageRequest = pageRequest.Next;
                int i = 0;
                while (i < resultPage.Results.Count)
                {
                    Console.WriteLine("PkgID: " + resultPage.Results[i].Id + "  TransName: " + resultPage.Results[i].Name + "  Sender: " + resultPage.Results[i].SenderInfo.Email + "  Created: " + resultPage.Results[i].CreatedDate);
                    i++;
                }
            } while (hasNext);
        }

Richard DeMello


Reply to: GetUpdatedPackagesWithinDateRange .NET 11.35 Public Sandbox

0 votes

Any help would be appreciated

Richard DeMello


Reply to: GetUpdatedPackagesWithinDateRange .NET 11.35 Public Sandbox

0 votes

Hi Richard,

 

Package retrieval API/SDK function only returns packages created by the API Key holder, in order to retrieve all sender's packages, you'd:

With API Key:
(1)grab a list of senders with their IDs

(2)get sender API Keys per sender ID

GET /api/account/senders/{senderId}/apiKey

(3)create different EslClient objects with different API Keys

 

With API Token:
(1)create an API Token secret+id pair at your account (check my blog for detailed steps)

(2)get a sender email list

(3)create EslClient objects per sender email (internally use temporary API Token to validate the API calls):

String BASE_API_URL = "https://sandbox.esignlive.com";
String CLIENT_APP_ID = "your_client_id";
String CLIENT_APP_SECRET = "your_client_secret";
EslClient eslClient = new EslClient(ApiTokenConfig
            .newBuilder()
            .clientAppId(CLIENT_APP_ID)
            .clientAppSecret(CLIENT_APP_SECRET)
            .baseUrl(BASE_API_URL)
            .tokenType(TokenType.SENDER)
            .senderEmail("sender_email")    //no need to specify sender email if type is OWNER 
            .build()
        , BASE_API_URL + "/api", false, null, false, new HashMap<String, String>());

 

The #2 step of the first approach required a customized function invoking API call to retrieve API Key per sender ID. I can create some sample code for you if you preferred this way.

While the second approach with API Token is more SDK friendly.

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: GetUpdatedPackagesWithinDateRange .NET 11.35 Public Sandbox

0 votes

Hi Richard,

 

Give a second look to the code, it seems you didn't pass in the pageRequest created outside the loop:
Page<DocumentPackage> resultPage = eslClient.PackageService.GetUpdatedPackagesWithinDateRange(DocumentPackageStatus.COMPLETED, pageRequest, START_DATE, END_DATE);

You may get an infinite loop if you have more than 10 packages (default page size for "new PageRequest(1)" is 10), but it shouldn't cause the issue that only one package get returned.

Please be aware that reports pulls transactions under all senders, but the package retrieval API/SDK function only pulls transactions created by the API Key holder. Completion report has a main limitation that only 100 entities can be returned, therefore package retrieval API is suggested in order not to miss any packages.

 

Duo

 

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to:

0 votes

Maybe I'm going about this wrong?  I need to be able to pull a list of transactions (including PackageID) for ALL users for a given date range.  I need that for all Status (Complete, Draft, Trash, Archived, Inprocess) Is there a different report I should be using?

Richard DeMello


Reply to: GetUpdatedPackagesWithinDateRange .NET 11.35 Public Sandbox

0 votes

Hi Richard,

 

Do you mind sharing your account's email as well as the environment you are testing with to [email protected] so that I can check with support and know better about the structure of your account? In a nutshell, it's completely possible to pull ALL packages under ALL senders with ALL status for a given time range, with SDK. With enough information, I will create some working sample codes for you.

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: GetUpdatedPackagesWithinDateRange .NET 11.35 Public Sandbox

0 votes

Thanks for the information. I will check with support and reply back to you soon.

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


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