การอัปเดตพื้นที่โฆษณาที่เพิ่มขึ้น v2

ส่วนนี้จะอธิบายวิธีส่งการอัปเดตรายการพื้นที่โฆษณาของคุณที่ขึ้นอยู่กับเวลาไปยัง Google API การอัปเดตที่เพิ่มขึ้นช่วยให้คุณพุชการอัปเดตและลบเอนทิตีในแซนด์บ็อกซ์หรือพื้นที่โฆษณาเวอร์ชันที่ใช้งานจริงได้แบบเกือบเรียลไทม์

ฟังก์ชันการทำงานนี้มีไว้เพื่อการอัปเดตที่คุณคาดการณ์ไม่ได้เป็นหลัก เช่น การปิดกรณีฉุกเฉิน ตามกฎแล้ว การเปลี่ยนแปลงที่ส่งผ่าน API การอัปเดตส่วนเพิ่มคือการเปลี่ยนแปลงที่ต้องเผยแพร่ภายในไม่เกิน 1 ชั่วโมง หากการเปลี่ยนแปลงไม่จำเป็นต้องมีผลทันที คุณใช้การส่งผ่านข้อมูลเป็นกลุ่มแทนได้ ระบบจะดำเนินการอัปเดตที่เพิ่มขึ้นภายในไม่เกิน 5 นาที

ข้อกำหนดเบื้องต้น

คุณต้องระบุรายการต่อไปนี้ก่อนจะใช้การอัปเดตเพิ่มเติม

  1. ระบบได้สร้างบัญชีบริการที่มีบทบาทผู้แก้ไขให้กับโปรเจ็กต์ Actions ดูรายละเอียดเพิ่มเติมได้ที่สร้างและตั้งค่าโปรเจ็กต์
  2. ฟีดข้อมูลการผลิตหรือแซนด์บ็อกซ์จะโฮสต์และนำเข้า ดูรายละเอียดเพิ่มเติมได้ที่การส่งผ่านข้อมูลเป็นกลุ่ม
  3. (ไม่บังคับ แต่แนะนำ) ติดตั้งไลบรารีของไคลเอ็นต์ Google ในภาษาที่คุณต้องการ เพื่อความสะดวกในการใช้ OAuth 2.0 เมื่อเรียกใช้ API ตัวอย่างโค้ดที่แสดงด้านล่างใช้ไลบรารีเหล่านี้ มิเช่นนั้น คุณจะต้องจัดการการแลกเปลี่ยนโทเค็นด้วยตนเองตามที่อธิบายไว้ในการใช้ OAuth 2.0 เพื่อเข้าถึง Google API

ปลายทาง

ในคำขอด้านล่าง ให้แทนที่รายการต่อไปนี้

  • PROJECT_ID: รหัสโปรเจ็กต์ Google Cloud ที่เชื่อมโยงกับโปรเจ็กต์ที่คุณสร้างไว้ในส่วนสร้างและตั้งโปรเจ็กต์
  • TYPE: ประเภทเอนทิตี (พร็อพเพอร์ตี้ @type) ของออบเจ็กต์ในฟีดข้อมูลที่คุณต้องการอัปเดต
  • ENTITY_ID (ลบปลายทางเท่านั้น): รหัสของเอนทิตีที่จะลบ ตรวจสอบว่าได้เข้ารหัส URL รหัสเอนทิตีแล้ว
  • DELETE_TIME (ลบปลายทางเท่านั้น): ช่องที่ไม่บังคับเพื่อระบุเวลาที่ลบเอนทิตีในระบบ (ค่าเริ่มต้นคือเมื่อได้รับคำขอ) ค่าเวลาต้องไม่ใช่วันที่ในอนาคต เมื่อส่งเอนทิตีผ่านการเรียกที่เพิ่มขึ้น การกำหนดเวอร์ชันเอนทิตีจะใช้ช่อง delete_time ในกรณีที่เป็นการเรียกใช้การลบ จัดรูปแบบค่านี้เป็น yyyy-mm-ddTHH:mm:ssZ

