حالت دسته ای

می‌توانید custombatch برای insert ، get یا delete چندین محصول در یک زمان در یک تماس API استفاده کنید.

از URL درخواست زیر برای برقراری تماس با API های دسته ای سفارشی استفاده کنید:

POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch

بدنه درخواست شامل پارامترهای خاصی است: batchId ، merchantID ، و یک method .

فقط در صورتی از productId استفاده کنید که در حال اجرای get یا delete هستید. productId در فراخوانی API درج برای custombatch مورد نیاز نیست.

دسته سفارشی: درج

URL درخواست زیر برای ساخت products.custombatch method=insert استفاده می شود

POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch

برای درج دو محصول جدید، batchId برای هر محصول، merchantId فروشنده مجاز برای برقراری تماس API و روش insert مشخص کنید.

در مثال زیر، مقادیر batchId به ترتیب 1111 و 1112 هستند و شناسه های منحصر به فرد برای هر محصول هستند. merchantId: 1234567 تاجری است که مجاز به برقراری تماس API است و روش get ، delete یا insert است.

یک insert یک محصول جدید ایجاد می کند. اگر مقادیری برای ویژگی‌های channel ، contentLanguage ، offerId و feedLabel برای یک محصول مشخص وجود داشته باشد، این روش ورودی را به‌روزرسانی می‌کند و همه داده‌های فراخوان‌های API قبلی را برای محصول جایگزین می‌کند.

در اینجا یک نمونه بدنه JSON برای insert دو تی شرت در پایگاه داده Merchant Center با استفاده از یک تماس API وجود دارد:

{
  "entries": [
    {
      "batchId": 1111,
      "merchantId": 1234567,
      "method": "insert",
      "product": {
        "kind": "content#product",
        "offerId": "1111111111",

        "title": "Google Tee Black",
        "description": "The Black Google Tee is available in unisex sizing and
        features a retail fit.",
        "link": "http://my.site.com/blacktee/",
        "imageLink": "https://shop.example.com/.../images/GGOEGXXX1100.jpg",
        "contentLanguage": "en",
        "targetCountry": "US",
        "feedLabel": "US",
        "channel": "online",
        "ageGroup": "adult",
        "availability": "in stock",
        "availabilityDate": "2019-01-25T13:00:00-08:00",
        "brand": "Google",
        "color": "black",
        "condition": "new",
        "gender": "male",
        "googleProductCategory": "1604",
        "gtin": "608802531656",
        "itemGroupId": "google_tee",
        "mpn": "608802531656",
        "price": {
          "value": "21.99",
          "currency": "USD"
        },
        "sizes": [
          "Large"
        ],
        "includedDestination": [
          "Shopping"
        ]
      }
    },
    {
      "batchId": 1112,
      "merchantId": 1234567,
      "method": "insert",
      "product": {
        "kind": "content#product",
        "offerId": "2222222222",

        "title": "Google Tee Green",
        "description": "100% cotton jersey fabric sets  this Google t-shirt above
        the crowd. Features the google logo across the chest. Unisex sizing.",
        "link": "http://my.site.com/greentee/",
        "imageLink": "https://shop.example.com/.../images/GGOEGXXX0906.jpg",
        "contentLanguage": "en",
        "targetCountry": "US",
        "feedLabel": "US",
        "channel": "online",
        "ageGroup": "adult",
        "availability": "in stock",
        "availabilityDate": "2019-01-25T13:00:00-08:00",
        "brand": "Google",
        "color": "green",
        "condition": "new",
        "gender": "male",
        "googleProductCategory": "1604",
        "gtin": "608802531649",
        "itemGroupId": "google_tee",
        "mpn": "608802531649",
        "price": {
          "value": "21.99",
          "currency": "USD"
        },
        "sizes": [
          "Medium"
        ],
        "includedDestination": [
          "Shopping"
        ]
      }
    }
  ]
}

یک تماس موفق API یک کد HTTP 200 و پاسخ JSON را برمی‌گرداند که شامل محصولاتی است که درج شده‌اند. فرمت JSON برگشتی مشابه شکل زیر است:

{
 "kind": "content#productsCustomBatchResponse",
 "entries": [
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1111,
   "product": {
    "kind": "content#product",
    "id": "online:en:US:1111111111",
    "offerId": "1111111111",
    "title": "Google Tee Black",
    "description": "The Black Google Tee is available in unisex sizing and
    features a retail fit.",
    "link": "http://my.site.com/blacktee/",
    "imageLink": "https://shop.example.com/.../images/GGOEGXXX1100.jpg",
    "contentLanguage": "en",
    "targetCountry": "US",
    "feedLabel": "US",
    "channel": "online",
    "ageGroup": "adult",
    "availability": "in stock",
    "availabilityDate": "2019-01-25T13:00:00-08:00",
    "brand": "Google",
    "color": "black",
    "condition": "new",
    "gender": "male",
    "googleProductCategory": "1604",
    "gtin": "608802531656",
    "itemGroupId": "google_tee",
    "mpn": "608802531656",
    "price": {
     "value": "21.99",
     "currency": "USD"
    },
    "sizes": [
     "Large"
    ],
    "includedDestination": [
      "Shopping"
    ]
   }
  },
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1112,
   "product": {
    "kind": "content#product",
    "id": "online:en:US:2222222222",
    "offerId": "2222222222",
    "title": "Google Tee Green",
    "description": "100% cotton jersey fabric sets this Google t-shirt above
    the crowd. Features the google logo across the chest. Unisex sizing.",
    "link": "http://my.site.com/greentee/",
    "imageLink": "https://shop.example.com/.../images/GGOEGXXX0906.jpg",
    "contentLanguage": "en",
    "targetCountry": "US",
    "feedLabel": "US",
    "channel": "online",
    "ageGroup": "adult",
    "availability": "in stock",
    "availabilityDate": "2019-01-25T13:00:00-08:00",
    "brand": "Google",
    "color": "green",
    "condition": "new",
    "gender": "male",
    "googleProductCategory": "1604",
    "gtin": "608802531649",
    "itemGroupId": "google_tee",
    "mpn": "608802531649",
    "price": {
     "value": "21.99",
     "currency": "USD"
    },
    "sizes": [
     "Medium"
    ],
    "includedDestination": [
      "Shopping"
    ]
   }
  }
 ]
}

