Within our sample booking application we have provisional bookings and we need to confirm these.
Upon confirming a booking, users associated with the booking may receive a confirmation message - this can be an email or an SMS.
The contents of the message is not important, its just that we trigger the appropriate message delivery method.
Create an rails API endpoint to transition a provisional booking to the confirmed state.
PATCH /api/v1/bookings/:id/confirm
name | value | required |
---|---|---|
send_confirmation_msg | Boolean | N |
confirmation_type | String (email, sms) | N |
-
Update the booking state from
provisional
toconfirmed
(see confirmation rules) -
Set the timestamp for
confirmed_at
and who the user confirming the booking is -
Send a confirmation notification to:
a. The user associated with the booking
b. The host associated with the booking (if the host is present)
- If
send_confirmation_msg
param is present then a confirmation message should be sent to both the booking user and the booking host - If
confirmation_type
param is set to:sms
then send a SMS (useSMSSender.new(number, msg).deliver
- its in the lib directory) - If
confirmation_type
param is set to:email
then send a email - If
confirmation_type
is not set then send an email
A booking will transition through many states in its lifetime.
State | Description |
---|---|
Provisional | Booking has just been made |
Confirmed | Admin has confirmed bookings or user has paid for the booking |
Cancelled | Admin or user has cancelled the booking |
Expired | Booking was not confirmed and is in the past |
- Unapproved users cannot approve bookings
- Users can only approved their own bookings
- Bookings in the past cannot be confirmed
- Confirmed bookings cannot be re-confirmed
- Cancelled bookings cannot be confirmed
- Expired bookings cannot be confirmed
- Appropriate test coverage
- Design considerations
- Git history
We're looking for candidates to spend longer no than an hour working on this task.
Clone the repo and submit a zip file back via email (don't fork as other candidates will then see the code samples)