class Bookings
- Bookings
- Application
- ActionController::Base
- Reference
- Object
Defined in:
controllers/bookings.crConstant Summary
-
AFTER =
{} of Nil => Nil
-
AROUND =
{} of Nil => Nil
-
BEFORE =
{determine_tenant_from_domain => {nil, nil}, configure_request_logging => {nil, nil}, check_jwt_scope => {nil, nil}, confirm_access => {[update, update_alt, destroy, update_state], nil}} of Nil => Nil
-
FIFTY_MB =
(50 * 1024) * 1024
-
FORCE =
{} of Nil => Nil
-
LOCAL_AFTER =
{} of Nil => Nil
-
function => options
-
LOCAL_AROUND =
{} of Nil => Nil
-
function => options
-
LOCAL_BEFORE =
{confirm_access => {[update, update_alt, destroy, update_state], nil}} of Nil => Nil
-
function => options
-
LOCAL_FORCE =
{} of Nil => Nil
-
function => options
-
LOCAL_RESCUE =
{} of Nil => Nil
-
function => options
-
LOCAL_ROUTES =
{approve => {"post", "/:id/approve", nil, do set_approver(booking, true) booking.approved_at = Time.utc.to_unix clashing_bookings = check_clashing(booking) if clashing_bookings.size > 0 render(:conflict, json: clashing_bookings.first) end update_booking(booking, "approved") end, false}, reject => {"post", "/:id/reject", nil, do set_approver(booking, false) booking.rejected_at = Time.utc.to_unix booking.approver_id = nil booking.approver_email = nil booking.approver_name = nil update_booking(booking, "rejected") end, false}, check_in => {"post", "/:id/check_in", nil, do booking.checked_in = params["state"]? != "false" if booking.checked_in booking.checked_in_at = Time.utc.to_unix else booking.checked_out_at = Time.utc.to_unix end update_booking(booking, "checked_in") end, false}, update_state => {"post", "/:id/update_state", nil, do booking.process_state = params["state"]? update_booking(booking, "process_state") end, false}, guest_list => {"get", "/:id/guests", nil, do if booking else head(:not_found) end visitors = booking.attendees.to_a if visitors.empty? render(json: [] of Nil) end visitors = visitors.map do |visitor| visitor.guest.for_booking_to_h(visitor, booking.as_h) end render(json: visitors) end, false}} of Nil => Nil
-
function => options
-
LOCAL_SKIP =
{} of Nil => Nil
-
function => options
-
NAMESPACE =
["/api/staff/v1/bookings"]
-
default namespace based on class
-
PARAMS =
["checked_in", "created_before", "created_after", "approved", "rejected", "extension_data", "state"] of ::String
-
RESCUE =
{Error::Unauthorized => {error_unauthorized, do |error| Log.debug do error.message end head(:unauthorized) end}, Error::Forbidden => {error_forbidden, do |error| Log.debug do error.inspect_with_backtrace end head(:forbidden) end}, Clear::SQL::RecordNotFoundError => {clear_sql_record_not_found_error, do |error| Log.debug do error.message end head(:not_found) end}, Clear::SQL::Error => {clear_sql_error, do |error| render_error(HTTP::Status::INTERNAL_SERVER_ERROR, error) end}, KeyError => {key_error, do |error| if error.message.try(&.includes?("param")) else raise(error) end respond_with(:bad_request) do text(error.message) json({error: error.message}) end end}, JSON::MappingError => {json_mapping_error, do |error| respond_with(:bad_request) do text(error.inspect_with_backtrace) json({error: error.message, backtrace: error.backtrace?}) end end}, ::PlaceOS::Client::API::Error => {_place_os_client_api_error, do |error| render_error(HTTP::Status::NOT_FOUND, error) end}, ::Enumerable::EmptyError => {_enumerable_empty_error, do |error| render_error(HTTP::Status::NOT_FOUND, error) end}, PlaceCalendar::Exception => {place_calendar_exception, do |error| render_error(HTTP::Status::INTERNAL_SERVER_ERROR, error, "#{error.http_body} \n #{error.inspect_with_backtrace}") end}} of Nil => Nil
-
ROUTES =
{approve => {"post", "/:id/approve", nil, do set_approver(booking, true) booking.approved_at = Time.utc.to_unix clashing_bookings = check_clashing(booking) if clashing_bookings.size > 0 render(:conflict, json: clashing_bookings.first) end update_booking(booking, "approved") end, false}, reject => {"post", "/:id/reject", nil, do set_approver(booking, false) booking.rejected_at = Time.utc.to_unix booking.approver_id = nil booking.approver_email = nil booking.approver_name = nil update_booking(booking, "rejected") end, false}, check_in => {"post", "/:id/check_in", nil, do booking.checked_in = params["state"]? != "false" if booking.checked_in booking.checked_in_at = Time.utc.to_unix else booking.checked_out_at = Time.utc.to_unix end update_booking(booking, "checked_in") end, false}, update_state => {"post", "/:id/update_state", nil, do booking.process_state = params["state"]? update_booking(booking, "process_state") end, false}, guest_list => {"get", "/:id/guests", nil, do if booking else head(:not_found) end visitors = booking.attendees.to_a if visitors.empty? render(json: [] of Nil) end visitors = visitors.map do |visitor| visitor.guest.for_booking_to_h(visitor, booking.as_h) end render(json: visitors) end, false}, index => {"get", "/", nil, nil, false}, create => {"post", "/", nil, nil, false}, update => {"patch", "/:id", nil, nil, false}, show => {"get", "/:id", nil, nil, false}, destroy => {"delete", "/:id", nil, nil, false}} of Nil => Nil
-
SKIP =
{} of Nil => Nil
Class Method Summary
-
.__init_routes__(router)
Routes call the functions generated above
-
.__route_list__
Create draw_routes function
-
.approve(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts)
Helper methods for performing redirect_to calls
-
.base_route
Helper for obtaining base route
-
.check_in(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts)
Create draw_routes function
- .context(method : String, route : String, route_params : Hash(String, String) | Nil = nil, headers : Hash(String, String) | Nil = nil, body : String | Bytes | IO | Nil = nil, &)
-
.create(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts)
Create draw_routes function
-
.delete__api_staff_v1_bookings__id(context, head_request)
Create draw_routes function
-
.destroy(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts)
Create draw_routes function
-
.get__api_staff_v1_bookings_(context, head_request)
Create draw_routes function
-
.get__api_staff_v1_bookings__id(context, head_request)
Create draw_routes function
-
.get__api_staff_v1_bookings__id_guests(context, head_request)
Create draw_routes function
-
.guest_list(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts)
Create draw_routes function
-
.index(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts)
Create draw_routes function
-
.patch__api_staff_v1_bookings__id(context, head_request)
Create draw_routes function
-
.post__api_staff_v1_bookings_(context, head_request)
Create draw_routes function
-
.post__api_staff_v1_bookings__id_approve(context, head_request)
Generate functions for each route
-
.post__api_staff_v1_bookings__id_check_in(context, head_request)
Create draw_routes function
-
.post__api_staff_v1_bookings__id_reject(context, head_request)
Create draw_routes function
-
.post__api_staff_v1_bookings__id_update_state(context, head_request)
Create draw_routes function
-
.reject(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts)
Create draw_routes function
-
.show(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts)
Create draw_routes function
-
.update(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts)
Create draw_routes function
-
.update_state(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts)
Create draw_routes function
Instance Method Summary
- #_enumerable_empty_error(error)
- #_place_os_client_api_error(error)
-
#approve
Create functions for named routes Skip the CRUD verbs, as they are already defined Annotations defined via the
annotations
argument are applied here -
#base_route(*args, **options)
Helper for obtaining base route
-
#base_route(*args, **options, &)
Helper for obtaining base route
- #booking : Booking
- #check_in
- #clear_sql_error(error)
- #clear_sql_record_not_found_error(error)
-
#create
ameba:disable Metrics/CyclomaticComplexity
- #destroy
- #error_forbidden(error)
-
#error_unauthorized(error)
Create functions as required for errors Skip the generating methods for existing handlers
- #guest_list
- #index
- #json_mapping_error(error)
- #key_error(error)
- #place_calendar_exception(error)
- #reject
- #show
- #update
- #update_state
Macro Summary
- __inherit_after_filters__
- __inherit_around_filters__
- __inherit_before_filters__
- __inherit_force_filters__
- __inherit_rescue_filters__
- __inherit_routes_filters__
- __inherit_skip_filters__
Class methods inherited from class Application
context(method : String, route : String, route_params : Hash(String, String) | Nil = nil, headers : Hash(String, String) | Nil = nil, body : String | Bytes | IO | Nil = nil, &)
context
Instance methods inherited from module Utils::MultiTenant
client : PlaceCalendar::Client
client,
tenant
tenant
Instance methods inherited from module Utils::CurrentUser
authorize!
authorize!,
check_admin
check_admin,
check_support
check_support,
is_admin?
is_admin?,
is_support?
is_support?,
user
user,
user_token : UserJWT
user_token
Instance methods inherited from module Utils::PlaceOSHelpers
check_access(groups : Array(String), check : Array(String))
check_access,
get_placeos_client : PlaceOS::Client
get_placeos_client,
get_user_calendars
get_user_calendars,
matching_calendar_ids(allow_default = false)
matching_calendar_ids
Class Method Detail
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Helper methods for performing redirect_to calls
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Generate functions for each route
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Create draw_routes function
Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers
Instance Method Detail
Create functions for named routes
Skip the CRUD verbs, as they are already defined
Annotations defined via the annotations
argument are applied here
Create functions as required for errors Skip the generating methods for existing handlers