Contoh dan Definisi BatchAvailabilityLookup

Struktur permintaan

Permintaan BatchAvailabilityLookup dapat mencakup beberapa layanan untuk penjual yang sama, dan slot yang diminta dapat mencakup beberapa sumber daya dan hari. Sebaiknya gunakan satu ID Layanan di seluruh penjual untuk menyederhanakan integrasi Anda.

Waktu respons

Permintaan BatchAvailabilityLookup memiliki batas latensi 1,5 detik sebelum respons dianggap gagal. Pastikan perutean DNS dan jaringan internal Anda disinkronkan untuk meminimalkan penundaan dalam permintaan yang mencapai infrastruktur Anda. Jika ada error waktu tunggu yang signifikan, integrasi Anda mungkin dinonaktifkan hingga Anda dapat menyelesaikannya.

Setiap respons terhadap permintaan harus menampilkan status inventaris Anda yang sebenarnya pada saat itu, bukan saat alur pemesanan dimasukkan. Jika slot sudah dipesan, tampilkan hal tersebut dalam respons saat ini.

Definisi

Metode BatchAvailabilityLookup memverifikasi bahwa hanya slot saat ini yang ditampilkan kepada pengguna selama alur reservasi.

Permintaan 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;
}

Respons 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

Jika tidak ada slot yang ditemukan, tampilkan respons kosong. Jangan menampilkan error 400, sebaliknya Anda dapat menampilkan kode 204 atau kode 2xx lainnya. Hal ini memverifikasi bahwa respons diterima dengan benar.

message SlotTimeAvailability {
  // The SlotTime for which availability was checked.
  SlotTime slot_time = 1;

  // Whether the requested SlotTime is available
  bool available = 2;
}

Contoh BatchAvailabilityLookup

Pemuatan halaman

Saat pengguna mengklik Pesan Online untuk memulai alur pemesanan, permintaan BatchAvailabilityLookup akan dikirim dengan slot ketersediaan yang diketahui untuk penjual. Untuk setiap slot yang dikirim dalam permintaan, Server Pemesanan Anda akan menampilkan respons dengan ketersediaan slot saat ini yang sebenarnya. Hanya slot yang tersedia yang ditampilkan kepada pengguna di frontend.

Jika pengguna mengubah ukuran grupnya atau memilih tanggal lain, permintaan pemuatan halaman lain dapat dikirim.

Permintaan pemuatan halaman

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

Respons pemuatan halaman

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

Klik slot

Saat pengguna memilih slot yang dapat dipesan, permintaan BatchAvailabilityLookup akan dikirim untuk slot tertentu. Server Pemesanan Anda menampilkan respons dengan ketersediaan slot saat ini yang sebenarnya. Respons yang diharapkan adalah False untuk ketersediaan jika slot tersebut sudah dipesan oleh pengguna Google lain, secara internal dalam sistem Anda atau antara permintaan pemuatan halaman dan klik slot.

Permintaan klik slot

 {
    "merchant_id" : "1234",
    "slot_time" : [
       {
          "duration_sec" : "1800",
          "resource_ids" : {
             "party_size" : 2
          },
          "service_id" : "1000",
          "start_sec" : "1606467600"
       }
    ]
 }

Respons klik slot

 {
    "slot_time_availability" : [
       {
          "available" : true,
          "slot_time" : {
           "duration_sec" : "1800",
             "resource_ids" : {
                "party_size" : 2
             },
             "service_id" : "1000",
             "start_sec" : "1606467600"
          }
       }
    ]
 }