getChaptersResponse method

Future<Response> getChaptersResponse(
  1. String mangaId, {
  2. List<String>? ids,
  3. String? title,
  4. List<String>? groups,
  5. String? uploader,
  6. String? volume,
  7. String? chapter,
  8. List<LanguageCodes>? translatedLanguage,
  9. List<LanguageCodes>? originalLanguage,
  10. List<LanguageCodes>? excludedOriginalLanguage,
  11. List<ContentRating>? contentRating,
  12. String? createdAtSince,
  13. String? updatedAtSince,
  14. String? publishedAtSince,
  15. String? includes,
  16. Map<ChapterOrders, OrderDirections>? orders,
  17. int? limit,
  18. int? offset,
})
inherited

Endpoint used: GET /chapter

Returns the http response of a list of chapters for mangaId

Implementation

Future<http.Response> getChaptersResponse(
  String mangaId, {
  List<String>? ids,
  String? title,
  List<String>? groups,
  String? uploader,
  String? volume,
  String? chapter,
  List<LanguageCodes>? translatedLanguage,
  List<LanguageCodes>? originalLanguage,
  List<LanguageCodes>? excludedOriginalLanguage,
  List<ContentRating>? contentRating,
  String? createdAtSince,
  String? updatedAtSince,
  String? publishedAtSince,
  String? includes,
  Map<ChapterOrders, OrderDirections>? orders,
  int? limit,
  int? offset,
}) async {
  var unencodedPath = '/chapter';
  var _mangaId = mangaId;
  var _limit = limit != null ? '&limit=$limit' : '&limit=10';
  var _offset = offset != null ? '&offset=$offset' : '&offset=0';
  var _ids = '';
  if (ids != null) {
    ids.forEach((element) {
      _ids = _ids + '&ids[]=$element';
    });
  }
  var _title = title != null ? '&title=$title' : '';
  var _groups = '';
  if (groups != null) {
    groups.forEach((element) {
      _groups = _groups + '&groups[]=$element';
    });
  }
  var _uploader = uploader != null ? '&uploader=$uploader' : '';
  var _volume = volume != null ? '&volume=$volume' : '';
  var _chapter = chapter != null ? '&chapter=$chapter' : '';

  var _translatedLanguage = '';
  if (translatedLanguage != null) {
    translatedLanguage.forEach((element) {
      _translatedLanguage = _translatedLanguage +
          '&translatedLanguage[]=${EnumUtils.parseLanguageCodeFromEnum(element)}';
    });
  }
  var _originalLanguage = '';
  if (originalLanguage != null) {
    originalLanguage.forEach((element) {
      _originalLanguage = _originalLanguage +
          '&originalLanguage[]=${EnumUtils.parseLanguageCodeFromEnum(element)}';
    });
  }
  var _excludedOriginalLanguage = '';
  if (excludedOriginalLanguage != null) {
    excludedOriginalLanguage.forEach((element) {
      _excludedOriginalLanguage = _excludedOriginalLanguage +
          '&excludedOriginalLanguage[]=${EnumUtils.parseLanguageCodeFromEnum(element)}';
    });
  }
  var _contentrating = '';
  if (contentRating != null) {
    contentRating.forEach((element) {
      _contentrating = _contentrating +
          '&contentRating[]=${EnumUtils.parseContentRatingFromEnum(element)}';
    });
  }

  var _createdAtSince =
      createdAtSince != null ? '&createdAtSince=$createdAtSince' : '';
  var _updatedAtSince =
      updatedAtSince != null ? '&updatedAtSince=$updatedAtSince' : '';
  var _publishedAtSince =
      publishedAtSince != null ? '&publishedAtSince=$publishedAtSince' : '';
  var _includes = includes != null ? '&includes[]=$includes' : '';
  var _order = '';
  if (orders != null) {
    orders.entries.forEach((element) {
      _order = _order +
          '&order[${EnumUtils.parseChapterOrdersFromEnum(element.key)}]=${EnumUtils.parseOrderDirectionFromEnum(element.value)}';
    });
  }

  final url =
      'https://$AUTHORITY$unencodedPath?&manga=$_mangaId$_limit$_offset$_ids$_title$_groups$_uploader$_volume$_chapter$_translatedLanguage$_createdAtSince$_updatedAtSince$_publishedAtSince$_includes';
  var response = await http.get(Uri.parse(url),
      headers: {HttpHeaders.contentTypeHeader: 'application/json'});
  return response;
}