Class: ReservationGuestUpdatesController
Defined Under Namespace
Classes: InvalidReservation
Instance Method Summary
collapse
#validate_guest_edit
#activate_cache?, #current_user_ck, default_url_options, #identity_cache_memoization, #set_csrf_token
#append_info_to_payload
#setup_locale
#my_response_cache
#dynamic_pricings_formatter, #link_to_admin_reservations_path_by_id, #link_to_admin_restaurants_path_by_id, #link_to_log, #optional_locales, #optional_locales_with_labels, #staff_signed_in?
#identity_cache_memoization
Instance Method Details
#quick_cancel ⇒ Object
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
# File 'app/controllers/reservation_guest_updates_controller.rb', line 165
def quick_cancel
reason = params[:reason]
claim_refund = params.fetch(:claim_refund, false)
service = CancelReservationService.new(
@reservation.id,
:user,
{ require_reason: true, claim_refund: claim_refund },
)
service.cancel_reason = reason
if service.execute
render json: { success: true }
else
render json: { success: false, error: service.error_message_simple }
end
end
|
#quick_cancel_non_package ⇒ Object
106
107
108
109
110
111
112
113
114
115
|
# File 'app/controllers/reservation_guest_updates_controller.rb', line 106
def quick_cancel_non_package
reason = params[:reason]
service = CancelReservationService.new(@reservation.id, :user, { require_reason: true })
service.cancel_reason = reason
if service.execute
render json: { success: true }
else
render json: { success: false, error: service.error_message_simple }
end
end
|
#quick_edit ⇒ Object
52
53
54
55
56
57
58
59
60
|
# File 'app/controllers/reservation_guest_updates_controller.rb', line 52
def quick_edit
@operation = ::PackageBooking::Users::Update.new(@reservation.id, {}, package: nil)
@reservation = @operation.reservation
@custom_package_pricing = @reservation.custom_package_pricing if @reservation.custom_package_pricing?
render :quick_edit
set_meta_tags title: 'Manage My Booking'
end
|
#quick_edit_non_package ⇒ Object
83
84
85
86
87
88
89
|
# File 'app/controllers/reservation_guest_updates_controller.rb', line 83
def quick_edit_non_package
@operation = ::Agents::ModifyBookingForUser.new(@reservation.id, {})
@reservation = @operation.reservation
render :quick_edit_non_package
set_meta_tags title: 'Manage My Booking'
end
|
#quick_edit_owner ⇒ Object
62
63
64
65
66
|
# File 'app/controllers/reservation_guest_updates_controller.rb', line 62
def quick_edit_owner
@owner_id = HungryHub::Owner::Codec.encode @owner.id
quick_edit
set_meta_tags title: 'Manage Booking'
end
|
#quick_update ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'app/controllers/reservation_guest_updates_controller.rb', line 68
def quick_update
@operation = ::PackageBooking::Users::Update.new(@reservation.id, booking_parameters, package: package_params)
if @operation.execute
reservation = @operation.reservation
sync_reservations(reservation)
serializer = Api::V5::ReservationSerializer.new(reservation)
render json: { success: true, reservation: serializer.as_json }
else
render json: { success: false, error: @operation.error_message }
end
rescue ActionController::ParameterMissing => e
render json: { success: false, error: ParameterMissingFormatter.format(e) }
end
|
#quick_update_non_instant ⇒ Object
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
# File 'app/controllers/reservation_guest_updates_controller.rb', line 146
def quick_update_non_instant
return render(json: { success: false }) unless @reservation.restaurant.owner_id == @owner.id
update_type = params.require(:reservation_guest_update).require(:type)
confirmed = update_type == 'confirm'
rejected = update_type == 'reject'
service = ReservationConfirmationService.new(@reservation.id, confirmed_by: :owner)
if confirmed
success = service.accept
render json: { success: success, message: service.error_message_simple }
elsif rejected
success = service.reject
render json: { success: success, message: service.error_message_simple }
else
render json: { success: false, message: 'Unknown action' }
end
end
|
#quick_update_non_package ⇒ Object
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'app/controllers/reservation_guest_updates_controller.rb', line 91
def quick_update_non_package
@operation = ::Agents::ModifyBookingForUser.new(@reservation.id, booking_parameters)
if @operation.execute
reservation = @operation.reservation
sync_reservations(reservation)
serializer = Api::V5::ReservationSerializer.new(reservation)
render json: { success: true, reservation: serializer.as_json }
else
render json: { success: false, error: @operation.error_message }
end
rescue ActionController::ParameterMissing => e
render json: { success: false, error: ParameterMissingFormatter.format(e) }
end
|
#quick_update_owner ⇒ Object
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'app/controllers/reservation_guest_updates_controller.rb', line 117
def quick_update_owner
unless dashboard_v2_owner_signed_in?
if @owner.email == params[:email] && @owner.valid_password?(params[:password])
sign_in(:dashboard_v2_owner, @owner)
else
render json: { success: false, error: 'Invalid email or password' }
return
end
end
@owner = current_dashboard_v2_owner
unless @reservation.restaurant.owner_id == @owner.id
return render(json: { success: false,
error: 'you are not authorized to update this booking' })
end
operation = ::PackageBooking::Owners::Update.new(@reservation.id, booking_parameters, package_params)
if operation.update_booking
sync_reservations(@reservation)
serializer = Api::V5::ReservationSerializer.new(@reservation)
render json: { success: true, reservation: serializer.as_json }
else
render json: { success: false, error: operation.error_message }
end
end
|