findFlags method

Future<Response<List<Flag>>> findFlags (
  1. {int limit,
  2. bool enabled,
  3. String description,
  4. String descriptionLike,
  5. String key,
  6. int offset,
  7. bool preload,
  8. CancelToken cancelToken,
  9. Map<String, String> headers}
)

Implementation

Future<Response<List<Flag>>> findFlags({
  int limit,
  bool enabled,
  String description,
  String descriptionLike,
  String key,
  int offset,
  bool preload,
  CancelToken cancelToken,
  Map<String, String> headers,
}) async {
  String _path = "/flags";

  Map<String, dynamic> queryParams = {};
  Map<String, String> headerParams = Map.from(headers ?? {});
  dynamic bodyData;

  queryParams[r'limit'] = limit;
  queryParams[r'enabled'] = enabled;
  queryParams[r'description'] = description;
  queryParams[r'description_like'] = descriptionLike;
  queryParams[r'key'] = key;
  queryParams[r'offset'] = offset;
  queryParams[r'preload'] = preload;
  queryParams.removeWhere((key, value) => value == null);
  headerParams.removeWhere((key, value) => value == null);

  List<String> contentTypes = [];

  return _dio
      .request(
    _path,
    queryParameters: queryParams,
    data: bodyData,
    options: Options(
      method: 'get'.toUpperCase(),
      headers: headerParams,
      extra: {
        'secure': [],
      },
      contentType:
          contentTypes.isNotEmpty ? contentTypes[0] : "application/json",
    ),
    cancelToken: cancelToken,
  )
      .then((response) {
    final FullType type =
        const FullType(BuiltList, const [const FullType(Flag)]);
    BuiltList<Flag> dataList = _serializers.deserialize(
        response.data is String ? jsonDecode(response.data) : response.data,
        specifiedType: type);
    var data = dataList.toList();

    return Response<List<Flag>>(
      data: data,
      headers: response.headers,
      request: response.request,
      redirects: response.redirects,
      statusCode: response.statusCode,
      statusMessage: response.statusMessage,
      extra: response.extra,
    );
  });
}