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

ส่วนนี้จะอธิบายวิธีส่งอัปเดตเวลาที่ตามเวลาของพื้นที่โฆษณาไปยัง 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 ครั้งเดียว

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 ไปยังปลายทางต่อไปนี้

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/cuisine/nr":

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

ตัวอย่างปลายทางสําหรับเอนทิตีบริการที่มีรหัส "https://www.provider.com/Restaurant/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 และเนื้อหาการตอบสนองจะแสดงข้อผิดพลาด

เช่น หากผู้ใช้ตั้งค่า "vertical" ในเอนเวโลปเป็น 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 ส่วนที่เพิ่มขึ้นเพื่อให้พื้นที่โฆษณามีข้อมูลล่าสุดอยู่เสมอ