Skip to content

Instantly share code, notes, and snippets.

@kislayverma
Created April 10, 2021 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kislayverma/dfdd81fd63d6772cac33d462c9fe3fed to your computer and use it in GitHub Desktop.
Save kislayverma/dfdd81fd63d6772cac33d462c9fe3fed to your computer and use it in GitHub Desktop.
Specific cancellation APIs reveal the model by explain what all can be done
public class Booking {
String uniqueId;
User guest;
User host;
Date bookingTime;
Date confirmationTime;
Date cancellationTime;
Status status; //PENDING, CONFIRMED, CANCELLED_BY_GUEST, CANCELLED_BY_HOST
User lastUpdatedBy;
}
// In Booking Service
public void cancelBookingByGuest(String bookingId, Date cancellationTime) {
Booking originalBooking = readFromDB(bookingId);
originalBooking.lastUpdatedBy = originalBooking.guest;
originalBooking.cancellationTime = cancelltaionTime;
originalBooking.status = CANCELLED_BY_GUEST;
// Trigger notification to host
// Trigger refund if payment was taken
updateInDB(originalBooking);
}
public void cancelBookingByHost(String bookingId, Date cancellationTime) {
Booking originalBooking = readFromDB(bookingId);
originalBooking.lastUpdatedBy = originalBooking.host;
originalBooking.cancellationTime = cancellationTime;
originalBooking.status = CANCELLED_BY_HOST;
// Trigger notification to guest
// Trigger refund if payment was taken
updateInDB(originalBooking);
}
// Other APIs to handle combinations of new/old variables...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment