| # Java client example for real-time updates using RESTful calls |
| |
| ### Prerequisite: |
| |
| Have your service account created, download your private key. |
| |
| ### Get started: |
| |
| 1. Download the [Java client |
| library](https://dl.google.com/mapsbooking/apiclients/v1alpha/mapsbooking_java_public.zip) |
| , unzip the file to get the 'mapsbooking' package. |
| |
| 2. Create a java project in your IDE, retrieve the sample codes |
| (InventoryUpdate.java & BookingNotification.java) from this repo: |
| |
| git clone https://maps-booking.googlesource.com/java-maps-booking-api-example |
| |
| import them into your java project under src directory. |
| |
| 3. Make a copy of your private key (JSON file) to the src directory. |
| |
| 4. Add the Java Client Library to the dependencies of your project (include jar |
| files under mapsbooking and libs-sources directory). |
| |
| 5. In both java files, follow the TODOs to complete your implementations. |
| |
| More detail about the REST API can be found |
| [here.](https://developers.google.com/maps-booking/reference/maps-booking-api/rest/) |
| |
| ### Troubleshooting: |
| |
| 1. Create a merchant/service with existing merchantId/serviceId, your will get |
| following error message: 409 Conflict { "code" : 409, "errors" : \[ { |
| "domain" : "global", "message" : "Requested entity already exists", |
| "reason" : "alreadyExists", "debugInfo" : "detail: \"\[ORIGINAL ERROR\] |
| generic::already_exists: ..."\n" } \], "message" : "Requested entity already |
| exists", "status" : "ALREADY_EXISTS" } |
| |
| 2. Update/Delete with wrong merchantId/serviceId (update with wrong bookingId), |
| your will get following error message: 404 Not Found { "code" : 404, |
| "errors" : \[ { "domain" : "global", "message" : "Requested entity was not |
| found.", "reason" : "notFound", "debugInfo" : "detail: \"\[ORIGINAL ERROR\] |
| spanner::Row not found:...\"\n" } \], "message" : "Requested entity was not |
| found.", "status" : "NOT_FOUND" } |
| |
| 3. In all update functions, the parameter 'updateMask' must be in |
| [FieldMask](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask) |
| format to specify the fields to update. The API is required to only change |
| the values of the fields as specified in the mask and leave the others |
| untouched. If you pass the wrong updateMask string, the update will not take |
| effect. If a field mask is not present on update, the operation applies to |
| all fields (as if a field mask of all fields has been specified). So if you |
| want to update all fields, just set the updateMask empty. |
| |
| 4. Since an Availability Slot is not associated with a merchant_id/service_id, |
| if you make the replace availability calls with invalid |
| merchant_id/service_id, you will be able to make the REST call without any |
| issue, but your request will not be served in the production due to the |
| invalid merchant_id/service_id. |
| |
| 5. Any field that has a zero value is not shown in the response. |