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

#cancel_rental(rental, options = {}) ⇒ Array

Cancel a rental

to be canceled

Parameters:

Returns:

  • (Array) —

    An empty Array on success, exception is raised otherwise



47
48
49
# File 'lib/bookingsync/api/client/rentals.rb', line 47

def cancel_rental(rental, options = {})
  delete "rentals/#{rental}"
end

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

Create a new rental

Parameters:

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

    rental attributes

Returns:



25
26
27
# File 'lib/bookingsync/api/client/rentals.rb', line 25

def create_rental(options = {})
  post(:rentals, rentals: [options]).pop
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:



38
39
40
# File 'lib/bookingsync/api/client/rentals.rb', line 38

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

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

Get a single rental

Parameters:

Returns:



55
56
57
# File 'lib/bookingsync/api/client/rentals.rb', line 55

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