ClientsController
public final class ClientsController
The client controller is responsible for adding, deleting and updating client information with the Harvest API. This controller will only work if your account has the client module enabled
-
Creates a new client entry in the Harvest system. You may configure any of the parameters on the contact object you are creating and they will be saved.
Requires
name
on the client object as a minimumDeclaration
Swift
public func create(client: Client, completion: (error: ErrorType?) -> ())
Parameters
client
The new client object to send to the API
completion
The completion handler to return any errors to
-
Requests a specific client from the API by identifier
Declaration
Swift
public func get(clientIdentifier: Int, completion: (client: Client?, error: ErrorType?) -> ())
Parameters
clientIdentifier
The identifier of the client to look up in the system
-
Requests all clients in the system for this company
Declaration
Swift
public func getClients(completion: (clients: [Client]?, error: ErrorType?) -> ())
Parameters
completion
A closure to call with an optional array of
clients
and an optionalerror
-
Updates a client in the API. Any properties set on the client object will be sent to the server in an attempt to overwrite them. Not all properties are modifyable but Harvest does not make it clear which are so for now it will attempt all of them
Requires
identifier
on the client object as a minimumDeclaration
Swift
public func update(client: Client, completion: (error: ErrorType?) -> ())
Parameters
client
The client object to update
completion
The closure to call to return any errors to or indicate success
-
Deletes a client from the Harvest API.
Requires
identifier
on the client object as a minimumNote
You will not be able to delete a client if they have assosciated projects or invoicesDeclaration
Swift
public func delete(client: Client, completion: (error: ErrorType?) -> ())
Parameters
client
The client to delete in the API
completion
The closure to call with potential errors
-
Toggles the active status of a client.
Requires
identifier
on the client object as a minimumNote
You will not be able to toggle a client if they have active projectsDeclaration
Swift
public func toggle(client: Client, completion: (error: ErrorType?) -> ())
Parameters
client
The client to toggle the active status of in the API
completion
The closure to call with potential errors