Created
April 10, 2021 06:37
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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