Module: BookingSync::API::Client::Bathrooms

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

Instance Method Summary collapse

Instance Method Details

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

Get a single bathroom

Parameters:

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

    Bedroom or ID of the bathroom.

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

    A customizable set of query options.

Options Hash (options):

  • fields: (Array)

    List of fields to be fetched.

Returns:



27
28
29
# File 'lib/bookingsync/api/client/bathrooms.rb', line 27

def bathroom(bathroom, options = {})
  get("bathrooms/#{bathroom}", options).pop
end

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

List bathrooms

Returns bathrooms for the account user is authenticated with.

Examples:

Get the list of bathrooms for the current account

bathrooms = @api.bathrooms
bathrooms.first.name # => "Bathroom 2"

Get the list of bathrooms only with name for smaller response

@api.bathrooms(fields: [:name])

Parameters:

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

    A customizable set of options.

Options Hash (options):

  • fields: (Array)

    List of fields to be fetched.

Returns:



16
17
18
# File 'lib/bookingsync/api/client/bathrooms.rb', line 16

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

#cancel_bathroom(bathroom) ⇒ NilClass

Cancel a bathroom

Parameters:

Returns:

  • (NilClass)

    Returns nil on success.



60
61
62
# File 'lib/bookingsync/api/client/bathrooms.rb', line 60

def cancel_bathroom(bathroom)
  delete "bathrooms/#{bathroom}"
end

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

Create a new bathroom

Parameters:

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

    Rental or ID of the rental for which bathroom will be created.

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

    Bathroom’s attributes.

Returns:



37
38
39
# File 'lib/bookingsync/api/client/bathrooms.rb', line 37

def create_bathroom(rental, options = {})
  post("rentals/#{rental}/bathrooms", bathrooms: [options]).pop
end

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

Edit a bathroom

Examples:

bathroom = @api.bathrooms.first
@api.edit_bathroom(bathroom, { name: "Some bathroom" })

Parameters:

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

    Bathroom or ID of the bathroom to be updated.

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

    Bathroom attributes to be updated.

Returns:



51
52
53
# File 'lib/bookingsync/api/client/bathrooms.rb', line 51

def edit_bathroom(bathroom, options = {})
  put("bathrooms/#{bathroom}", bathrooms: [options]).pop
end