Sample Flows

This article presents possible sample flows that you can support. This can be a helpful jumping-off point as you plan your implementation.

Note: Learn more about querying data collections using API Query Language.

Set items' Publish status

On a data collection that has the Publish plugin, create a task to publish all special-edition holiday items at the specified time:

  1. Call Create Task and specify the following parameters:

    Copy
    { "task": { "type": "UPDATE_PUBLISH_STATUS", "updatePublishStatusOptions": { "dataCollectionId": "products", "filter": { "holidays": { "$in": ["Halloween"] } }, "operation": "SCHEDULE_PUBLISHED_STATUS", "schedulePublishedStatusOptions": { "date": "2024-10-24T10:00:00Z" } } } }

    The method returns the following response:

    Copy
    { "task": { "id": "b8815393-3bca-4de7-b592-53eeb1465a61", "type": "UPDATE_PUBLISH_STATUS", "status": "NEW", "startedAt": "2024-09-05T10:34:59.507Z", "estimatedItemCount": 5, "itemsSucceeded": 0, "itemsFailed": 0, "failures": [], "updatePublishStatusOptions": { "dataCollectionId": "Products", "filter": { "holidays": { "$in": ["Halloween"] } }, "operation": "SCHEDULE_PUBLISHED_STATUS", "schedulePublishedStatusOptions": { "date": "2024-10-24T10:00:00Z" } } } }
  2. At any point, you can check the task status by calling the Get Task method with the task ID.

    The method returns a response such as:

    Copy
    { "task": { "id": "b8815393-3bca-4de7-b592-53eeb1465a61", "type": "SCHEDULE_PUBLISHED_STATUS", "status": "FAILED", "startedAt": "2024-09-05T10:34:59.507Z", "finishedAt": "2024-09-05T10:35:03.654Z", "estimatedItemCount": 4, "itemsSucceeded": 0, "itemsFailed": 4, "failures": [ { "code": 404, "description": "Collection not found.", "data": { "dataCollectionId": "Products" } } ], "updatePublishStatusOptions": { "dataCollectionId": "Products", "filter": { "holidays": { "$in": ["Halloween"] } }, "operation": "SCHEDULE_PUBLISHED_STATUS", "schedulePublishedStatusOptions": { "date": "2024-10-24T10:00:00Z" } } } }

Delete items by query

Create a task to retrieve and delete all products from a specified manufacturer:

  1. Call Create Task and specify the following parameters:

    Copy
    { "task": { "type": "DELETE_BY_QUERY", "deleteByQueryOptions": { "dataCollectionId": "Products", "filter": { "manufacturer": "BadAcme" } } } }

    The method might return the following response:

    Copy
    { "task": { "id": "097a5564-0fec-4425-8d1e-3e753b48a422", "type": "DELETE_BY_QUERY", "status": "NEW", "startedAt": "2024-09-05T10:34:59.507Z", "estimatedItemCount": 3, "itemsSucceeded": 0, "itemsFailed": 0, "failures": [], "deleteByQueryOptions": { "dataCollectionId": "Products", "filter": { "manufacturer": "BadAcme" } } } }
  2. At any point, you can check the task status by calling the Get Task method with the task ID.

The method returns a response such as:

Copy
{ "task": { "id": "097a5564-0fec-4425-8d1e-3e753b48a422", "type": "DELETE_BY_QUERY", "status": "COMPLETED", "startedAt": "2024-09-05T10:34:59.507Z", "finishedAt": "2024-09-05T10:35:03.654Z", "estimatedItemCount": 3, "itemsSucceeded": 3, "itemsFailed": 0, "failures": [], "deleteByQueryOptions": { "dataCollectionId": "Products", "filter": { "manufacturer": "BadAcme" } } } }
Did this help?