"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const recombeeApiClient_1 = require("../recombeeApiClient");
const action = {
    title: 'Delete Bookmark',
    description: 'Deletes a bookmark of the given item made by the given user.',
    defaultSubscription: 'type = "track" and event = "Product Removed from Wishlist"',
    fields: {
        userId: {
            label: 'User ID',
            description: 'The ID of the user who bookmarked the item.',
            type: 'string',
            required: true,
            default: {
                '@if': {
                    exists: { '@path': '$.userId' },
                    then: { '@path': '$.userId' },
                    else: { '@path': '$.anonymousId' }
                }
            }
        },
        itemId: {
            label: 'Item ID',
            description: 'The item that was bookmarked.',
            type: 'string',
            required: true,
            default: {
                '@if': {
                    exists: { '@path': '$.properties.product_id' },
                    then: { '@path': '$.properties.product_id' },
                    else: { '@path': '$.properties.asset_id' }
                }
            }
        },
        timestamp: {
            label: 'Timestamp',
            description: 'The UTC timestamp of when the bookmark occurred. If the timestamp is omitted, then all the bookmarks with the given `userId` and `itemId` are deleted.',
            type: 'string',
            required: false
        }
    },
    perform: async (request, data) => {
        const client = new recombeeApiClient_1.RecombeeApiClient(data.settings, request);
        await client.send(new recombeeApiClient_1.DeleteBookmark(data.payload));
    },
    performBatch: async (request, data) => {
        const client = new recombeeApiClient_1.RecombeeApiClient(data.settings, request);
        await client.send(new recombeeApiClient_1.Batch(data.payload.map((payload) => new recombeeApiClient_1.DeleteBookmark(payload))));
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map