getFeatureStates method

Future<ApiResponse> getFeatureStates(
  1. List<String> apiKey, {
  2. Options? options,
  3. String? contextSha,
})

Implementation

Future<ApiResponse> getFeatureStates(List<String> apiKey,
    {Options? options, String? contextSha}) async {
  // create path and map variables
  final __path = '/features/';

  // query params
  final queryParams = <QueryParam>[];
  final headerParams = <String, String>{}
    ..addAll(options?.headers?.cast<String, String>() ?? {});
  if (!headerParams.containsKey('Accept')) {
    // we only want to accept this format as we can parse it
    headerParams['Accept'] = 'application/json';
  }

  queryParams.addAll(convertParametersForCollectionFormat(
      (p) => LocalApiClient.parameterToString(p)!,
      'multi',
      'apiKey',
      apiKey));
  if (contextSha != null) {
    queryParams.addAll(convertParametersForCollectionFormat(
        (p) => LocalApiClient.parameterToString(p)!,
        '',
        'contextSha',
        contextSha));
  }

  final authNames = <String>[];
  final opt = options ?? Options();

  final contentTypes = [];

  if (contentTypes.isNotEmpty && headerParams['Content-Type'] == null) {
    headerParams['Content-Type'] = contentTypes[0];
  }

  headerParams
      .removeWhere((key, value) => value.isEmpty); // remove empty headers
  opt.headers = headerParams;
  opt.method = 'GET';

  return await apiClient.invokeAPI(__path, queryParams, null, authNames, opt);
}