fetchRelatedCollection method

Future<CollectionFetched> fetchRelatedCollection(
  1. String type,
  2. String id,
  3. String relationship, {
  4. Map<String, String> headers = const {},
  5. Map<String, String> page = const {},
  6. Map<String, String> filter = const {},
  7. Iterable<String> include = const [],
  8. Iterable<String> sort = const [],
  9. Map<String, Iterable<String>> fields = const {},
  10. Map<String, String> query = const {},
})

Fetches a related resource collection identified by type, id, relationship.

Optional arguments:

  • headers - any extra HTTP headers
  • query - any extra query parameters
  • page - pagination options
  • filter - filtering options
  • include - request to include related resources
  • sort - collection sorting options
  • fields - sparse fields options

Implementation

Future<CollectionFetched> fetchRelatedCollection(
  String type,
  String id,
  String relationship, {
  Map<String, String> headers = const {},
  Map<String, String> page = const {},
  Map<String, String> filter = const {},
  Iterable<String> include = const [],
  Iterable<String> sort = const [],
  Map<String, Iterable<String>> fields = const {},
  Map<String, String> query = const {},
}) async {
  final response = await send(
      baseUri.related(type, id, relationship),
      Request.get()
        ..headers.addAll(headers)
        ..query.addAll(query)
        ..page(page)
        ..filter(filter)
        ..include(include)
        ..sort(sort)
        ..fields(fields));
  return CollectionFetched(
      response.http, response.document ?? (throw FormatException()));
}