Module: BookingSync::API::Client::Bedrooms

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

Instance Method Summary collapse

Instance Method Details

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

Get a single bedroom

Parameters:

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

    Bedroom or ID of the bedroom.

  • 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/bedrooms.rb', line 27

def bedroom(bedroom, options = {})
  get("bedrooms/#{bedroom}", options).pop
end

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

List bedrooms

Returns bedrooms for the account user is authenticated with.

Examples:

Get the list of bedrooms for the current account

bedrooms = @api.bedrooms
bedrooms.first.name # => "Bedroom 2"

Get the list of bedrooms only with name for smaller response

@api.bedrooms(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/bedrooms.rb', line 16

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

#cancel_bedroom(bedroom) ⇒ NilClass

Cancel a bedroom

Parameters:

Returns:

  • (NilClass)

    Returns nil on success.



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

def cancel_bedroom(bedroom)
  delete "bedrooms/#{bedroom}"
end

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

Create a new bedroom

Parameters:

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

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

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

    Bedroom’s attributes.

Returns:



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

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

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

Edit a bedroom

Examples:

bedroom = @api.bedrooms.first
@api.edit_bedroom(bedroom, { name: "Some bedroom" })

Parameters:

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

    Bedroom or ID of the bedroom to be updated.

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

    Bedroom attributes to be updated.

Returns:



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

def edit_bedroom(bedroom, options = {})
  put("bedrooms/#{bedroom}", bedrooms: [options]).pop
end