Class: Hungrytable::RestaurantSlotlock
- Inherits:
-
Object
- Object
- Hungrytable::RestaurantSlotlock
- Includes:
- RequestExtensions
- Defined in:
- lib/hungrytable/restaurant_slotlock.rb
Overview
Locks a reservation time slot before making a reservation
Instance Attribute Summary collapse
-
#restaurant_search ⇒ Object
readonly
Returns the value of attribute restaurant_search.
Instance Method Summary collapse
-
#errors ⇒ String?
Get error messages if slotlock failed.
-
#initialize(restaurant_search, requester = PostRequest) ⇒ RestaurantSlotlock
constructor
A new instance of RestaurantSlotlock.
-
#params ⇒ Hash
Parameters to send with the slotlock request.
-
#slotlock_id ⇒ String?
Get the slotlock ID needed for making a reservation.
-
#successful? ⇒ Boolean
Check if the slotlock was successful.
Constructor Details
#initialize(restaurant_search, requester = PostRequest) ⇒ RestaurantSlotlock
Returns a new instance of RestaurantSlotlock.
10 11 12 13 14 |
# File 'lib/hungrytable/restaurant_slotlock.rb', line 10 def initialize(restaurant_search, requester = PostRequest) @restaurant_search = restaurant_search @requester = requester validate_search_has_results end |
Instance Attribute Details
#restaurant_search ⇒ Object (readonly)
Returns the value of attribute restaurant_search.
8 9 10 |
# File 'lib/hungrytable/restaurant_slotlock.rb', line 8 def restaurant_search @restaurant_search end |
Instance Method Details
#errors ⇒ String?
Get error messages if slotlock failed
24 25 26 |
# File 'lib/hungrytable/restaurant_slotlock.rb', line 24 def errors details['ns:ErrorMessage'] end |
#params ⇒ Hash
Parameters to send with the slotlock request
38 39 40 41 42 43 44 45 46 |
# File 'lib/hungrytable/restaurant_slotlock.rb', line 38 def params { 'RID' => restaurant.id, 'datetime' => restaurant_search.ideal_time, 'partysize' => restaurant_search.party_size, 'timesecurityID' => restaurant_search.ideal_security_id, 'resultskey' => restaurant_search.results_key } end |
#slotlock_id ⇒ String?
Get the slotlock ID needed for making a reservation
30 31 32 33 34 |
# File 'lib/hungrytable/restaurant_slotlock.rb', line 30 def slotlock_id return nil unless successful? details['ns:SlotLockID'] end |
#successful? ⇒ Boolean
Check if the slotlock was successful
18 19 20 |
# File 'lib/hungrytable/restaurant_slotlock.rb', line 18 def successful? details['ns:ErrorID'].to_s == '0' end |