遷移區域管理
本指南說明如何將整合程序從 Content API for Shopping 中的 RegionsService 遷移至 Accounts 子 API 中的 RegionsService。
區域服務可讓您定義自訂地理區域,用於區域價格和運送覆寫等用途。您可以在 RegionalInventory 和 ShippingSettings 等服務中使用區域。
主要差異
- API 結構:Regions 服務現在是 Merchant API 的 
Accounts子 API 的一部分 (例如merchantapi.googleapis.com/accounts/v1/...)。 - 資源名稱:Merchant API 會使用資源名稱 (
accounts/{account}/regions/{region}),而非 Get、Update 和 Delete 作業網址路徑中的個別merchant_id和region_id參數。 - AIP 合規性:Merchant API 方法遵循標準 API 改進提案模式 (例如使用 
parent進行列出/建立、使用name進行取得/刪除,以及標準update_mask用法)。 - 包裝函式型別:先前在 Content API 中使用 
google.protobuf.StringValue或google.protobuf.BoolValue的欄位,現在在 Merchant API 中使用標準optional欄位。 - 新功能:
- Merchant API 在 
Region資源中導入RadiusArea類型,可根據某個點周圍的半徑定義區域 (最初具有TRUST_TESTER可見度)。 - 您可以使用批次方法,包括 
BatchCreateRegions、BatchUpdateRegions和BatchDeleteRegions。 
 - Merchant API 在 
 - 錯誤處理:錯誤代碼和訊息可提供更具體的意見回饋。
 
要求
以下說明請求模式的變化:
| 項目 | Content API for Shopping | Merchant API | 說明 | 
|---|---|---|---|
| 端點 | https://shoppingcontent.googleapis.com  | 
   https://merchantapi.googleapis.com  | 
   變更基礎網域。 | 
| 取得路徑 | /content/v2.1/{merchant_id}/regions/{region_id}  | 
   /accounts/v1/{name=accounts/*/regions/*}  | 
   Merchant API 使用 accounts 子 API 和資源 name。 | 
  
| 清單路徑 | /content/v2.1/{merchant_id}/regions  | 
   /accounts/v1/{parent=accounts/*}/regions  | 
   Merchant API 會使用 parent 指定帳戶。 | 
  
| 建立路徑 | /content/v2.1/{merchant_id}/regions  | 
   /accounts/v1/{parent=accounts/*}/regions  | 
   Merchant API 使用 parent。region_id 是要求主體中的欄位。 | 
  
| 更新路徑 | /content/v2.1/{merchant_id}/regions/{region_id}  | 
   /accounts/v1/{name=accounts/*/regions/*}  | 
   Merchant API 中的資源名稱是主體中 region 物件的一部分。 | 
  
| 刪除路徑 | /content/v2.1/{merchant_id}/regions/{region_id}  | 
   /accounts/v1/{name=accounts/*/regions/*}  | 
   使用資源 name。 | 
  
ID
請按照下列方式變更 ID 的使用方式:
| 項目 | Content API for Shopping | Merchant API | 說明 | 
|---|---|---|---|
| 帳戶 | merchant_id (整數)  | 
   account (整數,name 或 parent 字串的一部分) | 
   找出內嵌在資源名稱字串中的帳戶 ID,例如 accounts/{account}。 | 
  
| 地區 | region_id (字串)  | 
   {region} (字串,name 字串的一部分)  | 
   找出內嵌在資源名稱字串中的區域 ID,例如 accounts/{account}/regions/{region}。 | 
  
| 資源名稱 | 不嚴格用於要求。 | name:accounts/{account}/regions/{region} | 
   Get/Update/Delete 要求的標準 ID。 | 
| 家長姓名 | 不嚴格用於要求。 | parent:accounts/{account} | 
   List/Create 要求的標準 ID。 | 
資源
Region 資源結構有小幅變更:
| 項目 | Content API for Shopping | Merchant API | 說明 | 
|---|---|---|---|
| 資源 ID | region_id (字串)、merchant_id (int64)  | 
   name (字串):accounts/{account}/regions/{region} | 
   Merchant API 會使用單一 name 欄位做為資源 ID。 | 
  
display_name  | 
   google.protobuf.StringValue  | 
   optional string  | 
   已移除包裝類型。 | 
radius_area  | 
   不適用 (N/A) | RadiusArea  | 
   
    這個新類型會依半徑定義區域。包括 region_code、lat_lng、radius、radius_units。根據預設,瀏覽權限會受到限制。
    | 
  
regional_inventory_eligible  | 
   google.protobuf.BoolValue (僅限輸出)  | 
   optional bool (僅限輸出)  | 
   已移除包裝函式類型。 | 
shipping_eligible  | 
   google.protobuf.BoolValue (僅限輸出)  | 
   optional bool (僅限輸出)  | 
   已移除包裝函式類型。 | 
方法
請依下列方式變更方法的使用方式:
| 項目 | Content API for Shopping | Merchant API | 說明 | 
|---|---|---|---|
| 取得區域 | GetRegion  | 
   GetRegion  | 
   要求使用 name。 | 
  
| 建立區域 | CreateRegion  | 
   CreateRegion  | 
   
   要求會從網址取得 parent,而要求主體則包含 region 物件和 region_id。 | 
  
| 更新區域 | UpdateRegion  | 
   UpdateRegion  | 
   
    要求會使用 region (必須包含 region.name) 和 update_mask。 | 
  
| 刪除區域 | DeleteRegion
    | 
   DeleteRegion
    | 
   這項要求使用 name。
    | 
  
| 列出區域 | ListRegions  | 
   ListRegions  | 
   
   要求使用 parent。page_size 和
   page_token 的行為一致。
    | 
  
| 批次建立 | 不適用 | BatchCreateRegions  | 
   這是新方法。 | 
| 批次更新 | 不適用 | BatchUpdateRegions  | 
   這是新方法。 | 
| 批次刪除 | 不適用 | BatchDeleteRegions  | 
   這是新方法。 | 
重新命名的欄位
| 項目 | Content API for Shopping | Merchant API | 說明 | 
|---|---|---|---|
| 帳戶 ID | merchant_id  | 
   account (name 或 parent 的一部分) | 
   
    整合至資源 name 字串。這會影響 Region (回應) 和用於提出 API 要求 (例如 CreateRegionRequest, GetRegionRequest, UpdateRegionRequest, DeleteRegionRequest 和 ListRegionsRequest) 的 protobuf 訊息。 | 
  
| 區域 ID | region_id  | 
   region (name 的一部分),region_id | 
   大部分整合至 name,CreateRegionRequest 中有獨立的 region_id 欄位。這會影響 Region (回應) 和用於提出 API 要求的 protobuf 訊息,例如 CreateRegionRequest, GetRegionRequest, UpdateRegionRequest, DeleteRegionRequest 和 ListRegionsRequest。 | 
  
| 區域名稱 (輸出) | region_id
    | 
   name
    | 
   回應中的主要 ID 欄位現在是完整資源 name。這會影響 Region。
    | 
  
| 顯示名稱 | display_name  | 
   display_name  | 
   
    類型會從 StringValue 變更為 optional string。
    這會影響 Region。
    | 
  
| 資格旗標 | ...eligible  | 
   ...eligible  | 
   
    類型會從 BoolValue 變更為 optional bool。
    這會影響 Region。
    | 
  
| 更新遮罩 | update_mask  | 
   update_mask  | 
   Region 欄位路徑。這會影響 UpdateRegionRequest。 |