即時更新

即時更新功能可讓你的商品目錄與 Google 保持同步。您可以近乎即時地推送增量更新。系統會彙整動態消息和 RTU 的變更,向使用者顯示最新資訊。

API 端點

如要推送或刪除即時更新,請使用下列 REST API 端點:

批次推送

  • 沙箱:https://partnerdev-mapsbooking.googleapis.com/v1alpha/inventory/partners/{partner_id}/feeds/google.offer/record:batchPush
  • 正式版:https://mapsbooking.googleapis.com/v1alpha/inventory/partners/{partner_id}/feeds/google.offer/record:batchPush

批次刪除

  • 沙箱:https://partnerdev-mapsbooking.googleapis.com/v1alpha/inventory/partners/{partner_id}/feeds/google.offer/record:batchDelete
  • 正式版:https://mapsbooking.googleapis.com/v1alpha/inventory/partners/{partner_id}/feeds/google.offer/record:batchDelete

如要進一步瞭解 Offer JSON 物件定義,請參閱「Offer」。如要進一步瞭解優惠屬性,請參閱優惠參考頁面

如何向 API 驗證

如要連線至 API,請參閱「透過 Maps Booking API 驗證」。

限制

使用即時更新 API 時,請注意下列限制:

  • 僅限 protoRecord:API 設定為僅使用 protoRecord (而非 dataRecord)。
  • 配額限制:這些 API 的配額為每個合作夥伴帳戶每分鐘 1500 個要求。每個要求最多可傳送 1000 筆記錄,用於新增或更新或刪除作業。
  • 實體對應限制:合作夥伴可以為每個方案傳送 1 個實體 ID 的更新。如要更新多個實體 ID 的相同方案,合作夥伴必須為每個 entityId 傳送 1 筆記錄。每筆記錄的 entityId 一律只能是單數。
  • 加購方案:由於實體對應限制,系統不支援透過 RTU 更新 addOnOfferApplicableToAllEntities 的加購方案,因此無法透過這種方式更新 (只能透過動態饋給)。

範例

批次更新範例

以下是透過 curl 推送即時更新的範例:

curl -X POST \
  -H "Authorization: Bearer $(gcloud auth application-default print-access-token --impersonate-service-account=test@myproject.gserviceaccount.com --scopes=https://www.googleapis.com/auth/mapsbooking)" \
  -H "Content-Type: application/json" \
  -d '{
  "records": [
    {
      "generationTimestamp": {
        "seconds": 100
      },
      "protoRecord": {
        "@type": "type.googleapis.com/madden.ingestion.offer.Offer",
        "offerId": "1",
        "entityIds": [
          "1234567890"
        ],
        "addOnOfferApplicableToAllEntities": false,
        "offerSource": "OFFER_SOURCE_AGGREGATOR",
        "actionType": "ACTION_TYPE_FOOD_DELIVERY",
        "offerModes": [
          "OFFER_MODE_WALK_IN"
        ],
        "offerCategory": "OFFER_CATEGORY_BASE_OFFER",
        "tags": [
          "OFFER_TAG_NEW_YEAR_SPECIAL"
        ],
        "offerDetails": {
          "offerDisplayText": "FLAT 10% off",
          "offerSummaryText": "MONDAY TO FRIDAY",
          "discountPercent": 10
        },
        "offerRestrictions": {
          "combinableWithOtherOffers": true,
          "inclusions": [
            {
              "description": "complementary drink"
            },
            {
              "description": " starters"
            }
          ],
          "exclusions": [
            {
              "description": "taxes and Tips"
            }
          ]
        },
        "validityPeriods": [
          {
            "timeOfDay": {
              "timeWindows": [
                {
                  "openTime": {
                    "hours": 10
                  },
                  "closeTime": {
                    "hours": 20
                  }
                }
              ]
            },
            "validPeriod": {
              "validFromTime": {
                "seconds": 10
              }
            }
          }
        ],
        "offerUrl": "https://www.google.com/offer"
      }
    }
  ]
}' \
  https://partnerdev-mapsbooking.googleapis.com/v1alpha/inventory/partners/20000123/feeds/google.offer/record:batchPush

批次刪除範例

以下是透過 curl 刪除方案的範例:

curl -X POST \
  -H "Authorization: Bearer $(gcloud auth application-default print-access-token --impersonate-service-account=test@myproject.gserviceaccount.com --scopes=https://www.googleapis.com/auth/mapsbooking)" \
  -H "Content-Type: application/json" \
  -d '{
  "records": [
    {
      "deleteTime": {
        "seconds": 150
      },
      "protoRecord": {
        "@type": "type.googleapis.com/madden.ingestion.offer.Offer",
        "offerId": "1",
        "entityIds": [
          "1234567890"
        ]
      }
    }
  ]
}' \
  https://partnerdev-mapsbooking.googleapis.com/v1alpha/inventory/partners/20000123/feeds/google.offer/record:batchDelete