getScanlationGroupResponse method

Future<Response> getScanlationGroupResponse({
  1. int? limit = 10,
  2. int? offset,
  3. List<String>? ids,
  4. String? name,
  5. LanguageCodes? focussedLanguage,
  6. List<String>? includes,
  7. Map<ScanlationOrders, OrderDirections>? order,
})
inherited

Endpoint used: GET /group

Search for a scanlation group with the name and returns limit number of results from offset which may focus on the given focussedLanguage and returns a http response.

Implementation

Future<http.Response> getScanlationGroupResponse({
  int? limit = 10,
  int? offset,
  List<String>? ids,
  String? name,
  LanguageCodes? focussedLanguage,
  List<String>? includes,
  Map<ScanlationOrders, OrderDirections>? order,
}) {
  var _limit = limit == null ? 'limit=10' : 'limit=$limit';
  var _offset = offset == null ? '' : '&offset=$offset';
  var _ids = '';
  if (ids != null) {
    ids.forEach((element) {
      _ids = _ids + '&ids[]=$element';
    });
  }
  var _name = name == null ? '' : '&name=$name';
  var _focussedLanguage = focussedLanguage == null
      ? ''
      : '&focussedLanguage=${EnumUtils.parseLanguageCodeFromEnum(focussedLanguage)}';
  var _includes = '';
  if (includes != null) {
    includes.forEach((element) {
      _includes = _includes + '&includes[]=$element';
    });
  }
  var _order = '';
  (order != null)
      ? order.entries.forEach((element) {
          _order = _order +
              '&order[${EnumUtils.parseScanlationOrderEnum(element.key)}]=${EnumUtils.parseOrderDirectionFromEnum(element.value)}';
        })
      : _order = '&order[latestUploadedChapter]=desc';

  var unenecodedPath = '/group';
  var uri =
      'https://$AUTHORITY$unenecodedPath?$_limit$_offset$_ids$_name$_focussedLanguage$_order';
  return http.get(Uri.parse(uri), headers: {
    HttpHeaders.contentTypeHeader: 'application/json',
  });
}