29 lines
791 B
Dart
29 lines
791 B
Dart
import 'dart:convert';
|
|
|
|
import 'package:http/http.dart' as http;
|
|
|
|
import '../../../api_params.dart';
|
|
import '../get_poll/get_poll_state_response.dart';
|
|
import '../talk_api.dart';
|
|
|
|
/// Schließt eine Umfrage endgültig — nur Ersteller oder Moderatoren.
|
|
class ClosePoll extends TalkApi<GetPollStateResponse> {
|
|
ClosePoll({required String token, required int pollId})
|
|
: super('v1/poll/$token/$pollId', null);
|
|
|
|
@override
|
|
GetPollStateResponse assemble(String raw) {
|
|
final decoded = jsonDecode(raw) as Map<String, dynamic>;
|
|
return GetPollStateResponse.fromJson(
|
|
decoded['ocs'] as Map<String, dynamic>,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Future<http.Response> request(
|
|
Uri uri,
|
|
ApiParams? body,
|
|
Map<String, String>? headers,
|
|
) => http.delete(uri, headers: headers);
|
|
}
|