بنية الطلب
يمكن أن تشمل طلبات 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"
}
}
]
}