這份指南代表地理區域,可用來做為與 accounts.products.regionalInventories
資源相關的服務目標。您可以將區域定義為郵遞區號集合,或是在部分國家/地區使用預先定義的地理目標。詳情請參閱「設定區域」。
如要建立及更新區域,您可以使用下列方法:
擷取區域
如要擷取 Merchant Center 帳戶中定義的區域,請使用 accounts.regions.get
方法。
以下是要求範例:
GET https://merchantapi.googleapis.com/accounts/v1beta/accounts/125222396/regions/234567?key=[YOUR_API_KEY]
以下是成功呼叫的回應範例:
HTTP/1.1 200
{
"name": "accounts/125222396/regions/234567",
"displayName": "Canada",
"postalCodeArea": {
"regionCode": "CA",
"postalCodes": [
{
"begin": "L6A"
}
]
}
列出所有區域
如要列出 Merchant Center 帳戶中的區域,請使用 accounts.regions.list
方法。
以下是要求範例:
GET https://merchantapi.googleapis.com/accounts/v1beta/accounts/125222396/regions?pageSize=100&key=[YOUR_API_KEY]
以下是成功呼叫的回應範例:
HTTP/1.1 200
{
"regions": [
{
"name": "accounts/125222396/regions/234567",
"displayName": "Canada",
"postalCodeArea": {
"regionCode": "CA",
"postalCodes": [
{
"begin": "L6A"
}
]
},
"regionalInventoryEligible": true,
"shippingEligible": true
},
{
"name": "accounts/125222396/regions/Inline region",
"displayName": "Inline region",
"postalCodeArea": {
"regionCode": "CA",
"postalCodes": [
{
"begin": "M7B"
}
]
},
"regionalInventoryEligible": false,
"shippingEligible": true
},
]
}
插入區域
如要在 Merchant Center 帳戶中插入區域定義,請使用 accounts.regions.create
方法。執行此方法需要管理員存取權。
以下是要求範例:
POST https://merchantapi.googleapis.com/accounts/v1beta/accounts/102959835/regions?regionId=987654&key=[YOUR_API_KEY]
{
"displayName": "TestRegion",
"name": "987654",
"postalCodeArea": {
"postalCodes": [
{
"begin": "98109"
}
],
"regionCode": "US"
}
}
以下是成功呼叫的回應範例:
{
"name": "accounts/102959835/regions/987654",
"displayName": "TestRegion",
"postalCodeArea": {
"regionCode": "US",
"postalCodes": [
{
"begin": "98109"
}
]
},
"regionalInventoryEligible": true,
"shippingEligible": true
}
如要使用 AreaCode
建立新區域,請按照下列步驟操作:
以下是要求範例:
POST https://merchantapi.googleapis.com/accounts/v1beta/accounts/102959835/regions?regionId=168888&key=[YOUR_API_KEY] HTTP/1.1
{
"displayName": "WA_test",
"name": "168888",
"geotargetArea": {
"geotargetCriteriaIds": [
20101
]
}
}
以下是成功呼叫的回應範例:
{
"name": "accounts/102959835/regions/168888",
"displayName": "WA_test",
"geotargetArea": {
"geotargetCriteriaIds": [
"20101"
]
},
"regionalInventoryEligible": true,
"shippingEligible": false
}
如要更新已建立區域的 displayName
和 GeoTargetCriteriaIds
,請按照下列步驟操作:
以下是要求範例:
PATCH https://merchantapi.googleapis.com/accounts/v1beta/accounts/102959835/regions/168888?updateMask=displayName%2CgeotargetArea&key=[YOUR_API_KEY] HTTP/1.1
{
"displayName": "BR_test",
"geotargetArea": {
"geotargetCriteriaIds": [
20100
]
}
}
以下是成功呼叫的回應範例:
HTTP/1.1 200
{
"name": "accounts/102959835/regions/168888",
"displayName": "BR_test",
"geotargetArea": {
"geotargetCriteriaIds": [
"20100"
]
},
"regionalInventoryEligible": true,
"shippingEligible": false
}
更新區域
如要在 Merchant Center 帳戶中更新區域定義,請使用 accounts.regions.patch
方法。執行此方法需要管理員存取權。
以下是要求範例:
PATCH https://merchantapi.googleapis.com/accounts/v1beta/accounts/102959835/regions/987654?updateMask=displayName%2CpostalCodeArea&key=[YOUR_API_KEY] HTTP/1.1
Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json
Content-Type: application/json
{
"displayName": "Test",
"postalCodeArea": {
"postalCodes": [
{
"begin": "98108"
}
],
"regionCode": "US"
}
}
以下是成功呼叫的回應範例:
{
"name": "accounts/102959835/regions/987654",
"displayName": "Test",
"postalCodeArea": {
"regionCode": "US",
"postalCodes": [
{
"begin": "98108"
}
]
},
"regionalInventoryEligible": true,
"shippingEligible": true
}
刪除區域
如要從 Merchant Center 帳戶中刪除區域定義,請使用 accounts.regions.delete
方法。執行此方法需要管理員存取權。
以下是要求範例:
DELETE https://merchantapi.googleapis.com/accounts/v1beta/accounts/102959835/regions/987654?key=[YOUR_API_KEY] HTTP/1.1
以下是成功呼叫的回應範例:
HTTP/1.1 200
{}