Class: Conexa::RoomBooking

Inherits:
Model show all
Defined in:
lib/conexa/resources/room_booking.rb

Overview

RoomBooking resource (Reserva de Sala)

Examples:

Create a room booking

booking = Conexa::RoomBooking.create(
  room_id: 5,
  customer_id: 127,
  start_date: '2026-04-01T10:00:00-03:00',
  end_date: '2026-04-01T12:00:00-03:00'
)

Find a room booking

booking = Conexa::RoomBooking.find(143063)

List room bookings

bookings = Conexa::RoomBooking.all(limit: 50)

Cancel a booking

Conexa::RoomBooking.cancel(143063)

Constant Summary

Constants inherited from ConexaObject

ConexaObject::RESOURCES

Instance Attribute Summary collapse

Attributes inherited from ConexaObject

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

all, #class_name, class_name, #create, create, #destroy, destroy, extract_page_size_or_params, #fetch, find_by, find_by_id, #id, #primary_key, primary_key_attribute, #primary_key_name, #save, #set_primary_key, underscored_class_name

Methods inherited from ConexaObject

#==, #[]=, convert, #empty?, #initialize, #respond_to_missing?, #to_hash, #unsaved_attributes

Constructor Details

This class inherits a constructor from Conexa::ConexaObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Conexa::ConexaObject

Instance Attribute Details

#booking_idInteger (readonly)

