searchAvatars method

Future<Response<List<Avatar>>> searchAvatars({
  1. bool? featured,
  2. SortOption? sort,
  3. String? user,
  4. String? userId,
  5. int? n = 60,
  6. OrderOption? order,
  7. int? offset,
  8. String? tag,
  9. String? notag,
  10. ReleaseStatus? releaseStatus,
  11. String? maxUnityVersion,
  12. String? minUnityVersion,
  13. String? platform,
  14. CancelToken? cancelToken,
  15. Map<String, dynamic>? headers,
  16. Map<String, dynamic>? extra,
  17. ValidateStatus? validateStatus,
  18. ProgressCallback? onSendProgress,
  19. ProgressCallback? onReceiveProgress,
})

Search Avatars Search and list avatars by query filters. You can only search your own or featured avatars. It is not possible as a normal user to search other peoples avatars.

Parameters:

  • featured - Filters on featured results.
  • sort - The sort order of the results.
  • user - Set to me for searching own avatars.
  • userId - Filter by UserID.
  • n - The number of objects to return.
  • order - Result ordering
  • offset - A zero-based offset from the default object sorting from where search results start.
  • tag - Tags to include (comma-separated). Any of the tags needs to be present.
  • notag - Tags to exclude (comma-separated).
  • releaseStatus - Filter by ReleaseStatus.
  • maxUnityVersion - The maximum Unity version supported by the asset.
  • minUnityVersion - The minimum Unity version supported by the asset.
  • platform - The platform the asset supports.
  • cancelToken - A CancelToken that can be used to cancel the operation
  • headers - Can be used to add additional headers to the request
  • extras - Can be used to add flags to the request
  • validateStatus - A ValidateStatus callback that can be used to determine request success based on the HTTP status of the response
  • onSendProgress - A ProgressCallback that can be used to get the send progress
  • onReceiveProgress - A ProgressCallback that can be used to get the receive progress

Returns a Future containing a Response with a List<Avatar> as data Throws DioException if API call or serialization fails

Implementation

Future<Response<List<Avatar>>> searchAvatars({
  bool? featured,
  SortOption? sort,
  String? user,
  String? userId,
  int? n = 60,
  OrderOption? order,
  int? offset,
  String? tag,
  String? notag,
  ReleaseStatus? releaseStatus,
  String? maxUnityVersion,
  String? minUnityVersion,
  String? platform,
  CancelToken? cancelToken,
  Map<String, dynamic>? headers,
  Map<String, dynamic>? extra,
  ValidateStatus? validateStatus,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) async {
  final _path = r'/avatars';
  final _options = Options(
    method: r'GET',
    headers: <String, dynamic>{
      ...?headers,
    },
    extra: <String, dynamic>{
      'secure': <Map<String, String>>[
        {
          'type': 'apiKey',
          'name': 'authCookie',
          'keyName': 'auth',
          'where': '',
        },
      ],
      ...?extra,
    },
    validateStatus: validateStatus,
  );

  final _queryParameters = <String, dynamic>{
    if (featured != null) r'featured': featured,
    if (sort != null) r'sort': sort,
    if (user != null) r'user': user,
    if (userId != null) r'userId': userId,
    if (n != null) r'n': n,
    if (order != null) r'order': order,
    if (offset != null) r'offset': offset,
    if (tag != null) r'tag': tag,
    if (notag != null) r'notag': notag,
    if (releaseStatus != null) r'releaseStatus': releaseStatus,
    if (maxUnityVersion != null) r'maxUnityVersion': maxUnityVersion,
    if (minUnityVersion != null) r'minUnityVersion': minUnityVersion,
    if (platform != null) r'platform': platform,
  };

  final _response = await _dio.request<Object>(
    _path,
    options: _options,
    queryParameters: _queryParameters,
    cancelToken: cancelToken,
    onSendProgress: onSendProgress,
    onReceiveProgress: onReceiveProgress,
  );

  List<Avatar>? _responseData;

  try {
    final rawData = _response.data;
    _responseData = rawData == null
        ? null
        : deserialize<List<Avatar>, Avatar>(rawData, 'List<Avatar>',
            growable: true);
  } catch (error, stackTrace) {
    throw DioException(
      requestOptions: _response.requestOptions,
      response: _response,
      type: DioExceptionType.unknown,
      error: error,
      stackTrace: stackTrace,
    );
  }

  return Response<List<Avatar>>(
    data: _responseData,
    headers: _response.headers,
    isRedirect: _response.isRedirect,
    requestOptions: _response.requestOptions,
    redirects: _response.redirects,
    statusCode: _response.statusCode,
    statusMessage: _response.statusMessage,
    extra: _response.extra,
  );
}