module BookingSync::API::Client::Rentals

Public Instance Methods

create_rental(options = {}) click to toggle source

Create a new rental

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

# File lib/bookingsync/api/client/rentals.rb, line 51
def create_rental(options = {})
  post(:rentals, rentals: [options]).pop
end
delete_rental(rental) click to toggle source

Delete a rental

@param rental [BookingSync::API::Resource|Integer] Rental or ID

of the rental to be deleted.

@return [NilClass] Returns nil on success.

# File lib/bookingsync/api/client/rentals.rb, line 73
def delete_rental(rental)
  delete "rentals/#{rental}"
end
edit_rental(rental, options = {}) click to toggle source

Edit a rental

@param rental [BookingSync::API::Resource|Integer] rental or ID of the rental to be updated @param options [Hash] rental attributes to be updated @return [BookingSync::API::Resource] Updated rental on success, exception is raised otherwise @example

rental = @api.rentals.first
@api.edit_rental(rental, { sleeps: 3 })
# File lib/bookingsync/api/client/rentals.rb, line 64
def edit_rental(rental, options = {})
  put("rentals/#{rental}", rentals: [options]).pop
end
rental(rental, options = {}) click to toggle source

Get a single rental

@param rental [BookingSync::API::Resource|Integer] Rental or ID

of the rental.

@return [BookingSync::API::Resource]

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

List rentals

Returns rentals 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 rentals.

@example Get the list of rentals for the current account

rentals = @api.rentals
rentals.first.name # => "Small apartment"

@example Get the list of rentals only with name and description for smaller response

@api.rentals(fields: [:name, :description])

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

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

Get meta information about rentals.

@param rentals [Array] IDs of Rentals, leave empty for all account’s rentals @return [BookingSync::API::Resource]

# File lib/bookingsync/api/client/rentals.rb, line 81
def rentals_meta(rentals = nil)
  path = reject_blank_values(["rentals", Array(rentals).join(","), "meta"]).join("/")
  get(path).pop
end