Skip to content

Commit 1a51f24

Browse files
committed
Add topic poll vote endpoint
1 parent fe432d7 commit 1a51f24

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Modules/Sources/APIClient/APIClient.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public struct APIClient: Sendable {
6363
public var editPost: @Sendable (_ request: PostEditRequest) async throws -> PostSendResponse
6464
public var deletePosts: @Sendable (_ postIds: [Int]) async throws -> Bool
6565
public var postKarma: @Sendable (_ postId: Int, _ isUp: Bool) async throws -> Bool
66+
public var voteInTopicPoll: @Sendable (_ topicId: Int, _ selections: [[Int]]) async throws -> Bool
6667

6768
// Favorites
6869
public var getFavorites: @Sendable (_ request: FavoritesRequest, _ policy: CachePolicy) async throws -> AsyncThrowingStream<Favorite, any Error>
@@ -357,6 +358,13 @@ extension APIClient: DependencyKey {
357358
return status == 0
358359
},
359360

361+
voteInTopicPoll: { topicId, selections in
362+
let command = ForumCommand.Topic.Poll.vote(topicId: topicId, selections: selections)
363+
let response = try await api.send(command)
364+
let status = Int(response.getResponseStatus())!
365+
return status == 0
366+
},
367+
360368
// MARK: - Favorites
361369

362370
getFavorites: { request, policy in
@@ -570,6 +578,9 @@ extension APIClient: DependencyKey {
570578
postKarma: { _, _ in
571579
return true
572580
},
581+
voteInTopicPoll: { _, _ in
582+
return true
583+
},
573584
getFavorites: { _, _ in
574585
let (stream, continuation) = AsyncThrowingStream.makeStream(of: Favorite.self)
575586
continuation.yield(with: .success(.mock))

0 commit comments

Comments
 (0)