getMassiveActionParameters method Null safety
- GlpiItemType itemType,
- String massiveActionName
override
Show the awaitables parameters for a given massive action Warning: experimental endpoint, some required parameters may be missing from the returned content. Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-massive-action-parameters
Implementation
@override
Future<List<Map<String, String>>> getMassiveActionParameters(
GlpiItemType itemType, String massiveActionName) async {
if (sessionToken!.isEmpty) {
throw Exception('No session token, initSession first');
}
final Map<String, String> headers = {
'Session-Token': sessionToken!,
'Content-Type': 'application/json',
...?appToken != null ? {'App-Token': appToken!} : null,
};
final uri = Uri.parse(
'$host/getMassiveActionParameters/${itemType.toString().split('.').last}/$massiveActionName');
final response = await _innerClient.get(uri, headers: headers);
if (response.statusCode != 200 && response.statusCode != 207) {
throw GlpiException.fromResponse(
response.statusCode, json.decode(response.body));
}
List<dynamic> decodedJson = json.decode(response.body);
List<Map<String, String>> formatted = decodedJson.map((element) {
return element as Map<String, String>;
}).toList();
return Future.value(formatted);
}