Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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