อัปเดตปลายทาง

หากต้องการแก้ไขเอนทิตี ให้ส่งคำขอ HTTP POST ไปยังปลายทางต่อไปนี้และรวมเพย์โหลดของการอัปเดตและการเพิ่ม คุณจะอัปเดตเอนทิตีได้สูงสุด 1,000 รายการในการเรียก API 1 ครั้ง

https://actions.googleapis.com/v2/apps/PROJECT_ID/entities:batchPush

ตัวอย่างเช่น หากคุณต้องการอัปเดตเอนทิตีในโปรเจ็กต์ที่มีรหัส "delivery-provider-id" ปลายทางจะเป็นดังนี้

https://actions.googleapis.com/v2/apps/delivery-provider-id/entities:batchpush

ลบปลายทาง

หากต้องการลบเอนทิตีในคลัง ให้ส่งคำขอ HTTP DELETE ไปยังปลายทางต่อไปนี้

https://actions.googleapis.com/v2/apps/PROJECT_ID/entities/TYPE/ENTITY_ID?entity.vertical=FOODORDERING&delete_time=DELETE_TIME

ตัวอย่างเช่น หากต้องการลบเอนทิตี " MenuSection" ที่มีรหัส "menuSection_122" จากโปรเจ็กต์ "delivery-provider-id" คุณต้องเรียก HTTP DELETE API ไปยัง

https://actions.googleapis.com/v2/apps/delivery-provider-id/entities/MenuSection/menuSection_122?entity.vertical=FOODORDERING

สภาพแวดล้อมแซนด์บ็อกซ์

หากต้องการใช้ API การอัปเดตที่เพิ่มขึ้นในพื้นที่แซนด์บ็อกซ์ ให้ทำตามวิธีการในปลายทางด้านบน แต่ส่งคำขอไปยัง /v2/sandbox/apps/ แทน /v2/apps/

https://actions.googleapis.com/v2/sandbox/apps/PROJECT_ID/entities:batchPush
https://actions.googleapis.com/v2/sandbox/apps/PROJECT_ID/entities/TYPE/ENTITY_ID?entity.vertical=FOODORDERING&delete_time=DELETE_TIME

การอัปเดตเอนทิตี

คำขอ POST แต่ละรายการต้องมีพารามิเตอร์คำขอ พร้อมด้วยเพย์โหลด JSON ที่มีข้อมูลที่มีโครงสร้างของเอนทิตีประเภทใดก็ตามที่แสดงอยู่ในสคีมาพื้นที่โฆษณา

อัปเดตเพย์โหลด

JSON ควรปรากฏเหมือนกับในฟีดกลุ่มโดยมีความแตกต่างดังต่อไปนี้

  • ส่วนเนื้อหาเพย์โหลดต้องมีขนาดไม่เกิน 5 MB เราขอแนะนำให้คุณตัดช่องว่างออกเพื่อให้มีข้อมูลมากขึ้นคล้ายกับฟีดแบบกลุ่ม
  • ซองจดหมายมีลักษณะดังต่อไปนี้
{
  "requests": [
    {
      "entity": {
        "data":"ENTITY_DATA",
        "name": "apps/project_id>/entities/type/entity_id"
      },
      "update_time":"UPDATE_TIMESTAMP"
    },
  ],
  "vertical": "FOODORDERING"
}

ในเพย์โหลดข้างต้น ให้แทนที่

  • ENTITY_DATA: เอนทิตีในรูปแบบ JSON ทำให้เป็นสตริง ต้องส่งเอนทิตี JSON-LD เป็นสตริงในช่อง data
  • UPDATE_TIMESTAMP (ไม่บังคับ): การประทับเวลาเมื่อมีการอัปเดตเอนทิตีในระบบ ค่าเวลาต้องไม่ใช่วันที่ในอนาคต การประทับเวลาเริ่มต้นคือเมื่อ Google ได้รับคำขอ เมื่อส่งเอนทิตีผ่านคำขอที่เพิ่มขึ้น การกำหนดเวอร์ชันเอนทิตีจะใช้ช่อง update_time ในกรณีที่เป็นคำขอเพิ่ม/อัปเดตด้วย

