webflow / js-webflow-api

Node.js SDK for the Webflow Data API
https://www.npmjs.com/package/webflow-api
286 stars 93 forks source link

Add `deleteItems` and `publishItems` methods. Add data to the `delete` method callsites. #61

Closed wf-d-whitely closed 1 year ago

wf-d-whitely commented 1 year ago

Adding new methods and passing data into the delete method.

const Webflow = require('webflow-api');

const api = new Webflow({
  token: "<access_token>",
});

Promise.all([
  api.publishItems({
    collectionId: "<collection_id>",
    itemIds: [
      "<item_id_1>",
      "<item_id_2>",
      "<item_id_x>",
    ],
  }),
  api.deleteItems(
    {
      collectionId: "<collection_id>",
      itemIds: [
        "<item_id_1>",
        "<item_id_2>",
        "<item_id_x>",
      ],
    },
    { live: true }
  ),
]).then((x) => console.log(x));

returns

[
  {
    publishedItemIds: [
      "<item_id_1>",
      "<item_id_2>",
      "<item_id_x>",
    ],
    errors: [],
    _meta: { rateLimit: { limit: 60, remaining: 57 } }
  },
  {
    unpublishedItemIds: [
      "<item_id_1>",
      "<item_id_2>",
      "<item_id_x>",
    ],
    errors: [],
    _meta: { rateLimit: { limit: 60, remaining: 56 } }
  }
]