ตัวอย่างและคำจำกัดความของ BatchAvailabilityLookup

โครงสร้างคำขอ

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"
          }
       }
    ]
 }