דוגמאות והגדרות של 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"
          }
       }
    ]
 }