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, options = {}) ⇒ BookingSync::API::Resource

Create a new special offer for a rental

Parameters:

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

    Rental or ID of the rental for which special offer will be created.

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

    Special offer’s attributes.

Returns:



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

def create_special_offer(rental, options = {})
  post("rentals/#{rental}/special_offers", special_offers: [options]).pop
end

#delete_special_offer(special_offer) ⇒ NilClass

Delete a special offer

Parameters:

Returns:

  • (NilClass)

    Returns nil on success.



61
62
63
# File 'lib/bookingsync/api/client/special_offers.rb', line 61

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

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

Edit a special offer

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 ID of the special offer to be updated.

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

    special offer attributes to be updated.

Returns:



52
53
54
# File 'lib/bookingsync/api/client/special_offers.rb', line 52

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

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

Get a single special_offer

Parameters:

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

    SpecialOffer or ID of the special_offer.

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

    A customizable set of query options.

Options Hash (options):

  • fields: (Array)

    List of fields to be fetched.

Returns:



28
29
30
# File 'lib/bookingsync/api/client/special_offers.rb', line 28

def special_offer(special_offer, options = {})
  get("special_offers/#{special_offer}", 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