getFieldsFromForm static method

Future<PcoCollection<PcoPeopleFormField>> getFieldsFromForm(
  1. String formId, {
  2. PcoPeopleFormFieldQuery? query,
  3. bool getAll = false,
  4. bool includeOptions = false,
})

Will get a PcoCollection of PcoPeopleFormField objects (expecting one) using a path like this: /people/v2/forms/$formId/fields

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<PcoPeopleFormField>> getFieldsFromForm(
  String formId, {
  PcoPeopleFormFieldQuery? query,
  bool getAll = false,
  bool includeOptions = false,
}) async {
  query ??= PcoPeopleFormFieldQuery();
  if (getAll) query.getAll = true;

  if (includeOptions) query.include.add('options');
  var url = '/people/v2/forms/$formId/fields';

  return PcoCollection.fromApiCall<PcoPeopleFormField>(url,
      query: query, apiVersion: kApiVersion);
}