getFromPerson static method

Future<PcoCollection<PcoServicesPlanPerson>> getFromPerson(
  1. String personId, {
  2. String? id,
  3. PcoServicesPlanPersonQuery? query,
  4. bool getAll = false,
  5. bool includeAllRelated = false,
  6. bool includeDeclinedPlanTimes = false,
  7. bool includePerson = false,
  8. bool includePlan = false,
  9. bool includeTeam = false,
})

Will get a PcoCollection of PcoServicesPlanPerson objects (expecting many) using a path like this: /services/v2/people/$personId/plan_people

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<PcoServicesPlanPerson>> getFromPerson(
  String personId, {
  String? id,
  PcoServicesPlanPersonQuery? query,
  bool getAll = false,
  bool includeAllRelated = false,
  bool includeDeclinedPlanTimes = false,
  bool includePerson = false,
  bool includePlan = false,
  bool includeTeam = false,
}) async {
  query ??= PcoServicesPlanPersonQuery();
  if (getAll) query.getAll = true;
  if (includeAllRelated)
    query.include.addAll(PcoServicesPlanPerson.canInclude);
  if (includeDeclinedPlanTimes) query.include.add('declined_plan_times');
  if (includePerson) query.include.add('person');
  if (includePlan) query.include.add('plan');
  if (includeTeam) query.include.add('team');
  var url = '/services/v2/people/$personId/plan_people';
  if (id != null) url += '/$id';
  return PcoCollection.fromApiCall<PcoServicesPlanPerson>(url,
      query: query, apiVersion: kApiVersion);
}