Java Sample Client

You can download our Java real time update API client to help get started implementing the real time updates.

Prerequisite:

Have your service account created, download your private key.

Get started:

  1. Download the Java client library unzip the file to get the ‘mapsbooking’ package.
  2. Create a java project in your IDE, download the sample codes InventoryUpdate.java and BookingNotification.java from this repo:

    git clone https://maps-booking.googlesource.com/java-maps-booking-api-example

    and 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.

Troubleshooting:

  1. When trying to create a new merchant/service with an existing merchantId or serviceId, you will get the 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. When making a replace availaiblity call with an invalid merchantId or serviceId, the call will not throw an error message. This is because changes to availability slots via RTUs support out-of-order execution and thus is not associated with a merchantId or serviceId. However, the slots in the request will not be served in the production due to the invalid merchantId or serviceId. To make the slots servable, please add the missing merchant or service via RTUs or feeds.
  3. In all update functions, the parameter ‘updateMask’ must be in 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. Any field that has a zero value is not shown in the response.