jhullin | Posts: 20

Querying for Packages Recently Completed, Expired, Etc.

0 votes
I need to query for packages that changed status (e.g. completed, expired, opted out, sent) within a given time frame. For example, I may want to query for all packages that expired since yesterday, regardless of when the package was created. The Completion Report doesn't satisfy this because the filter dates seem to apply to the date a package was created. Is there a Java SDK or REST API method to support this?

Approved Answer
harishaidary | Posts: 1812

Reply to: Querying for Packages Recently Completed, Expired, Etc.

0 votes
The only workaround I would have for you is to use the sample code above and set START_DATE to something like the last 30 days (or more). This way, you would be able to determine the status of each package in the last 30 days.

harishaidary | Posts: 1812

Reply to: Querying for Packages Recently Completed, Expired, Etc.

0 votes
Here is a sample code on how to retrieve package statuses in a give date range:
public class StatusPackage {
	
	static String API_KEY = "your_api_key";
	static String url = "https://sandbox.esignlive.com/api";
	static EslClient eslClient = new EslClient( API_KEY, url );
	
	public static void main(String[] args) {
		
		Calendar cal = Calendar.getInstance();
		cal.add(Calendar.DATE, -10);
		
		final Date START_DATE = cal.getTime();
	    final Date END_DATE = new DateTime().toDate();
	    int record = 1;
	    int j = 1;
	
	    Page completedPackages;
	    
        completedPackages = getPackagesByPackageStatus(PackageStatus.COMPLETED, START_DATE, END_DATE, record);    
        
        while (record = completedPackages.getTotalElements()){
        	Iterator index = completedPackages.iterator();
        	//Number of completed packages in current page. I set mine to display 10 packages at a time a the bottom (e.g. new PageRequest(i, 10))
        	System.out.println("COMPLETED Packages in page " + j);
        	while (index.hasNext()){
        		DocumentPackage myPackage = index.next();
        		//Do what you want here with the current package (e.g. get packageId etc...)
        		System.out.println(myPackage.getId());
        		record++;
        	}
        	 //make another call from new page start point
        	j++;
            completedPackages = getPackagesByPackageStatus(PackageStatus.COMPLETED, START_DATE, END_DATE, record);
        }
	}
	
	private static Page getPackagesByPackageStatus(PackageStatus packageStatus, Date startDate, Date endDate, int i) {
		
		Page resultPage = eslClient.getPackageService().getUpdatedPackagesWithinDateRange(packageStatus, new PageRequest(i, 5), startDate, endDate);
        return resultPage;
    }
}
You can do the same for DRAFT, EXPIRED, SENT, DECLINED, and ARCHIVED packages. Let me know if it works for you :)

jhullin | Posts: 20

Reply to: Querying for Packages Recently Completed, Expired, Etc.

0 votes
I've tried this service as well. Again, the dates seem to apply to when the package was created and not when the status was updated. For example, querying for EXPIRED packages from '12/07/2015' would return packages that were created on 12/07 and expired on 12/10. It would not return packages that were created on 12/03 and expired on 12/07, and this is the kind of query I need to perform. In this example, I'd like to know what packages expired on 12/07, regardless of when those packages were created.

harishaidary | Posts: 1812

Reply to: Querying for Packages Recently Completed, Expired, Etc.

0 votes
If I understand correctly, you want to know what packages were in COMPLETED, DRAFT, SENT, etc. for a specific day regardless of when the updates happened?

jhullin | Posts: 20

Reply to: Querying for Packages Recently Completed, Expired, Etc.

0 votes
No, I want to know what packages were updated to COMPLETED, DRAFT, SENT, etc. on a specific day, regardless of when those packages were created. A simple use-case is querying for all packages that EXPIRED yesterday. "getUpdatedPackagesWithinDateRange" sounds like it would do what I want, but it doesn't in practice.

jhullin | Posts: 20

Reply to: Querying for Packages Recently Completed, Expired, Etc.

0 votes
Can I assume there is nothing in your API to support this need? Or is the “getUpdatedPackagesWithinDateRange” method just not working properly?

harishaidary | Posts: 1812

Reply to: Querying for Packages Recently Completed, Expired, Etc.

0 votes
Unfortunately, our api doesn't support this at the moment. I do apologize for the inconvenience.

jhullin | Posts: 20

Reply to: Querying for Packages Recently Completed, Expired, Etc.

0 votes
That's too bad. Is there a way, instead, to query for all packages currently in a given status? It'd essentially be something like the CompletionReport but without filtering by date. For example, I want to query for all packages currently in status SENT.

jhullin | Posts: 20

Reply to: Querying for Packages Recently Completed, Expired, Etc.

0 votes
That's the best I could come up with as well. Thanks.

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