Class: Bistrochat::Reservations::Detail
- Inherits:
-
Object
- Object
- Bistrochat::Reservations::Detail
- Includes:
- ApiHelpers, DefaultErrorContainer, ElasticAPM::SpanHelpers
- Defined in:
- app/services/bistrochat/reservations/detail.rb
Instance Attribute Summary collapse
-
#reservation ⇒ Object
readonly
Returns the value of attribute reservation.
Instance Method Summary collapse
-
#initialize(reservation_id) ⇒ Detail
constructor
A new instance of Detail.
- #show ⇒ Object
Methods included from DefaultErrorContainer
#error, #error_message_simple, #merge_errors
Methods included from ApiHelpers
#api_call, #channel, #find_bistrochat_vendor_application, #get_purpose, #headers, #parse_phone_number, #parse_user_or_guest_full_name, #parsed_vendor_name, #reservation_start_at, #send_error_availability_notification_to_staff
Constructor Details
#initialize(reservation_id) ⇒ Detail
Returns a new instance of Detail.
12 13 14 |
# File 'app/services/bistrochat/reservations/detail.rb', line 12 def initialize(reservation_id) @reservation = Reservation.find_by(id: reservation_id) end |
Instance Attribute Details
#reservation ⇒ Object (readonly)
Returns the value of attribute reservation.
10 11 12 |
# File 'app/services/bistrochat/reservations/detail.rb', line 10 def reservation @reservation end |
Instance Method Details
#show ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/services/bistrochat/reservations/detail.rb', line 16 def show errors.clear = Bistrochat::ErrorMessages::DEFAULT_ERROR validation_result = validate_reservation(reservation) unless validation_result.success? = validation_result. errors.add(:base, ) return ServiceResult.new errors: errors, message: end bistrochat_reservation_id = reservation.vendor_reservation&.supplier_reservation_id if bistrochat_reservation_id.blank? = "BistroChat reservation id is blank for reservation #{reservation.id}" unless Bistrochat::ErrorMessages::KNOWN_ERRORS.include?() APMErrorHandler.report("#{self.class} #{}", reservation_id: reservation.id) end errors.add(:base, ) return ServiceResult.new errors: errors, message: end result = show_reservation(bistrochat_reservation_id) unless result.success? = result. errors.add(:base, ) return ServiceResult.new errors: errors, message: end ServiceResult.new data: result.data end |