setFeatureState method
Future<ApiResponse>
setFeatureState(
- String sdkUrl,
- String featureKey,
- FeatureStateUpdate featureStateUpdate, {
- Options? options,
Implementation
Future<ApiResponse> setFeatureState(
String sdkUrl, String featureKey, FeatureStateUpdate featureStateUpdate,
{Options? options}) async {
Object postBody = featureStateUpdate;
// create path and map variables
final __path = '/features/{sdkUrl}/{featureKey}'
.replaceAll(
'{' + 'sdkUrl' + '}', LocalApiClient.parameterToString(sdkUrl)!)
.replaceAll('{' + 'featureKey' + '}',
LocalApiClient.parameterToString(featureKey)!);
// 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';
}
final authNames = <String>[];
final opt = options ?? Options();
final contentTypes = ['application/json'];
if (contentTypes.isNotEmpty && headerParams['Content-Type'] == null) {
headerParams['Content-Type'] = contentTypes[0];
}
postBody = LocalApiClient.serialize(postBody);
headerParams
.removeWhere((key, value) => value.isEmpty); // remove empty headers
opt.headers = headerParams;
opt.method = 'PUT';
return await apiClient.invokeAPI(
__path, queryParams, postBody, authNames, opt);
}