Java Booking API 클라이언트
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Java 실시간 업데이트 API 클라이언트를 다운로드하여 실시간 업데이트 구현을 시작할 수 있습니다.
선행 조건:
서비스 계정이 생성되면 비공개 키를 다운로드합니다.
시작하기:
- Java 클라이언트 라이브러리를 다운로드하고 파일의 압축을 풀어 'mapsbooking' 패키지를 가져옵니다.
-
IDE에서 Java 프로젝트를 만들고 이 저장소에서 샘플 코드 InventoryUpdate.java 및 BookingNotification.java를 다운로드합니다.
git clone https://maps-booking.googlesource.com/java-maps-booking-api-example
src 디렉터리의 Java 프로젝트로 가져옵니다.
- 비공개 키 (JSON 파일)의 사본을 src 디렉터리에 만듭니다.
- Java 클라이언트 라이브러리를 프로젝트의 종속 항목에 추가합니다(mapsbooking 및 libs-sources 디렉터리에 jar 파일 포함).
- 두 Java 파일 모두에서 TODO에 따라 구현을 완료합니다.
REST API에 관한 자세한 내용은 여기에서 확인하실 수 있습니다.
문제 해결:
-
기존 merchantId 또는 serviceId로 새 판매자/서비스를 만들려고 하면 다음 오류 메시지가 표시됩니다.
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”
}
- 잘못된 merchantId 또는 serviceId로 replace availability를 호출하면 호출에서 오류 메시지가 발생하지 않습니다. 이는 RTU를 통한 어베일러빌리티 슬롯 변경사항이 순서가 지정되지 않은 실행을 지원하므로 merchantId 또는 serviceId와 연결되지 않기 때문입니다. 하지만 잘못된 merchantId 또는 serviceId로 인해 요청의 슬롯이 프로덕션에 게재되지 않습니다. 시간대를 제공할 수 있도록 하려면 RTU 또는 피드를 통해 누락된 판매자 또는 서비스를 추가하세요.
- 모든 업데이트 함수에서 업데이트할 필드를 지정하려면 매개변수 'updateMask'가 FieldMask 형식이어야 합니다. API는 마스크에 지정된 대로 필드의 값만 변경하고 나머지는 그대로 두어야 합니다. 잘못된 updateMask 문자열을 전달하면 업데이트가 적용되지 않습니다. 업데이트 시 필드 마스크가 없으면 모든 필드의 필드 마스크가 지정된 것처럼 모든 필드에 작업이 적용됩니다. 따라서 모든 필드를 업데이트하려면 updateMask를 비워 두면 됩니다.
- 값이 0인 필드는 응답에 표시되지 않습니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[[["\u003cp\u003eDownload the Java real-time update API client and sample code to get started with implementing real-time updates for your booking services.\u003c/p\u003e\n"],["\u003cp\u003eYou will need a service account with a downloaded private key to use the client.\u003c/p\u003e\n"],["\u003cp\u003eThe client library allows you to manage inventory and booking notifications, and more details on the REST API are available in the documentation.\u003c/p\u003e\n"],["\u003cp\u003eTroubleshooting information is provided for common issues such as entity conflicts, invalid IDs, and update mask usage.\u003c/p\u003e\n"],["\u003cp\u003eRemember that zero-valued fields are not displayed in responses from the API.\u003c/p\u003e\n"]]],["Download the Java real-time update API client and library. Create a Java project, import the sample code files, `InventoryUpdate.java` and `BookingNotification.java`, and copy your private key to the `src` directory. Add the Java Client Library to your project dependencies. Follow the TODOs in the Java files to complete implementation. Be aware of 409 errors with existing IDs. Replace availability calls won't throw errors with invalid IDs. Ensure the 'updateMask' parameter is in FieldMask format in update functions.\n"],null,["# Java Booking API client\n\nYou can download our\n[Java real time update API client](https://maps-booking.googlesource.com/java-maps-booking-api-example/) to help get started implementing\nthe real time updates.\n\nPrerequisite:\n-------------\n\nHave your service account created, download your private key.\n\nGet started:\n------------\n\n1. Download the [Java client library](https://dl.google.com/mapsbooking/apiclients/v1alpha/mapsbooking_java_public.zip) unzip the file to get the 'mapsbooking' package.\n2. Create a java project in your IDE, download the sample codes\n [InventoryUpdate.java](https://maps-booking.googlesource.com/java-maps-booking-api-example/+/master/InventoryUpdate.java) and\n [BookingNotification.java](https://maps-booking.googlesource.com/java-maps-booking-api-example/+/master/BookingNotification.java) from this repo:\n\n ```java\n git clone https://maps-booking.googlesource.com/java-maps-booking-api-example\n ```\n\n and import them into your java project under src directory.\n3. Make a copy of your private key (JSON file) to the src directory.\n4. Add the Java Client Library to the dependencies of your project (include jar files under mapsbooking and libs-sources directory).\n5. In both java files, follow the TODOs to complete your implementations\n\nMore detail about the REST API can be\n[found here](/maps-booking/reference/maps-booking-api/rest).\n\nTroubleshooting:\n----------------\n\n1. When trying to create a new merchant/service with an existing merchantId or\n serviceId, you will get the following error message:\n\n ```java\n 409 Conflict\n {\n \"code\" : 409,\n \"errors\" :\n [{\n \"domain\" : \"global\",\n \"message\" : \"Requested entity already exists\",\n \"reason\" : \"alreadyExists\",\n \"debugInfo\" : \"detail: \"[ORIGINAL ERROR] generic::already_exists: ...\"\\n\"\n }],\n \"message\" : \"Requested entity already exists\",\n \"status\" : \"ALREADY_EXISTS\"\n }\n ```\n2. 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.\n3. In all update functions, the parameter 'updateMask' must be in [FieldMask](/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.\n4. Any field that has a zero value is not shown in the response."]]