ตัวอย่าง

ตัวอย่างที่ 1: การอัปเดตร้านอาหาร

สมมติว่าคุณต้องอัปเดตหมายเลขโทรศัพท์ของร้านอาหารอย่างเร่งด่วน การอัปเดตของคุณมี JSON สำหรับทั้งร้านอาหาร

ลองใช้ฟีดแบบกลุ่มที่มีลักษณะดังนี้

{
  "@type": "Restaurant",
  "@id": "restaurant12345",
  "name": "Some Restaurant",
  "url": "https://www.provider.com/somerestaurant",
  "telephone": "+16501234567",
  "streetAddress": "345 Spear St",
  "addressLocality": "San Francisco",
  "addressRegion": "CA",
  "postalCode": "94105",
  "addressCountry": "US",
  "latitude": 37.472842,
  "longitude": -122.217144
}

การอัปเดตส่วนเพิ่มของคุณโดย HTTP POST จะเป็นดังนี้:

POST v2/sandbox/apps/provider-project/entities:batchPush
Host: actions.googleapis.com
Content-Type: application/ld+json
{
  "requests": [
    {
      "entity": {
        "name": "apps/provider-project/entities/restaurant/restaurant12345",
        "data": {
          "@type": "Restaurant",
          "@id": "restaurant12345",
          "name": "Some Restaurant",
          "url": "https://www.provider.com/somerestaurant",
          "telephone": "+16501235555",
          "streetAddress": "345 Spear St",
          "addressLocality": "San Francisco",
          "addressRegion": "CA",
          "postalCode": "94105",
          "addressCountry": "US",
          "latitude": 37.472842,
          "longitude": -122.217144
        }
      }
    }
  "vertical": "FOODORDERING"
}

ตัวอย่างที่ 2: การอัปเดตร้านอาหารหลายร้าน

หากต้องการอัปเดตเอนทิตีร้านอาหาร 2 รายการในการเรียก API เดียว คำขอ HTTP POST จะเป็นดังนี้

POST v2/sandbox/apps/provider-project/entities:batchPush
Host: actions.googleapis.com
Content-Type: application/ld+json
{
  "requests": [
    {
      "entity": {
        "name": "apps/provider-project/entities/restaurant/restaurant12345",
        "data": {
          "@type": "Restaurant",
          "@id": "restaurant12345",
          "name": "Some Restaurant",
          "url": "https://www.provider.com/somerestaurant",
          "telephone": "+16501235555",
          "streetAddress": "345 Spear St",
          "addressLocality": "San Francisco",
          "addressRegion": "CA",
          "postalCode": "94105",
          "addressCountry": "US",
          "latitude": 37.472842,
          "longitude": -122.217144
        }
      }
    },
    {
      "entity": {
        "name": "apps/provider-project/entities/restaurant/restaurant123",
        "data": {
          "@type": "Restaurant",
          "@id": "restaurant123",
          "name": "Some Other Restaurant",
          "url": "https://www.provider.com/somerestaurant",
          "telephone": "+16501231235",
          "streetAddress": "385 Spear St",
          "addressLocality": "San Mateo",
          "addressRegion": "CA",
          "postalCode": "94115",
          "addressCountry": "US"
        }
      }
    }
  ]
  "vertical": "FOODORDERING"
}

ตัวอย่างที่ 3: การอัปเดตราคารายการในเมนู

สมมติว่าคุณต้องเปลี่ยนราคารายการเมนู ตามตัวอย่างที่ 1 การอัปเดตต้องมี JSON สำหรับเอนทิตีระดับบนสุดทั้งหมด (เมนู) และฟีดใช้สคีมาพื้นที่โฆษณา v1

ลองใช้ฟีดแบบกลุ่มที่มีลักษณะดังนี้

{
  "@type": "MenuItemOffer",
  "@id": "menuitemoffer6680262",
  "sku": "offer-cola",
  "menuItemId": "menuitem896532",
  "price": 3.00,
  "priceCurrency": "USD"
}

การอัปเดตส่วนเพิ่มของคุณผ่านทาง POST จะเป็นดังนี้

POST v2/sandbox/apps/provider-project/entities:batchPush
Host: actions.googleapis.com
Content-Type: application/ld+json
{
  "requests": [
    {
      "entity": {
        "name": "apps/provider-project/entities/menuitemoffer/menuitemoffer6680262",
        "data": {
          "@type": "MenuItemOffer",
          "@id": "menuitemoffer6680262",
          "sku": "offer-cola",
          "menuItemId": "menuitem896532",
          "price": 1.00,
          "priceCurrency": "USD"
        },
        "vertical": "FOODORDERING"
      }
    }
  ]
  "vertical": "FOODORDERING"
}

การเพิ่มเอนทิตี

หากต้องการเพิ่มเอนทิตี ให้หลีกเลี่ยงการใช้การอัปเดตสินค้าคงคลัง แต่ให้ใช้กระบวนการฟีดแบบกลุ่มตามที่อธิบายไว้สำหรับสคีมาพื้นที่โฆษณา V2 แทน

การนำเอนทิตีออก

หากต้องการนำเอนทิตีระดับบนสุดออก ให้ใช้ปลายทางที่มีการแก้ไขเล็กน้อย และใช้ HTTP DELETE แทน HTTP POST ในคำขอ

การลบเอนทิตีระดับบนสุด

พิจารณาสถานการณ์ที่คุณต้องการลบร้านอาหารในฟีด คุณต้องลบบริการและเมนูของบริการด้วย

ปลายทางตัวอย่างสำหรับเอนทิตีเมนูที่มีรหัส "provider/restaurant/menu/nr":

DELETE v2/apps/delivery-provider-id/entities/menu/provider%2Frestaurant%2Fmenu%2Fnr?entity.vertical=FOODORDERING
Host: actions.googleapis.com

ตัวอย่างปลายทางสำหรับธุรกิจร้านอาหารที่มีรหัส "https://www.provider.com/merchant/nr":

DELETE v2/apps/delivery-provider-id/entities/restaurant/provider%2Frestaurant%2Fnr?entity.vertical=FOODORDERING
Host: actions.googleapis.com

ปลายทางตัวอย่างสำหรับเอนทิตีบริการที่มีรหัส "https://www.provider.com/merchant/service/nr":

DELETE v2/apps/delivery-provider-id/entities/service/provider%2Frestaurant%2Fservice%2Fnr?entity.vertical=FOODORDERING
Host: actions.googleapis.com
}

