इलाके

regions सेवा की मदद से, ऐसे भौगोलिक क्षेत्र बनाए और मैनेज किए जा सकते हैं जिनका इस्तेमाल regionalinventory और shippingsettings, दोनों सेवाओं के लिए टारगेट के तौर पर किया जा सकता है. आप पहले से तय जियो टारगेट का इस्तेमाल करके, क्षेत्रों को पिन कोड के संग्रह के तौर पर या कुछ देशों में तय कर सकते हैं. इस गाइड में, हर तरह के क्षेत्र को तय करने के उदाहरण दिए गए हैं. साथ ही, क्षेत्र के हिसाब से कीमत में बदलाव करने का तरीका भी बताया गया है. सभी उपलब्ध तरीकों और पैरामीटर के साथ-साथ regions सेवा के बारे में ज़्यादा जानकारी के लिए, रेफ़रंस दस्तावेज़ देखें.

देश/इलाके के हिसाब से ज़रूरी शर्तें

कोई क्षेत्र तय करने पर, क्षेत्र सेवा यह तय करती है कि उस क्षेत्र में Content API की अन्य सेवाएं इस्तेमाल की जा सकती हैं या नहीं. regions.create कॉल के बाद मिले रिस्पॉन्स ऑब्जेक्ट में, दो बूलियन फ़ील्ड regionalInventoryEligible और shippingEligible शामिल होते हैं. इनसे पता चलता है कि regionalinventory और shippingsettings सेवाओं के साथ इलाके का इस्तेमाल किया जा सकता है या नहीं.

regionalInventoryEligible

regionalinventory सेवा के साथ इस्तेमाल करने के लिए, किसी देश/इलाके को ये शर्तें पूरी करनी होंगी:

  • क्षेत्र बनाते समय आपके बताए गए regionId में सिर्फ़ अंक होने चाहिए. साथ ही, इसमें कम से कम छह अंक होने चाहिए.
  • इलाके को, भौगोलिक इलाके और ऑनलाइन जनसंख्या के लिए तय की गई, साइज़ की कम से कम ज़रूरी शर्तों को पूरा करना होगा.

shippingEligible

shippingsettings सेवा के साथ इस्तेमाल करने के लिए, किसी देश/इलाके को ये शर्तें पूरी करनी होंगी:

  • क्षेत्र को पिन कोड का इस्तेमाल करके तय करना चाहिए.
  • यह क्षेत्र किसी ऐसे देश का होना चाहिए जो shippingsettings सेवा के साथ काम करता हो.

सैंपल

यह पूरा कोड सैंपल है. इसकी मदद से, Java में नया क्षेत्र बनाया जा सकता है:

// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package shopping.content.v2_1.samples.regions;

import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.services.content.model.Region;
import com.google.api.services.content.model.RegionPostalCodeArea;
import com.google.api.services.content.model.RegionPostalCodeAreaPostalCodeRange;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import shopping.content.v2_1.samples.ContentSample;

/**
 * Creates a region. The region created here can be used with the regional inventory service.
 * Regional availability and pricing lets you provide product availability and variable pricing
 * based on your business presence and the location of your customer base. Regional availability and
 * pricing is available for products advertised through Shopping ads on Google Search, and listed in
 * free listings on the Shopping tab.
 */
public class RegionCreateSample extends ContentSample {
  public RegionCreateSample(String[] args) throws IOException {
    super(args);
  }

  @Override
  public void execute() throws IOException {
    checkNonMCA();

    // Creates a List of Postal Code Area Postal Code Ranges.
    // This allows you to flexibly define regions as combinations of postal code
    // ranges. Each postal code range in the list has its own start and end zip code.
    List<RegionPostalCodeAreaPostalCodeRange> postalCodeRanges =
        new ArrayList<RegionPostalCodeAreaPostalCodeRange>();

    // Creates a new postal code range from two postal code values.
    // This range is equivalent to all postal codes in the USA state of New York (00501 - 14925)
    RegionPostalCodeAreaPostalCodeRange postalCodeRange =
        new RegionPostalCodeAreaPostalCodeRange().setBegin("00501").setEnd("14925");

    // Adds the NY State postal code range into the list of postal code ranges that a postal
    // code area accepts.
    postalCodeRanges.add(postalCodeRange);

    // Creates Postal Code Area for the Region that will be inserted, using the NY State postal code
    // ranges, and the US CLDR territory/country code that the postal code ranges applies to.
    RegionPostalCodeArea postalCodeArea =
        new RegionPostalCodeArea().setPostalCodes(postalCodeRanges).setRegionCode("US");

    // Creates a region with example values for displayName and postalCodeArea
    Region region = new Region().setDisplayName("NYState").setPostalCodeArea(postalCodeArea);

    // Tries to create the region, and catches any exceptions
    try {
      System.out.println("Creating region");
      Region result =
          content
              .regions()
              .create(this.config.getMerchantId().longValue(), region)
              .setRegionId("12345678") // User-defined, numeric, minimum of 6 digits
              .execute();
      System.out.println("Listing succesfully created region");
      System.out.println(result);
    } catch (GoogleJsonResponseException e) {
      checkGoogleJsonResponseException(e);
    }
  }

