وضع الدفعة

يمكنك استخدام custombatch من أجل insert أو get أو delete لمنتجات متعددة في الوقت نفسه، وذلك من خلال طلب بيانات واحد من واجهة برمجة التطبيقات.

يمكنك استخدام عنوان URL التالي للطلب من أجل إجراء اتصال بواجهات برمجة تطبيقات الدفعات المخصّصة:

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

يحتوي نص الطلب على معلَمات معيّنة: batchId وmerchantID وmethod.

لا تستخدم السمة productId إلا في حال تنفيذ عملية الحصول على أو حذف. ولا يكون productId مطلوبًا في طلب إدراج من واجهة برمجة التطبيقات لـ custombatch.

custombatch:insert

يُستخدم عنوان URL للطلب التالي لإنشاء products.custombatch method=insert

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

لإدراج المنتجَين الجديدَين، حدِّد السمة batchId لكل منتج، والسمة merchantId للتاجر المفوَّض لإجراء طلب البيانات من واجهة برمجة التطبيقات، والطريقة insert.

في المثال التالي، القيمتان batchId هما 1111 و1112 على التوالي، وهما معرّفتان فريدتان لكل منتج. إنّ merchantId: 1234567 هو التاجر المسموح له بإجراء طلبات البيانات من واجهة برمجة التطبيقات، والطريقة هي get أو delete أو insert.

تُنشئ السمة insert منتجًا جديدًا. إذا كانت هناك قيم للسمات channel وcontentLanguage وofferId وfeedLabel لمنتج معيّن، تعدّل هذه الطريقة الإدخال وتستبدل كل البيانات من طلبات البيانات السابقة من واجهة برمجة التطبيقات الخاصة بهذا المنتج.

في ما يلي نموذج نص بتنسيق JSON لـ "insert" قميصَين في قاعدة بيانات Merchant Center باستخدام طلب بيانات واحد من واجهة برمجة التطبيقات:

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

يعرض طلب البيانات من واجهة برمجة التطبيقات الناجح رمز 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"
    ]
   }
  }
 ]
}

custombatch:get

يؤدي عنوان URL التالي للطلب إلى إجراء مكالمة products.custombatch مع method=get:

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

للحصول على منتج، حدِّد السمة batchId الفريدة للمنتج في طلب البيانات من واجهة برمجة التطبيقات، والسمة merchantId للتاجر المسموح له بإجراء طلب البيانات من واجهة برمجة التطبيقات، والطريقة 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"
    ]
   }
  }
 ]
}

custombatch:delete

يُستخدم عنوان URL التالي للطلب من أجل إنشاء products.custombatch مع method=delete:

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

لحذف منتج، حدِّد سمة batchId الفريدة للمنتج ضمن طلب البيانات من واجهة برمجة التطبيقات هذا، والسمة merchantId للتاجر المصرَّح له بإجراء طلب البيانات من واجهة برمجة التطبيقات هذه، والطريقة 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
  }
 ]
}