การนำเอนทิตีย่อยออก

อย่าใช้ HTTP DELETE เพื่อนำเอนทิตีย่อยภายในเอนทิตีระดับบนสุดออก เช่น รายการเมนูภายในเมนู แต่ให้ถือว่าการนำเอนทิตีย่อยออกนั้นเป็นการอัปเดตเอนทิตีระดับบนสุดที่มีการนำเอนทิตีย่อยออกจากรายการที่เกี่ยวข้องหรือ reverseReference

โค้ดตอบกลับของ API

การเรียกที่สำเร็จไม่ได้หมายความว่าฟีดนั้นถูกต้องหรือถูกต้อง แต่เป็นเพียงการเรียก API เท่านั้น การเรียกใช้ที่สำเร็จจะได้รับรหัสตอบกลับ HTTP 200 พร้อมด้วยเนื้อหาการตอบกลับที่ว่างเปล่า ดังนี้

{}

สำหรับข้อผิดพลาด โค้ดตอบกลับ HTTP จะไม่ใช่ 200 และเนื้อหาการตอบสนองจะบ่งชี้ถึงข้อผิดพลาดที่เกิดขึ้น

ตัวอย่างเช่น หากผู้ใช้ตั้งค่า "แนวตั้ง" ในเอนเวโลปเป็น FAKE_VERTICAL คุณจะได้รับข้อความด้านล่าง

