added additional documentation for waitlist + BAL
diff --git a/README.md b/README.md index 97e87a5..6b07188 100644 --- a/README.md +++ b/README.md
@@ -20,6 +20,9 @@ into a proto file (api_v3.proto). Modify the package to match your project (com.partner.mapsbooking.v3.model). + * If implementing waitlist functionality, repeat the same steps with the + [Waitlist Proto Interface](https://developers.google.com/maps-booking/reference/rest-api-v3/waitlists/proto-bundle) + 2. Create a web application project in your IDE named booking_server_v3, add Maven support to this project. @@ -70,8 +73,11 @@ protoc --java_out=java resources/api_v3.proto + * If implementing waitlist functionality, also execute the following: + protoc --java_out=java resources/waitlist.proto + 5. Inside of the **src/main/java,** create a new package matching your groupId - (com.partner.mapsbooking). Retrieve the sample code from the repo: + (com.partner.mapsbooking). Retrieve the sample code from the repo: git clone https://maps-booking.googlesource.com/java-maps-booking-rest-server-v3-skeleton
diff --git a/rest/BookingService.java b/rest/BookingService.java index b7cc41a..9711f7b 100644 --- a/rest/BookingService.java +++ b/rest/BookingService.java
@@ -42,7 +42,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -/** Booking REST Server for API v3 with com.partner.mapsbooking.authentication. */ +/** Booking REST Server for API v3 with authentication. */ @Path("/v3") public class BookingService { @@ -106,16 +106,17 @@ public String batchAvailabilityLookup(String request) throws InvalidProtocolBufferException { // use JsonFormat.Parser to convert Json String into protocol buffer - ApiV3.BatchAvailabilityLookupRequest.Builder requestBuilder = ApiV3.BatchAvailabilityLookupRequest.newBuilder(); + ApiV3.BatchAvailabilityLookupRequest.Builder requestBuilder + = ApiV3.BatchAvailabilityLookupRequest.newBuilder(); JsonFormat.Parser jsonParser = JsonFormat.parser(); jsonParser.merge(request, requestBuilder); ApiV3.BatchAvailabilityLookupRequest batchAvailabilityLookupRequest = requestBuilder.build(); // Unexpected error: throw exception and handle it in BookingExceptionMapper class, // return corresponding response and HTTP code - // // Normal path: get response object from the helper function - ApiV3.BatchAvailabilityLookupResponse response = performBatchAvailabilityLookup(batchAvailabilityLookupRequest); + ApiV3.BatchAvailabilityLookupResponse response + = performBatchAvailabilityLookup(batchAvailabilityLookupRequest); // use JsonFormat to convert protocol buffer to Json String jsonResponse = jsonPrinter().print(response); @@ -123,7 +124,8 @@ } // TODO(partner): Implement this method to perform batch availability lookup - private ApiV3.BatchAvailabilityLookupResponse performBatchAvailabilityLookup(ApiV3.BatchAvailabilityLookupRequest request) { + private ApiV3.BatchAvailabilityLookupResponse performBatchAvailabilityLookup( + ApiV3.BatchAvailabilityLookupRequest request) { // BatchAvailabilityLookup logic: // e.g. // String merchantId = request.getMerchantId(); @@ -137,15 +139,15 @@ // e.g // for (ApiV3.SlotTime slotTime : requestedSlotTimes) { // slotTimeAvailabilities.add(SlotTimeAvailability.newBuilder() - // .setSlotTime(slotTime) - // .setAvailable(true) - // .build()); + // .setSlotTime(slotTime) + // .setAvailable(true) + // .build()); // } // // ApiV3.BatchAvailabilityLookupResponse response = - // ApiV3.BatchAvailabilityLookupResponse.newBuilder() + // ApiV3.BatchAvailabilityLookupResponse.newBuilder() // .addAllSlotTimeAvailability(slotTimeAvailabilities).build(); - + // // return response; throw new UnsupportedOperationException("Not implemented yet"); @@ -430,7 +432,7 @@ // Create order business logic: // e.g. // ApiV3.Order order = request.getOrder(); - + // // normal case -> create this order in the backend, return response: // ApiV3.CreateOrderResponse response = ApiV3.CreateOrderResponse.newBuilder() // .setOrder(order) @@ -503,9 +505,9 @@ /** * Waitlist Implementation - * Proto File - https://developers.google.com/maps-booking/reference/rest-api-v3/waitlists/proto-bundle - * - * */ + * Proto File - + * https://developers.google.com/maps-booking/reference/rest-api-v3/waitlists/proto-bundle + */ @Path("/BatchGetWaitEstimates") @POST @Produces(MediaType.APPLICATION_JSON) @@ -513,7 +515,8 @@ public String batchGetWaitEstimates(String request) throws InvalidProtocolBufferException { // use JsonFormat.Parser to convert Json String into protocol buffer - Waitlist.BatchGetWaitEstimatesRequest.Builder requestBuilder = Waitlist.BatchGetWaitEstimatesRequest.newBuilder(); + Waitlist.BatchGetWaitEstimatesRequest.Builder requestBuilder + = Waitlist.BatchGetWaitEstimatesRequest.newBuilder(); JsonFormat.Parser jsonParser = JsonFormat.parser(); jsonParser.merge(request, requestBuilder); Waitlist.BatchGetWaitEstimatesRequest batchGetWaitEstimatesRequest = requestBuilder.build(); @@ -522,7 +525,8 @@ // return corresponding response and HTTP code // // Normal path: get response object from the helper function - Waitlist.BatchGetWaitEstimatesResponse response = performBatchGetWaitEstimates(batchGetWaitEstimatesRequest); + Waitlist.BatchGetWaitEstimatesResponse response + = performBatchGetWaitEstimates(batchGetWaitEstimatesRequest); // use JsonFormat to convert protocol buffer to Json String jsonResponse = jsonPrinter().print(response); @@ -530,15 +534,16 @@ } // TODO(partner): Implement this method to return wait estimates based on party size - private Waitlist.BatchGetWaitEstimatesResponse performBatchGetWaitEstimates(Waitlist.BatchGetWaitEstimatesRequest request) { - + private Waitlist.BatchGetWaitEstimatesResponse performBatchGetWaitEstimates( + Waitlist.BatchGetWaitEstimatesRequest request) { // String merchantId = request.getMerchantId(); // String serviceId = request.getServiceId(); // // List<Integer> requestedPartySizes = request.getPartySizeList(); // - // Waitlist.BatchGetWaitEstimatesResponse response = Waitlist.BatchGetWaitEstimatesResponse.newBuilder().setWaitlistStatus( - // WaitlistStatus.OPEN).addAllWaitEstimate(...).build(); + // Waitlist.BatchGetWaitEstimatesResponse response + // = Waitlist.BatchGetWaitEstimatesResponse.newBuilder().setWaitlistStatus( + // WaitlistStatus.OPEN).addAllWaitEstimate(...).build(); // // return response; @@ -552,7 +557,8 @@ public String createWaitlistEntry(String request) throws InvalidProtocolBufferException { // use JsonFormat.Parser to convert Json String into protocol buffer - Waitlist.CreateWaitlistEntryRequest.Builder requestBuilder = Waitlist.CreateWaitlistEntryRequest.newBuilder(); + Waitlist.CreateWaitlistEntryRequest.Builder requestBuilder + = Waitlist.CreateWaitlistEntryRequest.newBuilder(); JsonFormat.Parser jsonParser = JsonFormat.parser(); jsonParser.merge(request, requestBuilder); Waitlist.CreateWaitlistEntryRequest createWaitlistEntryRequest = requestBuilder.build(); @@ -561,7 +567,8 @@ // return corresponding response and HTTP code // // Normal path: get response object from the helper function - Waitlist.CreateWaitlistEntryResponse response = performCreateWaitlistEntry(createWaitlistEntryRequest); + Waitlist.CreateWaitlistEntryResponse response + = performCreateWaitlistEntry(createWaitlistEntryRequest); // use JsonFormat to convert protocol buffer to Json String jsonResponse = jsonPrinter().print(response); @@ -569,26 +576,28 @@ } // TODO(partner): Implement this method to create wait list entry based on request - private Waitlist.CreateWaitlistEntryResponse performCreateWaitlistEntry(Waitlist.CreateWaitlistEntryRequest request) { - + private Waitlist.CreateWaitlistEntryResponse performCreateWaitlistEntry( + Waitlist.CreateWaitlistEntryRequest request) { // String merchantId = request.getMerchantId(); // String serviceId = request.getServiceId(); // int partySize = request.getPartySize(); // // Waitlist.UserInformation userInformation = request.getUserInformation(); // String idempotencyToken = request.getIdempotencyToken(); - - // Normal Case -> return a unique waitlist_entry_id e.g - // Waitlist.CreateWaitlistEntryResponse response = Waitlist.CreateWaitlistEntryResponse.newBuilder() - // .setWaitlistEntryId(...).build(); - - // Business logic error -> set the WaitlistBusinessLogicFailure in the response - - // Waitlist.WaitlistBusinessLogicFailure waitlistBusinessLogicFailure = Waitlist.WaitlistBusinessLogicFailure.newBuilder() - // .setCause(Cause.WAITLIST_FULL).setDescription("").build(); // - // Waitlist.CreateWaitlistEntryResponse response = Waitlist.CreateWaitlistEntryResponse.newBuilder() - // .setWaitlistBusinessLogicFailure(waitlistBusinessLogicFailure).build(); + // Normal Case -> return a unique waitlist_entry_id e.g + // Waitlist.CreateWaitlistEntryResponse response + // = Waitlist.CreateWaitlistEntryResponse.newBuilder().setWaitlistEntryId(...).build(); + // + // Business logic error -> set the WaitlistBusinessLogicFailure in the response + // + // Waitlist.WaitlistBusinessLogicFailure waitlistBusinessLogicFailure + // = Waitlist.WaitlistBusinessLogicFailure.newBuilder() + // .setCause(Cause.WAITLIST_FULL).setDescription("").build(); + // + // Waitlist.CreateWaitlistEntryResponse response + // = Waitlist.CreateWaitlistEntryResponse.newBuilder() + // .setWaitlistBusinessLogicFailure(waitlistBusinessLogicFailure).build(); // // return response; @@ -602,7 +611,8 @@ public String getWaitlistEntry(String request) throws InvalidProtocolBufferException { // use JsonFormat.Parser to convert Json String into protocol buffer - Waitlist.GetWaitlistEntryRequest.Builder requestBuilder = Waitlist.GetWaitlistEntryRequest.newBuilder(); + Waitlist.GetWaitlistEntryRequest.Builder requestBuilder + = Waitlist.GetWaitlistEntryRequest.newBuilder(); JsonFormat.Parser jsonParser = JsonFormat.parser(); jsonParser.merge(request, requestBuilder); Waitlist.GetWaitlistEntryRequest getWaitlistEntryRequest = requestBuilder.build(); @@ -611,7 +621,8 @@ // return corresponding response and HTTP code // // Normal path: get response object from the helper function - Waitlist.GetWaitlistEntryResponse response = performGetWaitlistEntryRequest(getWaitlistEntryRequest); + Waitlist.GetWaitlistEntryResponse response + = performGetWaitlistEntry(getWaitlistEntryRequest); // use JsonFormat to convert protocol buffer to Json String jsonResponse = jsonPrinter().print(response); @@ -619,8 +630,8 @@ } // TODO(partner): Implement this method to return waitlist entry - private Waitlist.GetWaitlistEntryResponse performGetWaitlistEntryRequest(Waitlist.GetWaitlistEntryRequest request) { - + private Waitlist.GetWaitlistEntryResponse performGetWaitlistEntry( + Waitlist.GetWaitlistEntryRequest request) { // String waitlistEntryId = request.getWaitlistEntryId(); // // Waitlist.GetWaitlistEntryResponse response = Waitlist.GetWaitlistEntryResponse.newBuilder() @@ -638,7 +649,8 @@ public String deleteWaitlistEntry(String request) throws InvalidProtocolBufferException { // use JsonFormat.Parser to convert Json String into protocol buffer - Waitlist.DeleteWaitlistEntryRequest.Builder requestBuilder = Waitlist.DeleteWaitlistEntryRequest.newBuilder(); + Waitlist.DeleteWaitlistEntryRequest.Builder requestBuilder + = Waitlist.DeleteWaitlistEntryRequest.newBuilder(); JsonFormat.Parser jsonParser = JsonFormat.parser(); jsonParser.merge(request, requestBuilder); Waitlist.DeleteWaitlistEntryRequest deleteWaitlistEntryRequest = requestBuilder.build(); @@ -656,10 +668,10 @@ private void performDeleteWaitlistEntry(Waitlist.DeleteWaitlistEntryRequest request) { // String waitlistEntryId = request.getWaitlistEntryId(); - // If waitlist entry Id exists, delete it - // If waitlist entry id doesn't exist, return 404 - // throw new WebApplicationException(400); + // throw new WebApplicationException(404); + + throw new UnsupportedOperationException("Not implemented yet"); } -} \ No newline at end of file +}