Module: BookingSync::API::Client::ReservationsOffers

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

Overview

Client methods for the Reservations::Offer V3 endpoint (path: reservations/offers). This is a sibling to ReservationsRequests and is a different concept from SpecialOffers, which is a rental-level discount API (path: rentals/BookingSync::API::Client::Rentals#rental/special_offers). The two coexist.

Contract notes (verified against live Core), differing from reservations_requests:

- Request root key is `reservations_offers` (plural, array-wrapped),
while the response root key is `offers` (asymmetric, same pattern
as reservations_requests -> requests).
- Offer attributes are flat, there is no `booking_payload` wrapper.
- There is no `booking_id` on create, a booking is attached later via
a separate Core-side AttachBooking command.
- Money is `total_amount_cents` (integer cents), not a `final_price`
string decimal like reservations_requests.

Instance Method Summary collapse

Instance Method Details

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

Create a new reservations offer

Parameters:

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

    Reservations offer attributes. Required: conversation_id, rental_id, client_id, start_date, end_date, adults, total_amount_cents, currency, expires_at. Optional: children.

Returns:



48
49
50
# File 'lib/bookingsync/api/client/reservations_offers.rb', line 48

def create_reservation_offer(options = {})
  post("reservations/offers", reservations_offers: [options]).pop
end

#delete_reservation_offer(id) ⇒ NilClass

Delete a reservations offer

Soft-cancels the given reservations offer (sets canceled_at). This is distinct from a status transition to withdrawn, which is done via #patch_reservation_offer.

Parameters:

Returns:

  • (NilClass)

    Returns nil on success.



73
74
75
# File 'lib/bookingsync/api/client/reservations_offers.rb', line 73

def delete_reservation_offer(id)
  delete "reservations/offers/#{id}"
end

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

Edit a reservations offer

A withdrawal is performed as a regular update transitioning the offer to the withdrawn status, there is no dedicated withdraw endpoint on V3.

Parameters:

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

    Reservations offer or ID of the reservations offer to be updated.

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

    Reservations offer attributes to be updated.

Returns:



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

def patch_reservation_offer(id, options = {})
  patch("reservations/offers/#{id}", reservations_offers: [options]).pop
end

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

Get a single reservations offer

Parameters:

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

    Reservations offer or ID of the reservations offer.

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

    A customizable set of query options.

Options Hash (options):

  • fields: (Array)

    List of fields to be fetched.

Returns:



37
38
39
# File 'lib/bookingsync/api/client/reservations_offers.rb', line 37

def reservations_offer(id, options = {})
  get("reservations/offers/#{id}", options).pop
end

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

List reservations offers

Returns reservations offers for the current account.

Parameters:

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

    A customizable set of query options.

Options Hash (options):

  • fields: (Array)

    List of fields to be fetched.

Returns:

See Also:



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

def reservations_offers(options = {}, &block)
  paginate "reservations/offers", options, &block
end