{
  "error": {
    "code": 400,
    "message": "Invalid value at 'entity.vertical' (TYPE_ENUM), \"FAKE_VERTICAL\"",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "entity.vertical",
            "description": "Invalid value at 'entity.vertical' (TYPE_ENUM), \"FAKE_VERTICAL\""
          }
        ]
      }
    ]
  }
}

ตัวอย่างโค้ด

ด้านล่างคือตัวอย่างวิธีใช้ API การอัปเดตที่เพิ่มขึ้นในภาษาต่างๆ ตัวอย่างเหล่านี้ใช้ไลบรารีการตรวจสอบสิทธิ์ของ Google และถือว่าฟีดโดยใช้สคีมาสินค้าคงคลัง v1 สำหรับวิธีแก้ปัญหาทางเลือก โปรดดูที่การใช้ OAuth 2.0 สำหรับแอปพลิเคชันระหว่างเซิร์ฟเวอร์กับเซิร์ฟเวอร์

การอัปเดตเอนทิตี

Node.js

โค้ดนี้ใช้ไลบรารีการตรวจสอบสิทธิ์ของ Google สำหรับ Node.js

const {auth} = require('google-auth-library')
const request = require('request');
// The service account client secret file downloaded from the Google Cloud Console
const serviceAccountJson = require('./service-account.json')
// entity.json is a file that contains the entity data in json format
const entity = require('./entity.json')

const ENTITY_ID = 'your/entity/id'
const PROJECT_ID = 'type/your-project-id'

/**
 * Get the authorization token using a service account.
 */
async function getAuthToken() {
  let client = auth.fromJSON(serviceAccountJson)
  client.scopes = ['https://www.googleapis.com/auth/assistant']
  const tokens = await client.authorize()
  return tokens.access_token;
}

/**
 * Send an incremental update to update or add an entity
 */
async function updateEntity(entity) {
  const token = await getAuthToken()
  request.post({
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${token}`
    },
    url: `https://actions.googleapis.com/v2/apps/${PROJECT_ID}/entities:batchPush`,
    body: {
      requests: [
        {
          entity: {
            data: JSON.stringify(entity)
            name: `apps/${PROJECT_ID}/entities/${ENTITY_ID}`
          }
        }
      ],
      vertical: 'FOODORDERING'
    },
    json: true
  },
  (err, res, body) => {
    if (err) { return console.log(err); }
    console.log(`Response: ${JSON.stringify(res)}`)
  })
}

updateEntity(entity)

Python

โค้ดนี้ใช้ไลบรารีการตรวจสอบสิทธิ์ของ Google สำหรับ Python

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

PROJECT_ID = 'your-project-id'
ENTITY_ID = 'type/your/entity/id'

ENDPOINT = 'https://actions.googleapis.com/v2/apps/%s/entities:batchPush' % (
    PROJECT_ID)

# service-account.json is the service account client secret file downloaded from the
# Google Cloud Console
credentials = service_account.Credentials.from_service_account_file(
    'service-account.json')

scoped_credentials = credentials.with_scopes(
    ['https://www.googleapis.com/auth/assistant'])

authed_session = AuthorizedSession(scoped_credentials)

# Retrieving the entity
update_file = open("entity.json")  #JSON file containing entity data in json format.
data = update_file.read()

entity = {}
entity['data'] = data #entity JSON-LD serialized as string
entity['name'] = 'apps/%s/entities/%s' % (PROJECT_ID, urllib.quote(ENTITY_ID, '') )

# Populating the request
request = {}
request['entity'] = entity
requestArray = [request]

