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

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

Get a single client

Parameters:

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

    Client or ID of the client.

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

    A customizable set of query options.

Options Hash (options):

  • fields: (Array)

    List of fields to be fetched.

Returns:



28
29
30
# File 'lib/bookingsync/api/client/clients.rb', line 28

def client(client, options = {})
  get("clients/#{client}", options).pop
end

#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:



36
37
38
# File 'lib/bookingsync/api/client/clients.rb', line 36

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:



49
50
51
# File 'lib/bookingsync/api/client/clients.rb', line 49

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