请求结构
BatchAvailabilityLookup 请求可以涵盖同一商家的多项服务,并且请求的空档可以涵盖多个资源和日期。我们建议您在所有商家中使用单个服务 ID,以简化集成。
响应时间
在被视为失败之前,BatchAvailabilityLookup 请求的延迟时间阈值为 1.5 秒。请确保您的内部网络和 DNS 路由已同步,以最大限度地减少到达基础架构的请求中的任何延迟。如果出现严重的超时错误,您的集成可能会被下线,直到您解决这些错误为止。
对请求的每次响应都必须返回您当时广告资源的实际状态,而不是预订流程的进入时间。如果某个空档已预订完毕,请在当前响应中反映这一点。
定义
BatchAvailabilityLookup 方法可验证在预订流程中仅向用户显示当前空档。
BatchAvailabilityLookup 请求
message BatchAvailabilityLookupRequest {
// ID of the merchant.
string merchant_id = 1;
// Multiple slot times to be checked for availability. All queried times apply
// to the same merchant_id and service_id.
repeated SlotTime slot_time = 3;
reserved 2;
}
BatchAvailabilityLookup 响应
// Response for the [ext.maps.booking.partner.v3.BatchAvailabilityLookupRequest]
// RPC with the availabilities of the appointment slots.
message BatchAvailabilityLookupResponse {
// The availabilities for the requested SlotTime entries. There must be
// exactly one slot_time_availability for each SlotTime entry in the
// [ext.maps.booking.partner.v3.BatchAvailabilityLookupRequest].
repeated SlotTimeAvailability slot_time_availability = 1;
}
SlotTime
// Identifies a Slot service_id and start time and optionally, the Slot duration
// and resources, for a specific merchant. Note that this differs from the
// definition of Slot, as it does not include merchant_id identifier.
message SlotTime {
// ID of the service. (required)
string service_id = 5;
// Start time of the appointment slot in seconds of UTC time since Unix epoch
// (required)
int64 start_sec = 1;
// Duration of the appointment slot in seconds (optional)
int64 duration_sec = 2;
// Opaque tag that identifies the availability slot and matches the value
// provided in the Availability Feed (optional)
string availability_tag = 3;
// The set of resources that specifies the appointment slot, e.g. by
// indicating the staff member and room selected by the user, or party size
// for dining slots (optional)
ResourceIds resource_ids = 4;
// Indicates whether bookings of this slot will be confirmed
// synchronously or asynchronously. (optional)
// An UNSPECIFIED value will be interpreted as synchronous.
ConfirmationMode confirmation_mode = 6;
}
SlotTimeAvailability
如果未找到任何空档,请返回空响应。请勿返回 400 错误,而是可以返回 204 或其他 2xx 代码。它会验证响应是否已正确收到。
message SlotTimeAvailability {
// The SlotTime for which availability was checked.
SlotTime slot_time = 1;
// Whether the requested SlotTime is available
bool available = 2;
}
BatchAvailabilityLookup 示例
网页加载
当用户点击在线预订 以启动预订流程时,系统会发送 BatchAvailabilityLookup 请求,其中包含商家的已知可用空档。对于请求中发送的每个空档,您的预订服务器都会返回一个响应,其中包含该空档的实际当前可用性。前端仅向用户显示可用空档。
如果用户更改了同行人数或选择了其他日期,则可以发送另一个网页加载请求。
网页加载请求
{
"merchant_id" : "1234",
"slot_time" : [
{
"duration_sec" : "1800",
"resource_ids" : {
"party_size" : 2
},
"service_id" : "1000",
"start_sec" : "1606467600"
},
{
"duration_sec" : "1800",
"resource_ids" : {
"party_size" : 2
},
"service_id" : "1000",
"start_sec" : "1606469400"
},
{
"duration_sec" : "1800",
"resource_ids" : {
"party_size" : 2
},
"service_id" : "1000",
"start_sec" : "1606471200"
}
]
}
网页加载响应
{ "slot_time_availability" :
[
{
"available" : true,
"slot_time" : {
"duration_sec" : "1800",
"resource_ids" : {
"party_size" : 2 },
"service_id" : "1000",
"start_sec" : "1606467600" }
},
{
"available" : true,
"slot_time" : {
"duration_sec" : "1800",
"resource_ids" : {
"party_size" : 2 },
"service_id" : "1000",
"start_sec" : "1606469400" }
},
{
"available" : false,
"slot_time" : {
"duration_sec" : "1800",
"resource_ids" : {
"party_size" : 2 },
"service_id" : "1000",
"start_sec" : "1606471200" }
}
]
}
空档点击
当用户选择可预订的空档时,系统会针对该特定空档发送 BatchAvailabilityLookup 请求。您的预订服务器会返回一个响应,其中包含该空档的实际当前可用性。如果该空档已被其他 Google 用户、您的系统内部或在网页加载和空档点击请求之间预订完毕,则可用性的预期响应为 False 。
空档点击请求
{
"merchant_id" : "1234",
"slot_time" : [
{
"duration_sec" : "1800",
"resource_ids" : {
"party_size" : 2
},
"service_id" : "1000",
"start_sec" : "1606467600"
}
]
}
空档点击响应
{
"slot_time_availability" : [
{
"available" : true,
"slot_time" : {
"duration_sec" : "1800",
"resource_ids" : {
"party_size" : 2
},
"service_id" : "1000",
"start_sec" : "1606467600"
}
}
]
}