searchIllust method

Future<SearchIllust> searchIllust(
  1. String word,
  2. SearchSort sort,
  3. SearchTarget target, {
  4. String? startDate,
  5. String? endDate,
  6. int? bookmarkTotal,
  7. required CancelToken cancelToken,
})

搜索
word - 关键字
sort - 排序(SearchSort)
target - 搜索目标(SearchTarget)
startDate - 开始时间(必须跟endDate一起填)
endDate - 结束时间(必须跟startDate一起填)
bookmarkTotal - 收藏数量 100, 250, 500, 1000, 5000, 7500 , 10000, 20000, 30000, 50000

Implementation

Future<SearchIllust> searchIllust(
  String word,
  SearchSort sort,
  SearchTarget target, {
  String? startDate,
  String? endDate,
  int? bookmarkTotal,
  required CancelToken cancelToken,
}) async {
  final response = await _httpClient.get<String>(
    '/v1/search/illust',
    queryParameters: {
      'filter': 'for_android',
      'include_translated_tag_results': true,
      'merge_plain_keyword_results': true,
      'word': null != bookmarkTotal ? '$word ${bookmarkTotal}users入り' : word,
      'sort': sort.toPixivStringParameter(),
      'search_target': target.toPixivStringParameter(),
      'start_date': startDate,
      'end_date': endDate,
    }..removeWhere((key, value) => null == value),
    cancelToken: cancelToken,
  );
  final data = SearchIllust.fromJson(jsonDecode(response.data!));
  return data;
}