# Populating the payload
payload = {}
payload['requests'] = requestArray
payload['vertical'] = 'FOODORDERING'

response = authed_session.post(ENDPOINT, json=payload)

print(response.text) #if successful, will be '{}'

Java

รหัสนี้ใช้ไลบรารีการตรวจสอบสิทธิ์ของ Google สำหรับ Java

private static final String PROJECT_ID = "your-project-id";
private static final String ENTITY_ID = "type/your-entity-id";

/**
 * Get the authorization token using a service account.
 */
private static String getAuthToken() {
  InputStream serviceAccountFile =
      Example.class.getClassLoader().getResourceAsStream("service-account.json");
  ServiceAccountCredentials.Builder credentialsSimpleBuilder =
      ServiceAccountCredentials.fromStream(serviceAccountFile).toBuilder();
  credentialsSimpleBuilder.setScopes(ImmutableList.of("https://www.googleapis.com/auth/assistant"));
  AccessToken accessToken = credentialsSimpleBuilder.build().refreshAccessToken();
  return accessToken.getTokenValue();
}

/**
 * Send an incremental update to update or add an entity.
 * @param entityId The id of the entity to update.
 * @param entity the json of the entity to be updated.
 */
public void updateEntity(String entityId, JSONObject data) {
  String authToken = getAuthToken();
  String endpoint = String.format("https://actions.googleapis.com/v2/apps/%s/entities/:batchPush", PROJECT_ID);

  JSONObject entity = new JSONObject();
  entity.put("data", data.toString());
  entity.put("name", String.format("apps/%s/entities/%s", PROJECT_ID, URLEncoder.encode(ENTITY_ID, "UTF-8")));

  JSONObject request = new JSONObject();
  request.put("entity", entity);

  JSONArray requestArray = new JSONArray();
  requestArray.put(request);

  JSONObject payload = new JSONObject();
  payload.put("requests", requestArray);
  payload.put("vertical", FOODORDERING);

  // Execute POST request
  executePostRequest(endpoint, authToken, payload);
}

การนำเอนทิตีออก

Node.js

โค้ดนี้ใช้ไลบรารีการตรวจสอบสิทธิ์ของ Google สำหรับ Node.js

const {auth} = require('google-auth-library')
const request = require('request');
// The service account client secret file downloaded from the Google Cloud Console
const serviceAccountJson = require('./service-account.json')
// entity.json is a file that contains the entity data in json format
const entity = require('./entity.json')

const ENTITY_ID = 'restaurant/http://www.provider.com/somerestaurant'
const PROJECT_ID = 'your-project-id'

/**
 * Get the authorization token using a service account.
 */
async function getAuthToken() {
  let client = auth.fromJSON(serviceAccountJson)
  client.scopes = ['https://www.googleapis.com/auth/assistant']
  const tokens = await client.authorize()
  return tokens.access_token;
}

/**
 * Send an incremental update to delete an entity
 */
async function deleteEntity(entityId) {
  const token = await getAuthToken()
  request.delete({
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${token}`
    },
    url: `https://actions.googleapis.com/v2/apps/${PROJECT_ID}/entities/${encodeURIComponent(entityId)}?entity.vertical=FOODORDERING`,
    body: {},
    json: true
  },
  (err, res, body) => {
    if (err) { return console.log(err); }
    console.log(`Response: ${JSON.stringify(res)}`)
  })
}

deleteEntity(ENTITY_ID)

Python

โค้ดนี้ใช้ไลบรารีการตรวจสอบสิทธิ์ของ Google สำหรับ Python

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

# Service config
PROJECT_ID = 'your-project-id'
ENTITY_ID = 'restaurant/http://www.provider.com/somerestaurant'
DELETE_TIME = '2018-04-07T14:30:00-07:00'
ENDPOINT = 'https://actions.googleapis.com/v2/apps/%s/entities/%s?entity.vertical=FOODORDERING&delete_time=%s' % (
    PROJECT_ID, urllib.quote(ENTITY_ID, ''), urllib.quote(DELETE_TIME, ''))

