การค้นหาสถานะผู้ขายผ่าน API

Use Case

Google Maps Booking API มี 2 วิธีที่คุณสามารถใช้เพื่อเรียกดูสถานะผู้ขายแต่ละรายแบบเป็นโปรแกรมสำหรับการผสานรวม Actions Center ต่างๆ หรือพื้นที่โฆษณาในโฆษณาบริการในพื้นที่

กรณีการใช้งานสำหรับ Merchant Status API

  • ปรับปรุงเครื่องมือการจัดการลูกค้าสัมพันธ์ที่มีอยู่เพื่อแสดงให้ลูกค้าเห็นวิธีการแสดงสินค้าคงคลังในแพลตฟอร์ม Actions Center
  • สร้างหน้าแดชบอร์ดเพื่อติดตามสถานะสินค้าคงคลังและสถานะการจับคู่ของผู้ขาย
  • ดึงข้อมูลสถานะการจับคู่และการจองได้แบบเป็นโปรแกรมของผู้ขาย แล้วแก้ไขข้อมูลที่ไม่ถูกต้องเพื่อปรับปรุงคุณภาพข้อมูล

สถานะผู้ขายประกอบด้วยอะไรบ้าง

MerchantStatus ประกอบด้วยข้อมูลต่อไปนี้

  • สถานะสินค้าคงคลังของผู้ขาย: มีผลกับทั้งผู้ขายที่จองและ/หรือเข้าคิวรอ
  • สถานะการจับคู่ผู้ขาย: มีรายละเอียดเกี่ยวกับข้อมูลธุรกิจที่ตรงกัน
  • สำหรับโฆษณาบริการในพื้นที่ของ Google เท่านั้น) ผู้ให้บริการผู้ขายที่ตรงกัน: ประกอบด้วยรหัสลูกค้าและหมวดหมู่บริการ
  • URL ที่สาธิตวิธีที่ผู้ขายปรากฏผ่าน "จองกับ Google"

ค้นหาสถานะผู้ขายรายเดียว

คุณรับสถานะผู้ขายรายเดียวได้โดยใช้ inventory.partners.merchants.getStatus ดังนี้

GET https://mapsbooking.googleapis.com/v1alpha/inventory/partners/{partnerId}/merchants/{merchantId}/status

ตัวอย่างโค้ด Python มีดังนี้ (ดูตัวอย่างในภาษาอื่นๆ ที่นี่)

from google.auth.transport.requests import AuthorizedSession
from google.oauth2 import service_account

credentials = service_account.Credentials.from_service_account_file(
    './your_key.json')
scoped_credentials = credentials.with_scopes(
    ['https://www.googleapis.com/auth/mapsbooking'])
authed_session = AuthorizedSession(scoped_credentials)

response = authed_session.get('https://partnerdev-mapsbooking.googleapis.com' +
    '/v1alpha/inventory/partners/123456789/merchants/001/status')

ตัวอย่างการตอบกลับ MerchantStatus จะมีลักษณะดังนี้

  {
    "name": "partners/123456789/merchants/001/status",
    "merchantName": "Foo Bar Restaurant",
    "inputGeoInfo": {
      "unstructured_address": "123 Foo Bar Street, Mountain View"
    },
    "processingStatus": "COMPLETED",
    "bookingStatus": {
      "hasValidFutureInventory": true
    },
    "waitlistStatus": {
      "hasValidWaitlistService": true
    }
    "geoMatch": {
      "name": "Foo Bar Restaurant",
      "formattedAddress": "123 Foo Bar St, Mountain View, CA 94043",
      "placeId": "ChIAAAAAAAAABBBBBBBB"
    },
    "directUrls": [
      {
        "type": "BOOKING",
        "url": "https://reserve-partnerdev.sandbox.google.com/maps/reserve/v/dine/m/Nwaaaaa"
      },
      {
        "type": "WAITLIST",
        "url": "https://reserve-partnerdev.sandbox.google.com/maps/reserve/v/wait/c/iDbbbbb"
      }
    ]
  }

ดึงข้อมูลสถานะผู้ขายจำนวนมาก

คุณเรียกดูสถานะของผู้ขายทั้งหมดหรือกลุ่มผู้ขายที่ตรงตามเงื่อนไขสินค้าคงคลัง/การจับคู่บางอย่างได้โดยใช้ inventory.partners.merchants.status.list ตัวอย่างเช่น คุณเรียกใช้การเรียกนี้เพื่อขอผู้ขายทั้งหมดที่ไม่ตรงกันซึ่งมีสินค้าคงคลังสำหรับการจองโดยกำหนดวันที่ในอนาคตที่ถูกต้องได้

GET https://mapsbooking.googleapis.com/v1alpha/inventory/partners/{partnerId}/merchants/status?pageSize=50&bookingInventoryStatusRestrict=HAS_VALID_FUTURE_INVENTORY&geoMatchRestrict=GEO_UNMATCHED

คำตอบตัวอย่างจะมีลักษณะดังนี้

  {
    "merchantStatuses": [
      {
        "name": "partners/123456789/merchants/002/status",
        "merchantName": "Bar Foo Restaurant",
        "inputGeoInfo": {
          "unstructured_address": "234 Bar Foo Street, Mountain View"
        },
        "processingStatus": "COMPLETED",
        "bookingStatus": {
          "hasValidFutureInventory": true
        },
        "waitlistStatus": {},
      },
      ...
      {
        "name": "partners/123456789/merchants/080/status",
        "merchantName": "Baz Restaurant",
        "inputGeoInfo": {
          "unstructured_address": "345 Baz Street, Mountain View"
        },
        "processingStatus": "COMPLETED",
        "bookingStatus": {
          "hasValidFutureInventory": true
        },
        "waitlistStatus": {
          "hasValidWaitlistService": true
        },
      },
    ],
    "nextPageToken": "AAABBBB"
  }

การตอบกลับนี้จะมี MerchantStatus 50 รายการที่ตรงตามเงื่อนไขการกรองและเรียงลำดับตาม merchant_id การตอบกลับจะมีโทเค็นของหน้าด้วย (หากไม่ใช่หน้าสุดท้าย) สําหรับค้นหาหน้าถัดไป

โปรดทราบว่าเงื่อนไขการกรองควรสอดคล้องกันในทุกหน้า

แนวทางปฏิบัติแนะนำ

เนื่องจากสถานะผู้ขายไม่ได้เปลี่ยนแปลงบ่อยในเกือบทุกกรณี เราจึงขอแนะนำให้แคชผลลัพธ์ที่ดึงมาและดึงข้อมูลเป็นระยะๆ (เช่น ทุก 2-3 ชั่วโมง) ผ่านการค้นหาใหม่ Actions Center อาจควบคุมการค้นหาหากจำนวนคำขอต่อวินาทีสูงเกินไป