Skip to content

Commit

Permalink
feat(bookings): add update_induction endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
chillfox committed Aug 19, 2024
1 parent 7e79cea commit f635fd1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/controllers/bookings.cr
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Bookings < Application
.limit(1).to_a.first { raise Error::NotFound.new("could not find booking with id: #{id}") }
end

@[AC::Route::Filter(:before_action, only: [:update, :update_alt, :destroy, :update_state])]
@[AC::Route::Filter(:before_action, only: [:update, :update_alt, :destroy, :update_state, :update_induction])]
private def confirm_access
return if is_support?
if user = current_user
Expand Down Expand Up @@ -515,7 +515,7 @@ class Bookings < Application
original_assets = existing_booking.asset_ids
existing_booking.instance = instance

{% for key in [:asset_id, :asset_ids, :zones, :booking_start, :booking_end, :title, :description, :images] %}
{% for key in [:asset_id, :asset_ids, :zones, :booking_start, :booking_end, :title, :description, :images, :induction] %}
begin
existing_booking.{{key.id}} = changes.{{key.id}} if changes.{{key.id}}_present?
rescue NilAssertionError
Expand Down Expand Up @@ -807,6 +807,19 @@ class Bookings < Application
update_booking(booking, "process_state")
end

# update the induction status
@[AC::Route::POST("/:id/update_induction")]
def update_induction(
@[AC::Param::Info(description: "the induction status of the booking", example: "TENTATIVE")]
induction : PlaceOS::Model::Induction,
@[AC::Param::Info(description: "provided for use with analytics", example: "mobile")]
utm_source : String? = nil
) : Booking
booking.induction = induction
booking.utm_source = utm_source
update_booking(booking, "induction")
end

# returns a list of guests associated with a booking
@[AC::Route::GET("/:id/guests")]
def guest_list : Array(Guest)
Expand Down

0 comments on commit f635fd1

Please sign in to comment.