module BookingSync::API::Client::Contacts

Public Instance Methods

contact(contact, options = {}) click to toggle source

Get a single contact

@param contact [BookingSync::API::Resource|Integer] Contact or ID

of the contact.

@param options [Hash] A customizable set of query options. @option options [Array] fields: List of fields to be fetched. @return [BookingSync::API::Resource]

# File lib/bookingsync/api/client/contacts.rb, line 28
def contact(contact, options = {})
  get("contacts/#{contact}", options).pop
end
contacts(options = {}, &block) click to toggle source

List contacts

Returns contacts for the account user is authenticated with. @param options [Hash] A customizable set of options. @option options [Array] fields: List of fields to be fetched. @return [Array<BookingSync::API::Resource>] Array of contacts.

@example Get the list of contacts for the current account

contacts = @api.contacts
contacts.first.fullname # => "John Smith"

@example Get the list of contacts only with fullname and phone for smaller response

@api.contacts(fields: [:fullname, :phone])

@see developers.bookingsync.com/reference/endpoints/contacts/#list-contacts

# File lib/bookingsync/api/client/contacts.rb, line 17
def contacts(options = {}, &block)
  paginate :contacts, options, &block
end
create_contact(options = {}) click to toggle source

Create a new contact

@param options [Hash] Contact attributes @return [BookingSync::API::Resource] Newly created contact

# File lib/bookingsync/api/client/contacts.rb, line 36
def create_contact(options = {})
  post(:contacts, contacts: [options]).pop
end
delete_contact(contact) click to toggle source

Delete a contact

@param contact [BookingSync::API::Resource|Integer] Contact or ID

of the contact to be deleted.

@return [NilClass] Returns nil on success.

# File lib/bookingsync/api/client/contacts.rb, line 58
def delete_contact(contact)
  delete "contacts/#{contact}"
end
edit_contact(contact, options = {}) click to toggle source

Edit a contact

@param contact [BookingSync::API::Resource|Integer] Contact or ID of the contact

to be updated

@param options [Hash] Contact attributes to be updated @return [BookingSync::API::Resource] Updated contact on success, exception is raised otherwise @example

contact = @api.contacts.first
@api.edit_contact(contact, { fullname: "Gary Smith" })
# File lib/bookingsync/api/client/contacts.rb, line 49
def edit_contact(contact, options = {})
  put("contacts/#{contact}", contacts: [options]).pop
end