Class: Suitcase::Hotel::Cancellation
- Inherits:
-
Object
- Object
- Suitcase::Hotel::Cancellation
- Extended by:
- Helpers
- Includes:
- Helpers
- Defined in:
- lib/suitcase/hotel/cancellation.rb
Constant Summary
Constants included from Helpers
Instance Attribute Summary collapse
-
#cancellation_number ⇒ Object
Returns the value of attribute cancellation_number.
-
#confirmation_number ⇒ Object
Returns the value of attribute confirmation_number.
-
#email ⇒ Object
Returns the value of attribute email.
-
#itinerary_id ⇒ Object
Returns the value of attribute itinerary_id.
-
#reason ⇒ Object
Returns the value of attribute reason.
Instance Method Summary collapse
-
#cancel_reservation! ⇒ Object
Makes the call to EAN and if successful sets the cancellation_number attribute.
-
#initialize(info) ⇒ Cancellation
constructor
Accepts a hash with the itinerary_id, confirmation_number, email and optional reason code (COP ILL DEA OTH).
- #reservation_canceled? ⇒ Boolean
- #valid_reason? ⇒ Boolean
Methods included from Helpers
base_url, build_session_params, generate_signature, handle_errors, main_url, parameterize, parameterize_rooms, parse_response, update_session, url
Constructor Details
#initialize(info) ⇒ Cancellation
Accepts a hash with the itinerary_id, confirmation_number, email and optional reason code (COP ILL DEA OTH)
13 14 15 16 17 |
# File 'lib/suitcase/hotel/cancellation.rb', line 13 def initialize(info) info.each do |k, v| instance_variable_set("@" + k.to_s, v) end end |
Instance Attribute Details
#cancellation_number ⇒ Object
Returns the value of attribute cancellation_number.
7 8 9 |
# File 'lib/suitcase/hotel/cancellation.rb', line 7 def cancellation_number @cancellation_number end |
#confirmation_number ⇒ Object
Returns the value of attribute confirmation_number.
7 8 9 |
# File 'lib/suitcase/hotel/cancellation.rb', line 7 def confirmation_number @confirmation_number end |
#email ⇒ Object
Returns the value of attribute email.
7 8 9 |
# File 'lib/suitcase/hotel/cancellation.rb', line 7 def email @email end |
#itinerary_id ⇒ Object
Returns the value of attribute itinerary_id.
7 8 9 |
# File 'lib/suitcase/hotel/cancellation.rb', line 7 def itinerary_id @itinerary_id end |
#reason ⇒ Object
Returns the value of attribute reason.
7 8 9 |
# File 'lib/suitcase/hotel/cancellation.rb', line 7 def reason @reason end |
Instance Method Details
#cancel_reservation! ⇒ Object
Makes the call to EAN and if successful sets the cancellation_number attribute
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/suitcase/hotel/cancellation.rb', line 21 def cancel_reservation! params = {} params["itineraryId"] = itinerary_id params["email"] = email params["confirmationNumber"] = confirmation_number params["reason"] = reason if valid_reason? parsed = Hotel.parse_response(Hotel.url(method: 'cancel', params: params)) Hotel.handle_errors(parsed) @cancellation_number = parsed["HotelRoomCancellationResponse"]["cancellationNumber"] end |
#reservation_canceled? ⇒ Boolean
34 35 36 |
# File 'lib/suitcase/hotel/cancellation.rb', line 34 def reservation_canceled? !cancellation_number.nil? end |
#valid_reason? ⇒ Boolean
38 39 40 |
# File 'lib/suitcase/hotel/cancellation.rb', line 38 def valid_reason? %w(COP ILL DEA OTH).include?(reason) end |