# service-account.json is the service account client secret file downloaded from the
# Google Cloud Console
credentials = service_account.Credentials.from_service_account_file(
    'service-account.json')

scoped_credentials = credentials.with_scopes(
    ['https://www.googleapis.com/auth/assistant'])

authed_session = AuthorizedSession(scoped_credentials)
response = authed_session.delete(ENDPOINT)

print(response.text) #if successful, will be '{}'

Java

รหัสนี้ใช้ไลบรารีการตรวจสอบสิทธิ์ของ Google สำหรับ Java

private static final String PROJECT_ID = "your-project-id";
private static final String ENTITY_ID = "restaurant/http://www.provider.com/somerestaurant";

/**
 * Get the authorization token using a service account.
 */
private static String getAuthToken() {
  InputStream serviceAccountFile = Example.class.getClassLoader().getResourceAsStream("service-account.json");
  ServiceAccountCredentials.Builder credentialsSimpleBuilder =
      ServiceAccountCredentials.fromStream(serviceAccountFile).toBuilder();
  credentialsSimpleBuilder.setScopes(ImmutableList.of("https://www.googleapis.com/auth/assistant"));
  AccessToken accessToken = credentialsSimpleBuilder.build().refreshAccessToken();
  return accessToken.getTokenValue();
}

/**
 * Send an incremental update to delete an entity.
 * @param entityId The id of the entity to delete.
 */
public void deleteEntity(String entityId) {
  String authToken = getAuthToken();
  String endpoint = String.format(
      "https://actions.googleapis.com/v2/apps/%s/entities/%s?entity.vertical=FOODORDERING",
      PROJECT_ID, URLEncoder.encode(entityId, "UTF-8"));
  // Execute DELETE request
  System.out.println(executeDeleteRequest(endpoint, authToken));
}

Use Case

กรณีการใช้งานต่อไปนี้คือตัวอย่างของการอัปเดตที่เพิ่มขึ้น การอัปเดตฟีดแบบสมบูรณ์ และเนื้อหาที่ระดับสูงในการเรียก API

สถานการณ์ เอนทิตีที่จะอัปเดต คำอธิบายและเอฟเฟกต์
การปิดใช้บริการ Service

คุณต้องปิดใช้บริการโดยไม่ทราบสาเหตุ

การอัปเดตที่เพิ่มขึ้น: อัปเดตเอนทิตี Service ที่เป็นปัญหาโดยการตั้งค่าพร็อพเพอร์ตี้ isDisabled เป็น true แต่คงพร็อพเพอร์ตี้อื่นๆ ไว้เหมือนเดิม

ฟีดแบบสมบูรณ์: ตรวจสอบว่าได้อัปเดตเอนทิตีจากฟีดแบบเต็มให้ตั้งค่า isDisabled เป็น true ก่อนการดึงข้อมูลครั้งถัดไปโดย Google มิเช่นนั้นระบบจะเปิดใช้เอนทิตีอีกครั้ง

สินค้าบางรายการหมดสต็อก MenuItemOffer การอัปเดตที่เพิ่มขึ้น: ส่งเอนทิตี MenuItemOffer ที่รวมอยู่โดยที่ตั้งค่า inventoryLevel เป็น 0 สำหรับ MenuItem ที่ระบุและข้อมูลอื่นๆ ทั้งหมดไม่เปลี่ยนแปลง
การเปลี่ยนแปลงราคารายการในเมนู MenuItemOffer การอัปเดตที่เพิ่มขึ้น: ส่งเอนทิตี MenuItemOffer ที่รวมอยู่โดยที่ตั้งค่า price เป็นราคาที่อัปเดตสำหรับ MenuItem ที่ระบุและข้อมูลอื่นๆ ทั้งหมดโดยไม่มีการเปลี่ยนแปลง

เพิ่มเอนทิตีระดับบนสุดใหม่

