Module: BookingSync::API::Client::Clients

Included in:
BookingSync::API::Client
Defined in:
lib/bookingsync/api/client/clients.rb

Instance Method Summary collapse

Instance Method Details

#clients(options = {}, &block) ⇒ Array<BookingSync::API::Resource>

List clients

Returns clients for the account user is authenticated with.

Examples:

Get the list of clients for the current account

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

Get the list of clients only with fullname and phone for smaller response

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

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • fields: (Array)

    List of fields to be fetched.

Returns:

See Also:



17
18
19
# File 'lib/bookingsync/api/client/clients.rb', line 17

def clients(options = {}, &block)
  paginate :clients, options, &block
end

#create_client(options = {}) ⇒ BookingSync::API::Resource

Create a new client

Parameters:

  • options (Hash) (defaults to: {})

    Client attributes

Returns:



25
26
27
# File 'lib/bookingsync/api/client/clients.rb', line 25

def create_client(options = {})
  post(:clients, clients: [options]).pop
end

#edit_client(client, options = {}) ⇒ BookingSync::API::Resource

Edit a client

Examples:

client = @api.clients.first
@api.edit_client(client, { fullname: "Gary Smith" })

Parameters:

  • client (BookingSync::API::Resource|Integer)

    Client or ID of the client to be updated

  • options (Hash) (defaults to: {})

    Client attributes to be updated

Returns:



38
39
40
# File 'lib/bookingsync/api/client/clients.rb', line 38

def edit_client(client, options = {})
  put("clients/#{client}", clients: [options]).pop
end