summaryrefslogtreecommitdiff
path: root/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollResponseEvent.d.ts
blob: ad9e3b1dca798a3e8b1023cd2e786c853af21d12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { ExtensibleEvent } from "./ExtensibleEvent";
import { M_POLL_RESPONSE_EVENT_CONTENT } from "./poll_types";
import { IPartialEvent } from "../IPartialEvent";
import { PollStartEvent } from "./PollStartEvent";
import { EventType } from "../utility/events";
/**
 * Represents a poll response event.
 */
export declare class PollResponseEvent extends ExtensibleEvent<M_POLL_RESPONSE_EVENT_CONTENT> {
    private internalAnswerIds;
    private internalSpoiled;
    /**
     * The provided answers for the poll. Note that this may be falsy/unpredictable if
     * the `spoiled` property is true.
     */
    get answerIds(): string[];
    /**
     * The poll start event ID referenced by the response.
     */
    readonly pollEventId: string;
    /**
     * Whether the vote is spoiled.
     */
    get spoiled(): boolean;
    /**
     * Creates a new PollResponseEvent from a pure format. Note that the event is *not*
     * parsed here: it will be treated as a literal m.poll.response primary typed event.
     *
     * To validate the response against a poll, call `validateAgainst` after creation.
     * @param {IPartialEvent<M_POLL_RESPONSE_EVENT_CONTENT>} wireFormat The event.
     */
    constructor(wireFormat: IPartialEvent<M_POLL_RESPONSE_EVENT_CONTENT>);
    /**
     * Validates the poll response using the poll start event as a frame of reference. This
     * is used to determine if the vote is spoiled, whether the answers are valid, etc.
     * @param {PollStartEvent} poll The poll start event.
     */
    validateAgainst(poll: PollStartEvent): void;
    isEquivalentTo(primaryEventType: EventType): boolean;
    serialize(): IPartialEvent<object>;
    /**
     * Creates a new PollResponseEvent from a set of answers. To spoil the vote, pass an empty
     * answers array.
     * @param {string} answers The user's answers. Should be valid from a poll's answer IDs.
     * @param {string} pollEventId The poll start event ID.
     * @returns {PollStartEvent} The representative poll response event.
     */
    static from(answers: string[], pollEventId: string): PollResponseEvent;
}