Returns Booking ID (also accessible as #id).

Returns:

  • (Integer)

    Booking ID (also accessible as #id)



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/conexa/resources/room_booking.rb', line 32

class RoomBooking < Model
  primary_key_attribute :booking_id

  # Cancel this booking
  # @return [self]
  def cancel
    Conexa::Request.patch(self.class.show_url(primary_key, "cancel")).call(class_name)
    self
  end

  # Checkout this booking
  # @return [self]
  def checkout
    Conexa::Request.post(self.class.show_url(primary_key, "checkout")).call(class_name)
    self
  end

  class << self
    def url(*params)
      ["/room/bookings", *params].join '/'
    end

    def show_url(*params)
      ["/room/booking", *params].join '/'
    end

    # Cancel a booking by ID
    # @param id [Integer, String] booking ID
    # @return [RoomBooking]
    def cancel(id)
      find(id).cancel
    end

    # Checkout a booking by ID
    # @param id [Integer, String] booking ID
    # @return [RoomBooking]
    def checkout(id)
      find(id).checkout
    end

    # Perform a checkin
    # @param params [Hash] checkin parameters
    # @return [ConexaObject]
    def checkin(params = {})
      Conexa::Request.post("/checkin", params: params).call("room_booking")
    end

    # Perform a checkout (standalone)
    # @param params [Hash] checkout parameters
    # @return [ConexaObject]
    def standalone_checkout(params = {})
      Conexa::Request.post("/checkout", params: params).call("room_booking")
    end
  end
end

#customer_idInteger (readonly)

Returns Customer ID.

Returns:

  • (Integer)

    Customer ID



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/conexa/resources/room_booking.rb', line 32

class RoomBooking < Model
  primary_key_attribute :booking_id

  # Cancel this booking
  # @return [self]
  def cancel
    Conexa::Request.patch(self.class.show_url(primary_key, "cancel")).call(class_name)
    self
  end

  # Checkout this booking
  # @return [self]
  def checkout
    Conexa::Request.post(self.class.show_url(primary_key, "checkout")).call(class_name)
    self
  end

  class << self
    def url(*params)
      ["/room/bookings", *params].join '/'
    end

    def show_url(*params)
      ["/room/booking", *params].join '/'
    end

    # Cancel a booking by ID
    # @param id [Integer, String] booking ID
    # @return [RoomBooking]
    def cancel(id)
      find(id).cancel
    end

    # Checkout a booking by ID
    # @param id [Integer, String] booking ID
    # @return [RoomBooking]
    def checkout(id)
      find(id).checkout
    end

    # Perform a checkin
    # @param params [Hash] checkin parameters
    # @return [ConexaObject]
    def checkin(params = {})
      Conexa::Request.post("/checkin", params: params).call("room_booking")
    end

    # Perform a checkout (standalone)
    # @param params [Hash] checkout parameters
    # @return [ConexaObject]
    def standalone_checkout(params = {})
      Conexa::Request.post("/checkout", params: params).call("room_booking")
    end
  end
end

#room_idInteger (readonly)

Returns Room ID.

Returns:

  • (Integer)

    Room ID



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/conexa/resources/room_booking.rb', line 32

class RoomBooking < Model
  primary_key_attribute :booking_id

  # Cancel this booking
  # @return [self]
  def cancel
    Conexa::Request.patch(self.class.show_url(primary_key, "cancel")).call(class_name)
    self
  end

  # Checkout this booking
  # @return [self]
  def checkout
    Conexa::Request.post(self.class.show_url(primary_key, "checkout")).call(class_name)
    self
  end

  class << self
    def url(*params)
      ["/room/bookings", *params].join '/'
    end

    def show_url(*params)
      ["/room/booking", *params].join '/'
    end

    # Cancel a booking by ID
    # @param id [Integer, String] booking ID
    # @return [RoomBooking]
    def cancel(id)
      find(id).cancel
    end

    # Checkout a booking by ID
    # @param id [Integer, String] booking ID
    # @return [RoomBooking]
    def checkout(id)
      find(id).checkout
    end

    # Perform a checkin
    # @param params [Hash] checkin parameters
    # @return [ConexaObject]
    def checkin(params = {})
      Conexa::Request.post("/checkin", params: params).call("room_booking")
    end

    # Perform a checkout (standalone)
    # @param params [Hash] checkout parameters
    # @return [ConexaObject]
    def standalone_checkout(params = {})
      Conexa::Request.post("/checkout", params: params).call("room_booking")
    end
  end
end

#statusString (readonly)

Returns Booking status.

Returns:

  • (String)

    Booking status



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/conexa/resources/room_booking.rb', line 32

class RoomBooking < Model
  primary_key_attribute :booking_id

  # Cancel this booking
  # @return [self]
  def cancel
    Conexa::Request.patch(self.class.show_url(primary_key, "cancel")).call(class_name)
    self
  end

  # Checkout this booking
  # @return [self]
  def checkout
    Conexa::Request.post(self.class.show_url(primary_key, "checkout")).call(class_name)
    self
  end

  class << self
    def url(*params)
      ["/room/bookings", *params].join '/'
    end

    def show_url(*params)
      ["/room/booking", *params].join '/'
    end

    # Cancel a booking by ID
    # @param id [Integer, String] booking ID
    # @return [RoomBooking]
    def cancel(id)
      find(id).cancel
    end

    # Checkout a booking by ID
    # @param id [Integer, String] booking ID
    # @return [RoomBooking]
    def checkout(id)
      find(id).checkout
    end

    # Perform a checkin
    # @param params [Hash] checkin parameters
    # @return [ConexaObject]
    def checkin(params = {})
      Conexa::Request.post("/checkin", params: params).call("room_booking")
    end

    # Perform a checkout (standalone)
    # @param params [Hash] checkout parameters
    # @return [ConexaObject]
    def standalone_checkout(params = {})
      Conexa::Request.post("/checkout", params: params).call("room_booking")
    end
  end
end

Class Method Details

.cancel(id) ⇒ RoomBooking

Cancel a booking by ID

Parameters:

  • id (Integer, String)

    booking ID

Returns:



61
62
63
# File 'lib/conexa/resources/room_booking.rb', line 61

def cancel(id)
  find(id).cancel
end

.checkin(params = {}) ⇒ ConexaObject

Perform a checkin

Parameters:

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

    checkin parameters

Returns:



75
76
77
# File 'lib/conexa/resources/room_booking.rb', line 75

def checkin(params = {})
  Conexa::Request.post("/checkin", params: params).call("room_booking")
end

.checkout(id) ⇒ RoomBooking

Checkout a booking by ID

Parameters:

  • id (Integer, String)

    booking ID

Returns:



68
69
70
# File 'lib/conexa/resources/room_booking.rb', line 68

def checkout(id)
  find(id).checkout
end

.show_url(*params) ⇒ Object



54
55
56
# File 'lib/conexa/resources/room_booking.rb', line 54

def show_url(*params)
  ["/room/booking", *params].join '/'
end

.standalone_checkout(params = {}) ⇒ ConexaObject

Perform a checkout (standalone)

Parameters:

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

    checkout parameters

Returns:



82
83
84
# File 'lib/conexa/resources/room_booking.rb', line 82

def standalone_checkout(params = {})
  Conexa::Request.post("/checkout", params: params).call("room_booking")
end

.url(*params) ⇒ Object



50
51
52
# File 'lib/conexa/resources/room_booking.rb', line 50

def url(*params)
  ["/room/bookings", *params].join '/'
end

Instance Method Details

#cancelself

Cancel this booking

Returns:

  • (self)


37
38
39
40
# File 'lib/conexa/resources/room_booking.rb', line 37

def cancel
  Conexa::Request.patch(self.class.show_url(primary_key, "cancel")).call(class_name)
  self
end

#checkoutself

Checkout this booking

Returns:

  • (self)


44
45
46
47
# File 'lib/conexa/resources/room_booking.rb', line 44

def checkout
  Conexa::Request.post(self.class.show_url(primary_key, "checkout")).call(class_name)
  self
end