Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Generic update API
public class Booking {
String uniqueId;
User guest;
User host;
Date bookingTime;
Date confirmationTime;
Date cancellationTime;
User lastUpdatedBy;
public class BookingUpdateRequest {
Date updateTime;
Booking updatedBooking;
// In Booking Service
public void updateBooking(BookingUpdateRequest request) {
Booking originalBooking = readFromDB(request.updatedBooking.uniqueId);
if ((originalBooking.status == PENDING || originalBooking.status == CONFIRMED) &&
(request.updatedBooking.status == CANCELLED_BY_GUEST)) {
originalBooking.lastUpdatedBy = originalBooking.guest;
originalBooking.cancellationTime = request.updateTime
// Trigger notification to host
// Trigger refund if payment was taken
} else if ((originalBooking.status == PENDING || originalBooking.status == CONFIRMED) &&
(request.updatedBooking.status == CANCELLED_BY_HOST)) {
originalBooking.lastUpdatedBy =;
// Trigger notification to guest
// Trigger refund if payment was taken
// else if ........ more conditions to handle other combinations of new/old variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment