getFromPerson static method

Future<PcoCollection<PcoCheckInsPersonEvent>> getFromPerson(
  1. String personId, {
  2. String? id,
  3. PcoCheckInsPersonEventQuery? query,
  4. bool getAll = false,
  5. bool includeAllRelated = false,
  6. bool includeEvent = false,
  7. bool includeFirstCheckIn = false,
  8. bool includeLastCheckIn = false,
  9. bool includePerson = false,
})

Will get a PcoCollection of PcoCheckInsPersonEvent objects (expecting many) using a path like this: /check-ins/v2/people/$personId/person_events

Getting a PcoCollection is useful even when retrieving a single object because it contains error data and helper functions.

Additional options may be specified by using the query argument, but some query options are also available as boolean flags in this function call too.

Implementation

static Future<PcoCollection<PcoCheckInsPersonEvent>> getFromPerson(
  String personId, {
  String? id,
  PcoCheckInsPersonEventQuery? query,
  bool getAll = false,
  bool includeAllRelated = false,
  bool includeEvent = false,
  bool includeFirstCheckIn = false,
  bool includeLastCheckIn = false,
  bool includePerson = false,
}) async {
  query ??= PcoCheckInsPersonEventQuery();
  if (getAll) query.getAll = true;
  if (includeAllRelated)
    query.include.addAll(PcoCheckInsPersonEvent.canInclude);
  if (includeEvent) query.include.add('event');
  if (includeFirstCheckIn) query.include.add('first_check_in');
  if (includeLastCheckIn) query.include.add('last_check_in');
  if (includePerson) query.include.add('person');
  var url = '/check-ins/v2/people/$personId/person_events';
  if (id != null) url += '/$id';
  return PcoCollection.fromApiCall<PcoCheckInsPersonEvent>(url,
      query: query, apiVersion: kApiVersion);
}