fetchWantedPersons function

Future<WantedPersonResultSet> fetchWantedPersons({
  1. int pageSize = 50,
  2. int page = 1,
  3. WantedPersonSortOn sortOn = WantedPersonSortOn.modified,
  4. WantedPersonSortDirection sortDirection = WantedPersonSortDirection.descending,
  5. String? title,
  6. List<String>? fieldOffices,
  7. WantedPersonClassification? personClassification,
  8. WantedPosterClassification? posterClassification,
  9. WantedPersonStatus? status,
})

Fetches wanted persons with the given parameters.

pageSize is the number of items to return per page. The FBI API does not specify a maximum value, but it appears to be 50.

page is the page number to return.

sortOn is the field to sort on. Note: The FBI API does not specify this, but it appears WantedPersonSortOn.publication is deprecated.

sortDirection is the direction to sort in.

title is the title of the wanted person.

fieldOffices is the field offices involved in the case.

personClassification is the roll of the wanted person (suspect, victim, etc.).

posterClassification is the type of wanted person (individual, group, etc.).

Implementation

Future<WantedPersonResultSet> fetchWantedPersons({
  int pageSize = 50,
  int page = 1,
  WantedPersonSortOn sortOn = WantedPersonSortOn.modified,
  WantedPersonSortDirection sortDirection =
      WantedPersonSortDirection.descending,
  String? title,
  List<String>? fieldOffices,
  WantedPersonClassification? personClassification,
  WantedPosterClassification? posterClassification,
  WantedPersonStatus? status,
}) async {
  final StringBuffer fieldOfficesBuffer = StringBuffer();

  String? fieldOfficesString;

  if (fieldOffices != null && fieldOffices.isNotEmpty) {
    fieldOfficesBuffer.writeAll(fieldOffices, ',');
    fieldOfficesString = fieldOfficesBuffer.toString();
  }

  return await WantedPersonService.fetchWantedPersons(
    pageSize: pageSize,
    page: page,
    sortOn: sortOn.value,
    sortOrder: sortDirection.value,
    title: title,
    fieldOffices: fieldOfficesString,
    personClassification: personClassification?.value,
    posterClassification: posterClassification?.value,
    status: status?.value,
  );
}