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. @Deprecated('No longer supported by ISBNdb API contract.') int? offset,
})

Search books in ISBNdb

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,
  @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),
  }..removeWhere((_, value) => value == null);

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