setFolderOption method
Set an option on a folder
folderId
is the id of the folder
option
is the option to be set, only one option can be set at a time
value
is the value of the option, the value will be not validated before sending the request
Implementation
Future<bool> setFolderOption(
String folderId, GoFileFolderOption option, String value) async {
if (folderId.isEmpty) {
throw ArgumentError('Folder id is empty');
}
if (token.isEmpty) {
throw ArgumentError('API key is empty');
}
final uri = Uri.parse('$baseUrl/setFolderOption');
final bodyFields = <String, String>{
'token': token,
'folderId': folderId,
'option': option.toString().split('.').last,
'value': value,
};
final response = await http.put(uri, body: bodyFields);
if (response.statusCode == 200) {
final goFileResponse =
GoFileResponse.fromJson(json.decode(response.body));
if (goFileResponse.status == 'ok') {
return true;
} else {
throw GoFileException.fromJson(json.decode(response.body));
}
} else {
throw Exception('Failed to set folder option');
}
}