setConfiguration static method
This methods sets a configuration state remotely to your account with the state provided.
Implementation
static Future<void> setConfiguration(
RolleeConnectConfig configuration) async {
final initialConfig = generateInitialConfig(config: configuration);
final params = {
...initialConfig.params.toMap(),
};
final keys = params.keys.toList();
final config = keys.fold<Map<String, dynamic>>({}, (acc, key) {
if (params[key] != null) {
acc[key] = params[key]!;
}
return acc;
});
try {
final madeUrl = makeURL(
type: RolleeUrlType.config,
isProduction: initialConfig.isProduction,
);
final response = await http.post(
Uri.parse(madeUrl),
headers: {
'Content-Type': 'application/json',
},
body: jsonEncode({"config": config}),
);
if (response.statusCode >= 200 && response.statusCode < 300) {
RolleeLogger.connectLog("Configuration updated successfully.");
} else {
RolleeLogger.connectLog("Configuration update failed.");
}
} catch (e) {
RolleeLogger.connectLog("Configuration update failed.");
}
}