Module: BookingSync::API::Client::Rentals

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

Instance Method Summary collapse

Instance Method Details

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

Create a new rental

Parameters:

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

    rental attributes

Returns:



50
51
52
# File 'lib/bookingsync/api/client/rentals.rb', line 50

def create_rental(options = {})
  post(:rentals, rentals: [options]).pop
end

#delete_rental(rental) ⇒ NilClass

Delete a rental

Parameters:

Returns:

  • (NilClass)

    Returns nil on success.



72
73
74
# File 'lib/bookingsync/api/client/rentals.rb', line 72

def delete_rental(rental)
  delete "rentals/#{rental}"
end

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

Edit a rental

to be updated

Examples:

rental = @api.rentals.first
@api.edit_rental(rental, { sleeps: 3 })

Parameters:

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

    rental or ID of the rental

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

    rental attributes to be updated

Returns:



63
64
65
# File 'lib/bookingsync/api/client/rentals.rb', line 63

def edit_rental(rental, options = {})
  put("rentals/#{rental}", rentals: [options]).pop
end

#rental(rental) ⇒ BookingSync::API::Resource

Get a single rental

Parameters:

Returns:



42
43
44
# File 'lib/bookingsync/api/client/rentals.rb', line 42

def rental(rental)
  get("rentals/#{rental}").pop
end

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

List rentals

Returns rentals for the account user is authenticated with.

Examples:

Get the list of rentals for the current account

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

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

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

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/rentals.rb', line 17

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

#rentals_meta(rentals = nil) ⇒ BookingSync::API::Resource

Get meta information about rentals.

Parameters:

  • rentals (Array) (defaults to: nil)

    IDs of Rentals, leave empty for all account’s rentals

Returns:



80
81
82
# File 'lib/bookingsync/api/client/rentals.rb', line 80

def rentals_meta(rentals = nil)
  get(["rentals", Array(rentals).join(","), "meta"].compact.join("/")).pop
end

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

Search rentals

Returns list of light rentals. Composed of id, initial_price, final_price and updated_at.

villas = @api.rentals_search(rental_type: “villa”)

Examples:

Search rentals by rental type


Parameters:

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

    A customizable set of options.

Returns:



31
32
33
34
35
# File 'lib/bookingsync/api/client/rentals.rb', line 31

def rentals_search(options = {}, &block)
  ids = Array(options.delete(:ids))
  path = ["rentals", ids.join(","), "search"].compact.join("/")
  paginate path, options, &block
end