applyMassiveActions method Null safety
- GlpiItemType itemType,
- String massiveActionName,
- String payload
override
Run the given massive action
payload
Must be a json string with the parameters for the action and the ids of the items to apply the action to.
Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#apply-massive-action
Implementation
@override
Future<Map<String, dynamic>> applyMassiveActions(
GlpiItemType itemType, String massiveActionName, String payload) 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/applyMassiveActions/${itemType.toString().split('.').last}/$massiveActionName');
final response =
await _innerClient.post(uri, headers: headers, body: payload);
if (response.statusCode != 200 && response.statusCode != 207) {
throw GlpiException.fromResponse(
response.statusCode, json.decode(response.body));
}
Map<String, dynamic> decodedJson = json.decode(response.body);
return Future.value(decodedJson);
}