Tworzenie i aktualizowanie regionów

Ten przewodnik przedstawia region geograficzny, którego możesz użyć jako usługi docelowej powiązanej z zasobem accounts.products.regionalInventories. Regiony możesz definiować jako zbiory kodów pocztowych lub w niektórych krajach za pomocą wstępnie zdefiniowanych celów geograficznych. Więcej informacji znajdziesz w artykule Konfigurowanie regionów.

Aby utworzyć i zaktualizować regiony, możesz użyć tych metod:

Pobieranie regionu

Aby pobrać region zdefiniowany na koncie Merchant Center, użyj metody accounts.regions.get.

Oto przykładowa prośba:

GET https://merchantapi.googleapis.com/accounts/v1beta/accounts/125222396/regions/234567?key=[YOUR_API_KEY]

Oto przykład odpowiedzi po pomyślnym wywołaniu:

HTTP/1.1 200

{
  "name": "accounts/125222396/regions/234567",
  "displayName": "Canada",
  "postalCodeArea": {
    "regionCode": "CA",
    "postalCodes": [
      {
        "begin": "L6A"
      }
    ]
  }

Wyświetlanie listy wszystkich regionów

Aby wyświetlić listę regionów na koncie Merchant Center, użyj metody accounts.regions.list.

Oto przykładowa prośba:

GET https://merchantapi.googleapis.com/accounts/v1beta/accounts/125222396/regions?pageSize=100&key=[YOUR_API_KEY]

Oto przykład odpowiedzi po pomyślnym wywołaniu:

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
    },
  ]
}

Wstawianie regionu

Aby wstawić definicję regionu na koncie Merchant Center, użyj metody accounts.regions.create. Wykonywanie tej metody wymaga dostępu administratora.

Oto przykładowa prośba:

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"
  }
}

Oto przykład odpowiedzi po pomyślnym wywołaniu:

{
     "name": "accounts/102959835/regions/987654",
  "displayName": "TestRegion",
  "postalCodeArea": {
    "regionCode": "US",
    "postalCodes": [
      {
        "begin": "98109"
      }
    ]
  },
  "regionalInventoryEligible": true,
  "shippingEligible": true
}

Aby utworzyć nowy region za pomocą usługi AreaCode:

Oto przykładowa prośba:

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
    ]
  }
}

Oto przykład odpowiedzi po pomyślnym wywołaniu:

{
  "name": "accounts/102959835/regions/168888",
  "displayName": "WA_test",
  "geotargetArea": {
    "geotargetCriteriaIds": [
      "20101"
    ]
  },
  "regionalInventoryEligible": true,
  "shippingEligible": false
}

Aby zaktualizować wartości displayName i GeoTargetCriteriaIds dla utworzonego regionu:

Oto przykładowa prośba:

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
    ]
  }
}

Oto przykład odpowiedzi po pomyślnym wywołaniu:

HTTP/1.1 200

{
  "name": "accounts/102959835/regions/168888",
  "displayName": "BR_test",
  "geotargetArea": {
    "geotargetCriteriaIds": [
      "20100"
    ]
  },
  "regionalInventoryEligible": true,
  "shippingEligible": false
}

Aktualizowanie regionu

Aby zaktualizować definicję regionu na koncie Merchant Center, użyj metody accounts.regions.patch. Wykonywanie tej metody wymaga dostępu administratora.

Oto przykładowa prośba:

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"
  }
}

Oto przykład odpowiedzi po pomyślnym wywołaniu:

{
  "name": "accounts/102959835/regions/987654",
  "displayName": "Test",
  "postalCodeArea": {
    "regionCode": "US",
    "postalCodes": [
      {
        "begin": "98108"
      }
    ]
  },
  "regionalInventoryEligible": true,
  "shippingEligible": true
}

Usuwanie regionu

Aby usunąć definicję regionu z konta Merchant Center, użyj metody accounts.regions.delete. Wykonywanie tej metody wymaga dostępu administratora.

Oto przykładowa prośba:

DELETE https://merchantapi.googleapis.com/accounts/v1beta/accounts/102959835/regions/987654?key=[YOUR_API_KEY] HTTP/1.1

Oto przykład odpowiedzi po pomyślnym wywołaniu:

HTTP/1.1 200
{}