searchResponse method
Future<Response>
searchResponse({
- String? title,
- int? limit,
- int? offset,
- List<
String> ? authors, - List<
String> ? artists, - int? year,
- List<
String> ? includedTags, - TagsMode? includedTagsMode,
- List<
String> ? excludedTags, - TagsMode? excludedTagsMode,
- List<
MangaStatus> ? status, - List<
LanguageCodes> ? originalLanguage, - List<
LanguageCodes> ? excludedOriginalLanguages, - List<
LanguageCodes> ? availableTranslatedLanguage, - List<
PublicDemographic> ? publicationDemographic, - List<
String> ? ids, - List<
ContentRating> ? contentRating, - String? createdAtSince,
- String? updatedAtSince,
- List<
String> ? includes, - String? group,
- Map<
SearchOrders, OrderDirections> ? orders, - bool? hasAvailableChapters,
inherited
Endpoint used: GET /manga
Gets manga search results
takes in optional parameters to filter out content
and returns the query data in a Search
class instance
Implementation
Future<http.Response> searchResponse({
String? title,
int? limit,
int? offset,
List<String>? authors,
List<String>? artists,
int? year,
List<String>? includedTags,
TagsMode? includedTagsMode,
List<String>? excludedTags,
TagsMode? excludedTagsMode,
List<MangaStatus>? status,
List<LanguageCodes>? originalLanguage,
List<LanguageCodes>? excludedOriginalLanguages,
List<LanguageCodes>? availableTranslatedLanguage,
List<PublicDemographic>? publicationDemographic,
List<String>? ids,
List<ContentRating>? contentRating,
String? createdAtSince,
String? updatedAtSince,
List<String>? includes,
String? group,
Map<SearchOrders, OrderDirections>? orders,
bool? hasAvailableChapters,
}) async {
var unencodedPath = '/manga';
var _title = title != null ? '&title=$title' : '';
var _authors = '';
if (authors != null) {
authors.forEach((element) {
_authors = _authors + '&authors[]=$element';
});
}
var _limit = limit != null ? '&limit=$limit' : '';
var _offset = offset != null ? '&offset=$offset' : '';
var _artists = '';
if (artists != null) {
artists.forEach((element) {
_artists = _artists + '&artists[]=$element';
});
}
var _year = year != null ? '&year=$year' : '';
var _includedTags = '';
if (includedTags != null) {
includedTags.forEach((element) {
_includedTags = _includedTags + '&includedTags[]=$element';
});
}
var _publicationDemographic = '';
if (publicationDemographic != null) {
publicationDemographic.forEach((element) {
_publicationDemographic = _publicationDemographic +
'&publicationDemographic[]=${EnumUtils.parsePublicDemographicFromEnum(element)}';
});
}
var _includedTagsMode = '';
if (includedTagsMode != null) {
_includedTagsMode = EnumUtils.parseTagModeFromEnum(includedTagsMode);
}
var _excludedTags = '';
if (excludedTags != null) {
excludedTags.forEach((element) {
_excludedTags = _excludedTags + '&excludedTags[]=$element';
});
}
var _excludedTagsMode = '';
if (excludedTagsMode != null) {
_excludedTagsMode = EnumUtils.parseTagModeFromEnum(excludedTagsMode);
}
var _status = '';
if (status != null) {
status.forEach((element) {
_status = _status +
'&status[]=${EnumUtils.parseMangaStatusFromEnum(element)}';
});
}
var _originalLanguage = '';
if (originalLanguage != null) {
originalLanguage.forEach((element) {
_originalLanguage = _originalLanguage +
'&originalLanguage[]=${EnumUtils.parseLanguageCodeFromEnum(element)}';
});
}
var _excludedOriginalLanguage = '';
if (excludedOriginalLanguages != null) {
excludedOriginalLanguages.forEach((element) {
_excludedOriginalLanguage = _excludedOriginalLanguage +
'&excludedOriginalLanguage[]=${EnumUtils.parseLanguageCodeFromEnum(element)}';
});
}
var _availableTranslatedLanguage = '';
if (availableTranslatedLanguage != null) {
availableTranslatedLanguage.forEach((element) {
_availableTranslatedLanguage = _availableTranslatedLanguage +
'&availableTranslatedLanguage[]=${EnumUtils.parseLanguageCodeFromEnum(element)}';
});
}
var _ids = '';
if (ids != null) {
ids.forEach((element) {
_ids = _ids + '&ids[]=$element';
});
}
var _contentRating = '';
if (contentRating != null) {
contentRating.forEach((element) {
_contentRating = _contentRating +
'&contentRating[]=${EnumUtils.parseContentRatingFromEnum(element)}';
});
}
var _includes = '';
if (includes != null) {
includes.forEach((element) {
_includes = _includes + '&includes[]=$element';
});
}
var _createdAtSince =
createdAtSince != null ? '&createdAtSince=$createdAtSince' : '';
var _updatedAtSince =
updatedAtSince != null ? '&updatedAtSince=$updatedAtSince' : '';
var _group = group != null ? '&group=$group' : '';
var _order = '';
if (orders != null) {
orders.entries.forEach((element) {
_order = _order +
'&order[${EnumUtils.parseSearchOrdersFromEnum(element.key)}]=${EnumUtils.parseOrderDirectionFromEnum(element.value)}';
});
} else {
_order = '&order[latestUploadedChapter]=desc';
}
final url =
'https://$AUTHORITY$unencodedPath?$_title$_limit$_offset$_authors$_artists$_year$_includedTags$_includedTagsMode$_excludedTags$_excludedTagsMode$_status$_originalLanguage$_excludedOriginalLanguage$_availableTranslatedLanguage$_publicationDemographic$_ids$_contentRating$_createdAtSince$_updatedAtSince$_includes$_group$_order';
var httpResponse = await http.get(Uri.parse(url),
headers: {HttpHeaders.contentTypeHeader: 'application/json'});
return httpResponse;
}