Cardholder Tardiness Report

The windows client currently grabs all people and then checks against the events in the database to see when/if the person signed in for the day selected. The person is shown if they signed in after the time or have been found to have never signed in for the day and time in question. The filter and processing are shown in the C# example as that is the language I am most familiar with. The calls to the api are shown in all languages.

Example in C#

var currentInstance  = await client.GetCurrentInstanceAsync();
var app = (await client.GetAppsAsync(currentInstance)).Where(a=> a.ApiKey == "MercuryService").FirstOrDefault(); 
var eventAccessGrantedKey = (await client.GetEventTypesAsync(app)).Where(a=> a.CommonName == "Access Granted").FirstOrDefault()?.Key;
var eventAccessDeniedKey = (await client.GetEventTypesAsync(app)).Where(a=> a.CommonName == "Access Denied").FirstOrDefault()?.Key;
var peopleList = new List<PersonInfo>();
var peopleCount = 1000;
var page = 0;
//The call to get all the people the instance
while(peopleCount==1000)
{
	var people = (await client.SearchAsync(currentInstance, "type:Person", page++, peopleCount, includeChildFolders:true, spanScope:false)).OfType<PersonInfo>();
		peopleCount = people.Count();
	if (peopleCount>0)
	{
		peopleList.AddRange(people);
	}
}

var eventList = new List<EventMessageData>();
var eventCount = 1000;
var eventPage = 0;
//The call to get all the events of interest in the instance
while(eventCount==1000)
{
	var eventMessageData = await client.GetEventsAsync(currentInstance, 
		eventPage++, 
		eventCount, 
		includeSubFolders:false, 
		includeSharedInstances:false,
		spanScope:false, 
		requiresAck:false, 
		startingOn: DateTime.Today, 
		endingOn: DateTime.Today.AddDays(1).AddTicks(-1), 
		priorityThreshold: 0, 
		forKeys: new[] {eventAccessGrantedKey, eventAccessDeniedKey}
	);
		
	eventCount = eventMessageData.Count();
	if (eventCount>0)
	{
		eventList.AddRange(eventMessageData);
	}
}

var PersonAndEvent = new List<Tuple<PersonInfo,EventMessageData>>();

foreach(var person in peopleList)
{
	var firstEvent = eventList.Where(e=>e.ObjectLinks.Any(l=> l.LinkedObjectKey == person.Key && l.Relation =="Person")).OrderBy(e=> e.OccurredOn).FirstOrDefault();
	firstEvent.Dump();
	if(firstEvent?.OccurredOn > DateTime.Today.AddHours(8).AddMinutes(45))
		PersonAndEvent.Add(new Tuple<PersonInfo,EventMessageData>(person,firstEvent));
	else
		PersonAndEvent.Add(new Tuple<PersonInfo,EventMessageData>(person,null));
}

Example in CURL

#The Call to get all People
curl -X GET \
  'https://keepapi.feenicshosting.com/api/f/INSTANCE_KEY_HERE?q=type%3APerson&page=0&pageSize=1000&includeChildFolders=True&spanScope=False' \
  -H 'Accept: */*' \
  -H 'Authorization: Bearer TOKEN_GOES_HERE \
  -H 'Connection: keep-alive' \
  -H 'Host: keepapi.feenicshosting.com' \
  -H 'accept-encoding: gzip, deflate' \
  -H 'cache-control: no-cache'

#The Call to get the events of interest
curl -X GET \
  'https://keepapi.feenicshosting.com/api/f/INSTANCE_KEY_HERE/events?page=0&pageSize=1000&includeSubFolders=False&includeSharedInstances=False&spanScope=False&requiresAck=False&startingOn=2019-06-27T04%3A00%3A00z&endingOn=2019-06-28T03%3A59%3A59z&priorityThreshold=0&forKeys=EVENT_ACCESS_GRANTED_KEY,EVENT_ACCESS_DENIED_KEY%20' \
  -H 'Accept: */*' \
  -H 'Authorization: Bearer TOKEN_GOES_HERE'  \
  -H 'Connection: keep-alive' \
  -H 'Host: keepapi.feenicshosting.com' \
  -H 'accept-encoding: gzip, deflate' \
  -H 'cache-control: no-cache'