getSingleFromPerson static method

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

Will get a single PcoServicesPlanPerson object using a path like this: /services/v2/people/$personId/plan_people/[id]

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<PcoServicesPlanPerson?> getSingleFromPerson(
  String personId,
  String id, {
  PcoServicesPlanPersonQuery? query,
  bool includeAllRelated = false,
  bool includeDeclinedPlanTimes = false,
  bool includePerson = false,
  bool includePlan = false,
  bool includeTeam = false,
}) async {
  query ??= PcoServicesPlanPersonQuery();
  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/$id';
  var retval = await PcoCollection.fromApiCall<PcoServicesPlanPerson>(url,
      query: query, apiVersion: kApiVersion);
  return retval.items.isEmpty ? null : retval.items.first;
}