ใช้ได้กับเอนทิตีประเภท Menu, Restaurant และ Service เท่านั้น

Menu, Restaurant, Service

ตัวอย่างเช่น คุณต้องเพิ่มเมนูใหม่ไปที่ร้านอาหาร

ฟีดแบบสมบูรณ์: เพิ่มเอนทิตีในฟีดข้อมูลและรอการนำเข้าแบบกลุ่ม

ลบเอนทิตีระดับบนสุดอย่างถาวร

ใช้ได้กับเอนทิตีประเภท Menu, Restaurant และ Service เท่านั้น

Menu, Restaurant, Service

การอัปเดตที่เพิ่มขึ้น: ส่งการลบอย่างชัดแจ้ง

ฟีดแบบสมบูรณ์: ตรวจสอบว่าได้นําเอนทิตีออกจากฟีดที่สมบูรณ์แล้วก่อนที่ Google จะดึงข้อมูลครั้งถัดไป มิเช่นนั้นระบบจะเพิ่มเอนทิตีนั้นอีกครั้ง

เพิ่มพื้นที่นำส่งใหม่ในพื้นที่ Service ที่เจาะจง ServiceArea ฟีดที่เพิ่มขึ้น: ส่งเอนทิตี ServiceArea ที่เป็นปัญหาโดยที่ช่องทั้งหมดของเอนทิตีนั้นสมบูรณ์เหมือนปกติ เหมือนกับที่คุณทำภายในฟีดที่สมบูรณ์ซึ่งระบุพื้นที่นำส่งใหม่ภายใน polygon, geoRadius หรือ postalCode
อัปเดตเวลาถึงที่นำส่งโดยประมาณใน Service ServiceHours ฟีดที่เพิ่มขึ้น: ส่ง ServiceHours เหมือนกับในฟีด เว้นแต่จะอัปเดต leadTimeMin ให้สอดคล้องกัน
อัปเดตราคาการจัดส่งในสกุลเงิน Service Fee ฟีดที่เพิ่มขึ้น: ส่งการนำส่งแบบเต็ม Fee พร้อมอัปเดต price แล้ว
อัปเดตเวลาให้บริการส่งหรือสั่งกลับบ้านใน Service ServiceHours ฟีดที่เพิ่มขึ้น: ส่ง ServiceHours เหมือนกับในฟีด เว้นแต่จะอัปเดตพร็อพเพอร์ตี้ opens และ closes ให้สอดคล้องกัน
Service (เปลี่ยนจำนวนการสั่งซื้อขั้นต่ำ) Fee ฟีดที่เพิ่มขึ้น: ส่ง Fee แบบเต็มพร้อมอัปเดต minPrice แล้ว
ลบ MenuItem อย่างถาวร Menu ฟีดที่เพิ่มขึ้น: ส่ง MenuItem เหมือนกับในฟีด แต่ไม่มีข้อมูล parentMenuSectionId

SLO เกี่ยวกับเวลาในการประมวลผลสำหรับงานแบบกลุ่มและการอัปเดตส่วนเพิ่ม

เอนทิตีที่อัปเดตหรือลบผ่านกลุ่มจะได้รับการประมวลผลภายใน 2 ชั่วโมงในโหมดสุดความสามารถ ขณะที่เอนทิตีที่อัปเดตผ่านการอัปเดตที่เพิ่มขึ้นจะได้รับการประมวลผลภายใน 5 นาที ระบบจะลบเอนทิตีที่ไม่มีอัปเดตภายใน 7 วัน

คุณจะส่งรายการต่อไปนี้ให้ Google ได้

  • งานแบบกลุ่มหลายๆ งานต่อวันเพื่ออัปเดตสินค้าคงคลังให้เป็นปัจจุบันอยู่เสมอ หรือ
  • งานแบบกลุ่ม 1 งานต่อวันและ API ที่เพิ่มขึ้นเพื่อให้พื้นที่โฆษณาอัปเดตอยู่เสมอ