VotingEvent

public class VotingEvent : DALIEvent

Handles all voting communications

  • The configure the voting

    Declaration

    Swift

    public private(set) var config: Config
  • The options connected to the event

    Declaration

    Swift

    public private(set) var options: [DALIEvent.VotingEvent.Option]?
  • Voting results have been released

    Declaration

    Swift

    public private(set) var resultsReleased: Bool
  • An option that a user can vote for.

    See more

    Declaration

    Swift

    public struct Option
  • The configuration for voting events

    See more

    Declaration

    Swift

    public struct Config
  • Converts the data stored in the event into a JSON format that the API will understand

    Declaration

    Swift

    public override func json() -> JSON

    Return Value

    JSON data describing the event

  • Parses a JSON object. May return nil if this is not a voting event or if it fails

    Declaration

    Swift

    public override class func parse(_ object: JSON) -> VotingEvent?

    Parameters

    object

    The JSON object to parse

  • Get if the current device and user have already voted for this event

    Declaration

    Swift

    public func haveVoted(callback: @escaping (_ haveVoted: Bool, _ error: DALIError.General?) -> Void)

    Parameters

    callback

    Function called when done

    haveVoted

    Flag expressing if the user and device has voted already (default false)

    error

    The error encountered, if any

  • Get the public results for this event

    Declaration

    Swift

    public func getResults(callback: @escaping ([Option]?, DALIError.General?) -> Void)
  • Get all the options for this event

    Declaration

    Swift

    public func getOptions(callback: @escaping ([Option]?, DALIError.General?) -> Void)

    Parameters

    event

    Event to get the options for

  • Submit the given options as a vote

    Declaration

    Swift

    public func submitVote(options: [Option], callback: @escaping DALIapi.SuccessCallback)

    Parameters

    options

    The options to be submitted. If the voting event is ordered then they need to be in 1st, 2nd, 3rd, …, nth choice order

    callback

    Function to be called when done

  • Save the awards given to the given options

    Admin only

    Declaration

    Swift

    public func saveResults(options: [Option], callback: @escaping DALIapi.SuccessCallback)

    Parameters

    options

    The options to save

    callback

    Function called when done

  • Get the results of an event.

    Admin only

    Declaration

    Swift

    public func getUnreleasedResults(callback: @escaping (_ results: [Option]?, _ error: DALIError.General?) -> Void)

    Parameters

    event

    Event to get the events of

    callback

    Function to be called when done

    results

    The results requested

    error

    Error encountered (if any)

  • Releases the results

    Admin only

    Declaration

    Swift

    public func release(callback: @escaping DALIapi.SuccessCallback)

    Parameters

    callback

    Function called when done

  • Adds an option to the event

    Admin only

    Declaration

    Swift

    public func addOption(option: String, callback: @escaping DALIapi.SuccessCallback)

    Parameters

    option

    The option to be added

    callback

    Function called when done

  • Removes the given option from the list of options

    Admin only

    Declaration

    Swift

    public func removeOption(option: Option, callback: @escaping DALIapi.SuccessCallback)

    Parameters

    option

    The option to remove

    callback

    Function called when done

  • Get the current voting event

    Declaration

    Swift

    public static func getCurrent(callback: @escaping (_ events: [VotingEvent], _ error: DALIError.General?) -> Void)

    Parameters

    callback

    Function called when done

    event

    Event found (if any)

    error

    Error encountered (if any)

  • Get all events that have results released

    Declaration

    Swift

    public static func getReleasedEvents(callback: @escaping (_ events: [VotingEvent]?, _ error: DALIError.General?) -> Void)

    Parameters

    callback

    Function called when done

    events

    List of events retrieved

    error

    Error encountered (if any)

  • Get voting events as an admin. The signed in user must be an admin, otherwise will exit immediately

    Admin only

    Declaration

    Swift

    public static func get(callback: @escaping (_ events: [VotingEvent]?, _ error: DALIError.General?) -> Void)

    Parameters

    callback

    Function called when done

    events

    List of events retrieved

    error

    Error encountered (if any)

  • Undocumented

    Declaration

    Swift

    public static func observe() -> Event<[VotingEvent]>