โครงสร้างคำขอ
คำขอ BatchAvailabilityLookup สามารถครอบคลุมบริการหลายรายการสำหรับผู้ขายรายเดียวกัน และช่วงเวลาที่ขอสามารถครอบคลุมทรัพยากรและวันต่างๆ ได้ เราขอแนะนำให้ใช้รหัสบริการเดียวในผู้ขายเพื่อลดความซับซ้อนในการผสานรวม
เวลาตอบสนอง
คำขอ 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 สำหรับช่วงเวลาที่เฉพาะเจาะจง เซิร์ฟเวอร์การจองจะแสดงการตอบกลับพร้อมช่วงเวลาที่ว่างจริงในปัจจุบัน การตอบกลับที่คาดไว้คือ False สำหรับความพร้อมให้บริการ หากช่วงเวลาดังกล่าวถูกผู้ใช้ Google รายอื่นจองไว้ ภายในระบบของคุณเอง หรือระหว่างคำขอการโหลดหน้าเว็บกับคำขอคลิกช่วงเวลา
คำขอคลิกช่วงเวลา
{
"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"
}
}
]
}