Retrieving completed casefiles
Once you've sent out your casefiles, you'll probably want them back once they're signed. You'll want to limit them somehow, so you don't have to deal with the whole result set every time you check. Also, requests become really slow when there are more than 200 results.
You've got a couple options, depending on your volume:
- Get the latest files
This works well if you can be sure that you won't have more than 200 new completed casefiles between polling the api. - Get updates by date range
This will get you the same result set every time, which gives you 100% certainty that you didn't miss anything. You'll have to deal with the hassle of dates, though.
Strategy 1: Get latest completed casefiles
This is a simple request. Looks like this:
GET <<penneo_api_base_url>>/casefiles?sort=-completed&status=5&limit=200
var myCaseFiles = Query.FindBy<CaseFile>(
criteria: new Dictionary<string, object>{ { "status", 5 } },
orderBy: new Dictionary<string, string>(){ {"completed", "desc" } },
limit: 200
);
$myCaseFiles = CaseFile::findBy(
array('status' => 5),
array('completed' => 'desc'),
200
);
With status 5 being the "completed" state. Possible states are as follows:
new
pending
rejected
deleted
signed
completed
quarantined
failed
Strategy 2: Get documents in a date range
Pretty much same a above, but with unix timestamps to limit your result set.
GET <<penneo_api_base_url>>/casefiles?sort=-completed&status=5&completedAfter=1490000000&completedBefore=1500000000
var myCaseFiles = Query.FindBy<CaseFile>(
criteria: new Dictionary<string, object>{
{ "status", 5},
{ "completedAfter", new DateTime(2015,01, 01) },
{ "completedBefore", new DateTime(2016,01, 01) } },
orderBy: new Dictionary<string, string>(){ {"completed", "desc" } }
);
$myCaseFiles = CaseFile::findBy(
[
'status' => 5,
'completedAfter' => 1490000000,
'completedBefore' => 1500000000
],
[
'completed' => 'desc'
]
);
Make sure you define your date range so that you keep the result set low. If you're really cool, you'll set completedAfter to the max timestamp value of the casefiles already in your system, thus avoiding gaps and duplicates.
Strategy 3: Use webhooks
Get started here: Webhooks
Updated about 2 years ago