Class: Hungrytable::ReservationMake

Inherits:
Object
  • Object
show all
Includes:
RequestExtensions
Defined in:
lib/hungrytable/reservation_make.rb

Overview

Makes a new restaurant reservation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(restaurant_slotlock, opts = {}) ⇒ ReservationMake

Returns a new instance of ReservationMake.



10
11
12
13
14
15
# File 'lib/hungrytable/reservation_make.rb', line 10

def initialize(restaurant_slotlock, opts = {})
  @opts = opts
  ensure_required_opts
  @requester = opts[:requester] || PostRequest
  @restaurant_slotlock = restaurant_slotlock
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



8
9
10
# File 'lib/hungrytable/reservation_make.rb', line 8

def opts
  @opts
end

#restaurant_slotlockObject (readonly)

Returns the value of attribute restaurant_slotlock.



8
9
10
# File 'lib/hungrytable/reservation_make.rb', line 8

def restaurant_slotlock
  @restaurant_slotlock
end

Instance Method Details

#confirmation_numberString?

Get the confirmation number for the reservation

Returns:

  • (String, nil)

    confirmation number or nil if unsuccessful



25
26
27
28
29
# File 'lib/hungrytable/reservation_make.rb', line 25

def confirmation_number
  return nil unless successful?

  details['ns:ConfirmationNumber']
end

#error_messageString?

Get error messages if reservation failed

Returns:

  • (String, nil)

    error message or nil



33
34
35
# File 'lib/hungrytable/reservation_make.rb', line 33

def error_message
  details['ns:ErrorMessage']
end

#successful?Boolean

Check if the reservation was successful

Returns:

  • (Boolean)

    true if no errors



19
20
21
# File 'lib/hungrytable/reservation_make.rb', line 19

def successful?
  details['ns:ErrorID'].to_s == '0'
end