getBooks method

Future<BookQueryResult> getBooks(
  1. String query, {
  2. int page = 1,
  3. int pageSize = 20,
  4. int? year,
  5. int? edition,
  6. bool? shouldMatchAll,
  7. String? language,
  8. BookColumn? column,
  9. DateTime? publishedFrom,
  10. DateTime? publishedTo,
  11. List<String>? thema,
  12. @Deprecated('No longer supported by ISBNdb API contract.') int? offset,
})

Search books in ISBNdb.

ISBNdb rejects pageSize values greater than 100 with HTTP 400. thema accepts up to five codes, all of which must match, including narrower classifications. Searches using it return at most 1,000 books.

Implementation

Future<BookQueryResult> getBooks(
  String query, {
  int page = 1,
  int pageSize = 20,
  int? year,
  int? edition,
  bool? shouldMatchAll,
  String? language,
  BookColumn? column,
  DateTime? publishedFrom,
  DateTime? publishedTo,
  List<String>? thema,
  @Deprecated('No longer supported by ISBNdb API contract.') int? offset,
}) async {
  final path = "books/$query";
  final queryParameters = <String, Object?>{
    "page": page,
    "pageSize": pageSize,
    "year": year,
    "edition": edition,
    "shouldMatchAll": shouldMatchAll,
    "language": language,
    "column": column?.name,
    "publishedFrom": _formatQueryDate(publishedFrom),
    "publishedTo": _formatQueryDate(publishedTo),
    "thema": thema?.join(','),
  }..removeWhere((_, value) => value == null);

  final response = await _get(path, queryParameters: queryParameters);
  return _parseModel(
    method: "GET",
    path: path,
    parser: () => BookQueryResult.fromJson(response),
  );
}