module BookingSync::API::Client::RentalUrls

Public Instance Methods

cancel_rental_url(rental_url) click to toggle source

Cancel a RentalUrl

@param rental_url [BookingSync::API::Resource|Integer] RentalUrl or ID

of the rental_url to be canceled.

@return [NilClass] Returns nil on success.

# File lib/bookingsync/api/client/rental_urls.rb, line 61
def cancel_rental_url(rental_url)
  delete "rental_urls/#{rental_url}"
end
create_rental_url(rental, options = {}) click to toggle source

Create a new rental_url

@param options [Hash] RentalUrl’s attributes. @return [BookingSync::API::Resource] Newly created rental_url.

# File lib/bookingsync/api/client/rental_urls.rb, line 32
def create_rental_url(rental, options = {})
  if file_path = options.delete(:file_path)
    options[:file] ||= base_64_encode(file_path)
  end
  post("rentals/#{rental}/rental_urls", rental_urls: options).pop
end
edit_rental_url(rental_url, options = {}) click to toggle source

Edit a rental_url

@param rental_url [BookingSync::API::Resource|Integer] RentalUrl or ID of

the rental_url to be updated.

@param options [Hash] RentalUrl attributes to be updated. @return [BookingSync::API::Resource] Updated rental_url on success,

exception is raised otherwise.

@example

rental_url = @api.rental_urls.first
@api.edit_rental_url(rental_url, { label: "Airbnb" })
# File lib/bookingsync/api/client/rental_urls.rb, line 49
def edit_rental_url(rental_url, options = {})
  if file_path = options.delete(:file_path)
    options[:file] ||= base_64_encode(file_path)
  end
  put("rental_urls/#{rental_url}", rental_urls: options).pop
end
rental_url(rental_url) click to toggle source

Get a single rental_url

@param rental_url [BookingSync::API::Resource|Integer] RentalUrl or ID

of the rental_url.

@return [BookingSync::API::Resource]

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

List rental_urls

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

@example Get the list of rental_urls for the current account

rental_urls = @api.rental_urls
rental_urls.first.label # => "HomeAway"

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

# File lib/bookingsync/api/client/rental_urls.rb, line 15
def rental_urls(options = {}, &block)
  paginate :rental_urls, options, &block
end
restore_rental_url(rental_url) click to toggle source

Restore a RentalUrl

@param rental_url [BookingSync::API::Resource|Integer] RentalUrl or ID

of the rental_url to be canceled.

@return [BookingSync::API::Resource] Restored rental_url on success,

exception is raised otherwise.
# File lib/bookingsync/api/client/rental_urls.rb, line 71
def restore_rental_url(rental_url)
  put("rental_urls/#{rental_url}/restore").pop
end

Private Instance Methods

base_64_encode(file_path) click to toggle source
# File lib/bookingsync/api/client/rental_urls.rb, line 77
def base_64_encode(file_path)
  Base64.encode64(File.read(file_path))
end