دسته سفارشی: دریافت

URL درخواست زیر یک تماس products.custombatch با method=get برقرار می کند:

POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch

برای دریافت یک محصول، batchId منحصر به فرد محصول برای تماس API، merchantId تجاری مجاز برای برقراری تماس API، روش get و productId محصول در حال بازیابی را مشخص کنید.

در زیر نمونه ای از بدنه درخواست JSON برای بازیابی دو محصول درج شده با استفاده از نمونه custombatch:insert است که توسط مقادیر productId آنها مشخص شده است. batchId برای هر مورد در لیست منحصر به فرد است:

{
  "entries": [
    {
      "batchId": 1113,
      "merchantId": 1234567,
      "method": "get",
      "productId": "online:en:US:1111111111"
    },
    {
      "batchId": 1114,
      "merchantId": 1234567,
      "method": "get",
      "productId": "online:en:US:2222222222"
    }
  ]
}

این تماس یک کد HTTP 200 و بدنه پاسخ زیر را برمی گرداند:

{
 "kind": "content#productsCustomBatchResponse",
 "entries": [
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1113,
   "product": {
    "kind": "content#product",
    "id": "online:en:US:1111111111",
    "offerId": "1111111111",
    "title": "Google Tee Black",
    "description": "The Black Google Tee is available in unisex sizing and features a retail fit.",
    "link": "http://my.site.com/blacktee/",
    "imageLink": "https://shop.example.com/.../images/GGOEGXXX1100.jpg",
    "contentLanguage": "en",
    "targetCountry": "US",
    "feedLabel": "US",
    "channel": "online",
    "ageGroup": "adult",
    "availability": "in stock",
    "availabilityDate": "2019-01-25T13:00:00-08:00",
    "brand": "Google",
    "color": "black",
    "condition": "new",
    "gender": "male",
    "googleProductCategory": "1604",
    "gtin": "608802531656",
    "itemGroupId": "google_tee",
    "mpn": "608802531656",
    "price": {
     "value": "21.99",
     "currency": "USD"
    },
    "sizes": [
     "Large"
    ],
    "includedDestination": [
      "Shopping"
    ]
   }
  },
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1114,
   "product": {
    "kind": "content#product",
    "id": "online:en:US:2222222222",
    "offerId": "2222222222",
    "title": "Google Tee Green",
    "description": "100% cotton jersey fabric sets this Google t-shirt above the crowd.
    Features the google logo across the chest. Unisex sizing.",
    "link": "http://my.site.com/greentee/",
    "imageLink": "https://shop.example.com/.../images/GGOEGXXX0906.jpg",
    "contentLanguage": "en",
    "targetCountry": "US",
    "feedLabel": "US",
    "channel": "online",
    "ageGroup": "adult",
    "availability": "in stock",
    "availabilityDate": "2019-01-25T13:00:00-08:00",
    "brand": "Google",
    "color": "green",
    "condition": "new",
    "gender": "male",
    "googleProductCategory": "1604",
    "gtin": "608802531649",
    "itemGroupId": "google_tee",
    "mpn": "608802531649",
    "price": {
     "value": "21.99",
     "currency": "USD"
    },
    "sizes": [
     "Medium"
    ],
    "includedDestination": [
      "Shopping"
    ]
   }
  }
 ]
}

دسته سفارشی: حذف

URL درخواست زیر برای ساخت products.custombatch با method=delete استفاده می شود:

POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch

برای حذف یک محصول، batchId منحصر به فرد محصول در این فراخوان API، merchantId تجاری مجاز برای برقراری این تماس API، روش delete و productId محصول در حال حذف را مشخص کنید.

{
  "entries": [
    {
      "batchId": 1115,
      "merchantId": 1234567,
      "method": "delete",
      "productId": "online:en:US:1111111111"
    },
    {
      "batchId": 1116,
      "merchantId": 1234567,
      "method": "delete",
      "productId": "online:en:US:2222222222"
    }
  ]
}

این تماس یک کد HTTP 200 و مقادیر batchId موارد حذف شده را برمی گرداند:

{
 "kind": "content#productsCustomBatchResponse",
 "entries": [
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1115
  },
  {
   "kind": "content#productsCustomBatchResponseEntry",
   "batchId": 1116
  }
 ]
}