TimersController
public final class TimersController
Handles loading information about timers
-
Creates a new timer entry in the Harvest system. You may set projectIdentifier, taskIdentifier, notes and hours on the timer.
Requires
projectIdentifier
andtaskIdentifier
on the timer objectNote
If the timer does not have hours set then the API will start the timer running
Declaration
Swift
public func create(timer: Timer, completionHandler: (resultTimer: Timer?, requestError: NSError?) -> ())
Parameters
timer
The new timer object to send to the API
completionHandler
The completion handler to return the created timer object and errors to
-
Gets timers for a given user on a given day. If no user is specified, the authenticated user will be used. If no date is specified, today will be used
Declaration
Swift
public func getTimers(user: User?, date: NSDate?, completionHandler: (timers: [Timer?]?, requestError: NSError?) -> ())
Parameters
user
The user to look up the data for. If no user is specified, the authenticated user will be used
date
The date as an NSDate to return timers for. If no date is supplied today will be used instead
completionHandler
The completion handler to return timers and errors to
-
Gets timers for a given user for the current day. If no user is specified, the authenticated user will be used.
Declaration
Swift
public func getTimers(user: User?, completionHandler: (timers: [Timer?]?, requestError: NSError?) -> ())
Parameters
user
The user to look up the data for. If no user is specified, the authenticated user will be used
completionHandler
The completion handler to return timers and errors to
-
Gets timers for the authenticated user for the given day. If no day is specified, today will be used.
Declaration
Swift
public func getTimers(date: NSDate?, completionHandler: (timers: [Timer?]?, requestError: NSError?) -> ())
Parameters
date
THe date as an NSDate to return timers for. If no date is supplied today will be used instead
completionHandler
The completion handler to return timers and errors to
-
Gets timers for the authenticated user for the current day
Declaration
Swift
public func getTimers(completionHandler: (timers: [Timer?]?, requestError: NSError?) -> ())
Parameters
completionHandler
The completion handler to return timers and errors to
-
Gets a timer for a specific ID
Declaration
Swift
public func getTimer(identifier: Int, completionHandler: (timer: Timer?, requestError: NSError?) -> ())
Parameters
identifier
The identifier for a timer
completionHandler
The completion handler to return the timer and errors to
-
Toggles the given timer. If the timer is on, it will turn off, if it is off, it will turn on.
Note
if your account uses timestamp timers, timers cannot be restarted. Instead, a new timer will be created with the same project, task, and notes.
Declaration
Swift
public func toggle(timer: Timer?, completionHandler: (success: Bool?, updatedTimer: Timer?, requestError: NSError?) -> ())
Parameters
timer
The timer to toggle
completionHandler
The completion handler to return whether or not the toggle was successful, the updated timer and any request errors
-
Deletes the given timer. Will return an error of 404 if the timer has already been deleted or is not valid
Declaration
Swift
public func delete(timer: Timer?, completionHandler: (requestError: NSError?) -> ())
Parameters
timer
The timer to delete
completionHandler
The completion handler to return request errors to
-
Updates a timer. The timer must have an identifier to be updated. All other properties will be updated in the system.
Declaration
Swift
public func update(timer: Timer, completionHandler: (updatedTimer: Timer?, requestError: NSError?) -> ())
Parameters
timer
The timer to update. You may modify a timer returned from another request or create a new one that has a valid identifier
completionHandler
The completion handler to return request errors to as well as the updated timer