VotingEvent
public class VotingEvent : DALIEvent
Handles all voting communications
-
The configure the voting
Declaration
Swift
public private(set) var config: Config
-
Voting results have been released
Declaration
Swift
public private(set) var resultsReleased: Bool
-
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
-
Submit the given options as a vote
Declaration
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
-
Get the results of an event.
Declaration
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
Declaration
Swift
public func release(callback: @escaping DALIapi.SuccessCallback)
Parameters
callback
Function called when done
-
Adds an option to the event
Declaration
Swift
public func addOption(option: String, callback: @escaping DALIapi.SuccessCallback)
Parameters
option
The option to be added
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
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]>