ContactsController

public final class ContactsController

The contacts controller is responsible for managing contacts in the Harvest API. Contacts can be assosciated with clients

  • Creates a new contact 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

    clientIdentifier, firstName and lastName on the contact object as a minimum

    Declaration

    Swift

    public func create(contact: Contact, completionHandler: (requestError: NSError?) -> ())

    Parameters

    contact

    The new contact object to send to the API

    completionHandler

    The completion handler to return any errors to

  • Gets all contacts for the account of the authenticated user.

    Note

    The user must have access to the contacts on this account

    Declaration

    Swift

    public func getContacts(completionHandler: (contacts: [Contact]?, requestError: NSError?) -> ())

    Parameters

    completionHandler

    The completion handler to return contacts and errors to

  • Gets all contacts assosciated with a client by their identifier

    Note

    The user must have access to the contacts on this account

    Declaration

    Swift

    public func getContacts(clientIdentifier: Int, completionHandler: (contacts: [Contact]?, requestError: NSError?) -> ())

    Parameters

    clientIdentifier

    The unique identifier of the client to search for contacts for

    completionHandler

    The completion handler to return contacts and errors to

  • Gets all contacts assosciated with a client

    Note

    The user must have access to the contacts on this account

    Declaration

    Swift

    public func getContacts(client: Client, completionHandler: (contacts: [Contact]?, requestError: NSError?) -> ())

    Parameters

    clientIdentifier

    The unique identifier of the client to search for contacts for

    completionHandler

    The completion handler to return contacts and errors to

  • Gets a contact for a specific ID

    Declaration

    Swift

    public func getContact(identifier: Int, completionHandler: (contact: Contact?, requestError: NSError?) -> ())

    Parameters

    identifier

    The identifier for a contact

    completionHandler

    The completion handler to return the contact and errors to

  • Updates a contact. The contact must have an identifier to be updated. All other properties will be updated in the system except for creation and update date which are fixed.

    Declaration

    Swift

    public func update(contact: Contact, completionHandler: (requestError: NSError?) -> ())

    Parameters

    contact

    The contact to update. You may modify a contact returned from another request or create a new one that has a valid identifier

    completionHandler

    The completion handler to return request errors to

  • Deletes the given contact. Will return an error of 404 if the timer has already been deleted or is not valid

    Declaration

    Swift

    public func delete(contact: Contact, completionHandler: (requestError: NSError?) -> ())

    Parameters

    contact

    The contact to delete

    completionHandler

    The completion handler to return request errors to