feat: create vote (#871)

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
dom
2025-07-04 22:10:11 +08:00
committed by GitHub
parent 9ce84fb997
commit 83459df3b7
18 changed files with 800 additions and 67 deletions

View File

@@ -510,4 +510,30 @@ class DynamicsHttp {
return Error(res.data['message']);
}
}
static Future<LoadingState<int?>> createVote(VoteInfo voteInfo) async {
final res = await Request().post(
Api.createVote,
queryParameters: {'csrf': Accounts.main.csrf},
data: {'vote_info': voteInfo.toJson()},
);
if (res.data['code'] == 0) {
return Success(res.data['data']?['vote_id']);
} else {
return Error(res.data['message']);
}
}
static Future<LoadingState<int?>> updateVote(VoteInfo voteInfo) async {
final res = await Request().post(
Api.updateVote,
queryParameters: {'csrf': Accounts.main.csrf},
data: {'vote_info': voteInfo.toJson()},
);
if (res.data['code'] == 0) {
return Success(res.data['data']?['vote_id']);
} else {
return Error(res.data['message']);
}
}
}