  public static void main(String[] args) throws IOException {
    new RegionCreateSample(args).execute();
  }
}

पिन कोड का इस्तेमाल करके क्षेत्र बनाना

पिन कोड के कलेक्शन के तौर पर तय किया जाने वाला क्षेत्र बनाने के लिए, regions.create तरीके का इस्तेमाल किया जा सकता है. नीचे दिए गए उदाहरण में, पिन कोड की रेंज तय करके अमेरिका के एरिज़ोना राज्य के लिए एक नया क्षेत्र बनाया गया है.

क्षेत्र जोड़ने के लिए, इस यूआरएल और अनुरोध के मुख्य हिस्से के साथ, POST अनुरोध करें:

https://shoppingcontent.googleapis.com/content/v2.1/merchantId/regions?regionId=456789
{
  postalCodeArea: {
    regionCode: "US",
    postalCodes: [
      {
        begin: "850*",
        end: "860*"
      }
    ]
   }
}

हर Merchant Center खाते में regions और shippingsettings के लिए, 2 एमबी डेटा होना तय है. शिपिंग और क्षेत्र की सेटिंग, एमसीए से उसके सभी उप-खातों में अंदरूनी तौर पर कॉपी की जाती हैं. इसलिए, बड़े एमसीए के लिए, हो सकता है कि आप तुरंत स्टोरेज सीमा तक पहुंच जाएं. इस मामले में, regions और shippingsettings को मर्चेंट आईडी के लेवल पर मैनेज किया जा सकता है. क्षेत्रों के कोटे को 2 एमबी की सीमा से ज़्यादा बढ़ाने का कोई तरीका नहीं है.

भौगोलिक टारगेट का इस्तेमाल करके क्षेत्र बनाना

ब्राज़ील और रूस के इलाकों के लिए, regions.create तरीके का इस्तेमाल करके, पहले से तय भौगोलिक इलाके यानी भौगोलिक टारगेट के संग्रह के तौर पर तय किया गया क्षेत्र भी बनाया जा सकता है. भौगोलिक टारगेट के टाइप के उदाहरणों में देश, राज्य, शहर, आस-पास के इलाके, और हवाई अड्डे शामिल हैं. हालांकि, फ़िलहाल regions की सेवा सिर्फ़ ब्राज़ील के लिए “राज्य” और रूस के लिए “क्षेत्र” टाइप के साथ काम करती है. regions सेवा के साथ इस्तेमाल किए जा सकने वाले भौगोलिक टारगेट के साथ-साथ सभी जियोटारगेट आईडी की CSV फ़ाइल डाउनलोड करने के लिए, भौगोलिक टारगेट देखें. नीचे दिए गए उदाहरण में, ब्राज़ील के तीन राज्यों के जियोटारगेट आईडी देकर, एक नया क्षेत्र बनाया गया है.

क्षेत्र जोड़ने के लिए, इस यूआरएल और अनुरोध के मुख्य हिस्से का इस्तेमाल करके, POST का अनुरोध करें:

https://shoppingcontent.googleapis.com/content/v2.1/merchantId/regions?regionId=123456
{
  geoTargetAreas: {
    geotargetCriteriaId: [20106, 20102, 20101] //Sao Paulo, Rio de Janeiro, Parana
  }
}

क्षेत्र के हिसाब से कीमत में बदलाव करने के लिए, क्षेत्रों का इस्तेमाल करें

कोई क्षेत्र बनाने पर, regions सेवा रिस्पॉन्स ऑब्जेक्ट दिखाती है. इसमें regionId और ज़रूरी शर्तें वाले दो स्टेटस फ़ील्ड शामिल होते हैं. अगर regionalInventoryEligible की वैल्यू true है, तो regionaliventory सेवा का इस्तेमाल करके ऐसा बदलाव किया जा सकता है जो क्षेत्र के लिए अलग कीमत सेट करे. नीचे दिए गए उदाहरण में, ऊपर दिए गए उदाहरण में बनाए गए पिन कोड वाले क्षेत्र का इस्तेमाल करके, क्षेत्र के हिसाब से तय की गई कीमत में बदलाव किया जाता है. इसका regionId “456789” है.

बदलाव करने के लिए, इस यूआरएल का इस्तेमाल करके POST अनुरोध करें और अनुरोध के मुख्य हिस्से का इस्तेमाल करें:

https://shoppingcontent.googleapis.com/content/v2.1/merchantId/products/{productId}/regionalinventory
{
  “regionId”: "456789"
  “price”: {
    value: “10”
    currency: “USD”
  },
  “availability”: “in stock”
}