31 lines
839 B
Dart
31 lines
839 B
Dart
import 'dart:convert';
|
|
import 'dart:developer';
|
|
|
|
import 'package:http/http.dart' as http;
|
|
import 'package:http/http.dart';
|
|
|
|
import '../getPoll/getPollStateResponse.dart';
|
|
import '../talkApi.dart';
|
|
import 'votePollParams.dart';
|
|
|
|
class VotePoll extends TalkApi {
|
|
String token;
|
|
int pollId;
|
|
VotePoll({required this.token, required this.pollId, required VotePollParams params}) : super('v1/poll/$token/$pollId', params);
|
|
|
|
@override
|
|
GetPollStateResponse assemble(String raw) {
|
|
log(raw);
|
|
return GetPollStateResponse.fromJson(jsonDecode(raw)['ocs']);
|
|
}
|
|
|
|
@override
|
|
Future<Response>? request(Uri uri, Object? body, Map<String, String>? headers) {
|
|
if(body is VotePollParams) {
|
|
log(body.toJson().toString());
|
|
return http.post(uri, headers: headers, body: body.toJson().toString());
|
|
}
|
|
return null;
|
|
}
|
|
}
|