getBook method

Future<Book?> getBook(
  1. String isbn, {
  2. bool withPrices = false,
})

Get book details from an ISBN

Implementation

Future<Book?> getBook(String isbn, {bool withPrices = false}) async {
  final path = "book/$isbn";
  final response = await _get(
    path,
    queryParameters: <String, Object?>{"with_prices": withPrices},
  );
  final bookJson = response['book'];
  if (bookJson == null) {
    return null;
  }
  if (bookJson is! Map<String, dynamic>) {
    throw ISBNdbException(
      message: "Received an unexpected data format from API server",
      method: "GET",
      path: path,
    );
  }
  return _parseModel(
    method: "GET",
    path: path,
    parser: () => Book.fromJson(bookJson),
  );
}