BatchAvailabilityLookup 範例和定義

要求結構

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