getSingleFromServiceTypeAndPlan static method

Future<PcoServicesLive?> getSingleFromServiceTypeAndPlan(
  1. String serviceTypeId,
  2. String planId,
  3. String id, {
  4. PcoServicesLiveQuery? query,
  5. bool includeAllRelated = false,
  6. bool includeController = false,
  7. bool includeCurrentItemTime = false,
  8. bool includeItems = false,
  9. bool includeNextItemTime = false,
  10. bool includeServiceType = false,
})

Will get a single PcoServicesLive object using a path like this: /services/v2/service_types/$serviceTypeId/plans/$planId/live/[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<PcoServicesLive?> getSingleFromServiceTypeAndPlan(
  String serviceTypeId,
  String planId,
  String id, {
  PcoServicesLiveQuery? query,
  bool includeAllRelated = false,
  bool includeController = false,
  bool includeCurrentItemTime = false,
  bool includeItems = false,
  bool includeNextItemTime = false,
  bool includeServiceType = false,
}) async {
  query ??= PcoServicesLiveQuery();
  if (includeAllRelated) query.include.addAll(PcoServicesLive.canInclude);
  if (includeController) query.include.add('controller');
  if (includeCurrentItemTime) query.include.add('current_item_time');
  if (includeItems) query.include.add('items');
  if (includeNextItemTime) query.include.add('next_item_time');
  if (includeServiceType) query.include.add('service_type');
  var url =
      '/services/v2/service_types/$serviceTypeId/plans/$planId/live/$id';
  var retval = await PcoCollection.fromApiCall<PcoServicesLive>(url,
      query: query, apiVersion: kApiVersion);
  return retval.items.isEmpty ? null : retval.items.first;
}