module BookingSync::API::Client::Rentals
Public Instance Methods
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 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 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
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
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
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
Search rentals
Returns list of light rentals. Composed of id, initial_price, final_price and updated_at.
@param options [Hash] A customizable set of options. @return [Array<BookingSync::API::Resource>] Array of light rentals.
@example Search rentals by rental type villas = @api.rentals_search(rental_type: “villa”)
# File lib/bookingsync/api/client/rentals.rb, line 31 def rentals_search(options = {}, &block) ids = Array(options.delete(:ids)) path = reject_blank_values(["rentals", ids.join(","), "search"]).join("/") defaults = { request_method: :post } paginate path, defaults.merge(options), &block end