toggleVote

suspend fun toggleVote(featureRequestId: String, userToken: String): VoteResult(source)

Toggles an upvote on a feature request via POST /api/v1/feature-requests/{id}/vote.

If the user has not voted yet, a vote is added; if they have already voted, their vote is removed. Returns the reconciled server vote state for optimistic UI synchronization.

Return

VoteResult containing the updated vote state (voted) and current total count (voteCount).

Parameters

featureRequestId

Unique ID of the target FeatureRequestItem.

userToken

Stable anonymous user token from UserTokenStore.

Throws

if anonymous voting is disallowed (HTTP 401).

on network or parsing failure.

Example:

val result = client.toggleVote(featureRequestId = "req_123", userToken = userToken)
println("Voted: ${result.voted}, New total: ${result.voteCount}")