Poll

public final class Poll: NSObject, Codable
extension Poll: Mappable
extension Poll: Serializable

Represents a poll that users can vote

Since

4.1.0
  • Poll ID

    Declaration

    Swift

    public let pollId: Int64
  • Title of this poll

    Declaration

    Swift

    public internal(set) var title: String
  • Timestamp when poll was created

    Declaration

    Swift

    public let createdAt: Int64
  • Timestamp when poll was changed

    Declaration

    Swift

    public internal(set) var updatedAt: Int64
  • Timestamp when poll was closed

    Declaration

    Swift

    public internal(set) var closeAt: Int64
  • Poll status

    Declaration

    Swift

    public internal(set) var status: PollStatus
  • Message ID of the message associated with poll

    Declaration

    Swift

    public let messageId: Int64
  • Poll data. currently only text is provided

    Declaration

    Swift

    public let data: PollData?
  • Number of users voted this poll

    Declaration

    Swift

    public internal(set) var voterCount: Int64
  • Poll’s Options

    Declaration

    Swift

    public internal(set) var options: [PollOption]
  • The name of the user who created the poll

    Declaration

    Swift

    public let createdBy: String?
  • If set to true, the poll allows user-suggested options. Default is false.

    Declaration

    Swift

    public internal(set) var allowUserSuggestion: Bool
  • If set to true, voting items can be added. Default is false

    Declaration

    Swift

    public internal(set) var allowMultipleVotes: Bool
  • An array of ids of the option to vote for. Even if it’s a single choice, it must be included in the array.

    Declaration

    Swift

    public internal(set) var votedPollOptionIds: [Int64]
  • Encodes this object.

    Declaration

    Swift

    public func encode(to encoder: Encoder) throws

    Parameters

    encoder

    Encoder instance

  • Default constructor.

    Declaration

    Swift

    public required init(from decoder: Decoder) throws

    Parameters

    decoder

    Decoder instance

  • Creates a poll with given params.

    Declaration

    Swift

    public static func create(
        params: PollCreateParams,
        completionHandler: @escaping PollHandler
    )

    Parameters

    params

    PollCreateParams instance.

    completionHandler

    completion block.

  • Gets a poll.

    Declaration

    Swift

    public static func get(
        params: PollRetrievalParams,
        completionHandler: @escaping PollHandler
    )

    Parameters

    params
    completionHandler

    completion block.

  • Initialize with json dictionary

    Declaration

    Swift

    public func initWithDictionary(_ json: [String: Any]) -> Self?
  • Converts the object into dictionary

    Declaration

    Swift

    public func _toDictionary() -> [String: Any]
  • Compares this object with given other object.

    Declaration

    Swift

    public override func isEqual(_ object: Any?) -> Bool

    Parameters

    object

    Any instance

    Return Value

    true if same otherwise false

  • Serializes this object into data.

    Declaration

    Swift

    public func serialize() -> Data?

    Return Value

    optional Data instance

  • Deserializes and reconstructs the object.

    Declaration

    Swift

    public static func build(fromSerializedData data: Data?) -> Self?

    Parameters

    data

    Data instance

    Return Value

    Poll if parameter is valid, otherwise nil