Module: BookingSync::API::Client::SpecialOffers

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

Instance Method Summary collapse

Instance Method Details

#create_special_offer(rental_id, options = {}) ⇒ BookingSync::API::Resource

Create a new special_offer

Parameters:

  • rental_id (Integer) —

    ID of the rental

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

    special_offer attributes

Returns:



26
27
28
# File 'lib/bookingsync/api/client/special_offers.rb', line 26

def create_special_offer(rental_id, options = {})
  post(:special_offers, rental_id: rental_id, special_offers: [options]).pop
end

#delete_special_offer(special_offer, options = {}) ⇒ Array

Delete a special_offer

ID of the special offer to be deleted

Parameters:

Returns:

  • (Array) —

    An empty Array on success, exception is raised otherwise



49
50
51
# File 'lib/bookingsync/api/client/special_offers.rb', line 49

def delete_special_offer(special_offer, options = {})
  delete "special_offers/#{special_offer}"
end

#edit_special_offer(special_offer, options = {}) ⇒ BookingSync::API::Resource

Edit a special_offer

ID of the special offer to be updated exception is raised otherwise

Examples:

special_offer = @api.special_offers.first
@api.edit_special_offer(special_offer, { name: "New offer" })

Parameters:

  • special_offer (BookingSync::API::Resource|Integer) —

    special offer or

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

    special offer attributes to be updated

Returns:



40
41
42
# File 'lib/bookingsync/api/client/special_offers.rb', line 40

def edit_special_offer(special_offer, options = {})
  put("special_offers/#{special_offer}", special_offers: [options]).pop
end

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

List special_offers

Returns special_offers for the account user is authenticated with.

Examples:

Get the list of special_offers for the current account

special_offers = @api.special_offers
special_offers.first.name # => "Spring discount"

Get the list of special_offers only with name and rental_id for smaller response

@api.special_offers(fields: [:name, :rental_id])

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

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