"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Validate_1 = __importDefault(require("../Validate/Validate"));
const ProofOfPlayType_1 = __importDefault(require("./ProofOfPlayType"));
/**
 * The `sos.proofOfPlay` API provides methods for recording information about played content on the device.
 *
 * Can be useful for tracking the playback of content, which can be used for analytics, reporting, or debugging purposes.
 */
class ProofOfPlay {
    commandApi;
    /** @internal */
    constructor(commandApi) {
        this.commandApi = commandApi;
    }
    /**
     * The `recordItemPlayed()` method dispatches a `sos.command.dispatch()` command. It sends provided information about played content along
     * with additional metadata about current applet and device to signageOS.
     *
     * @param options The options for recording the played item.
     * @param options.name The name of the item that was played.
     * @param options.customId An optional custom identifier for the item.
     * @param options.type The type of the item that was played. It can be one of the following: `video`, `image`, `html`, or `custom`.
     * @param options.tags An array of tags associated with the item.
     * @param options.fileName The name of the file that was played.
     * @param options.playbackSuccess A boolean indicating whether the playback was successful.
     * @param options.errorMessage An optional error message if the playback was not successful.
     * @returns {Promise<void>} A promise that resolves when the item has been recorded.
     * @throws {Error} If any of the provided options are invalid.
     * @since 5.5.1
     */
    async recordItemPlayed(options) {
        const { name, customId, type, tags, fileName, playbackSuccess, errorMessage } = options;
        (0, Validate_1.default)({ name }).required().string();
        (0, Validate_1.default)({ customId }).string();
        (0, Validate_1.default)({ type }).string(['video', 'image', 'html', 'custom']);
        (0, Validate_1.default)({ tags }).array('string');
        (0, Validate_1.default)({ fileName }).string();
        (0, Validate_1.default)({ playbackSuccess }).boolean();
        (0, Validate_1.default)({ errorMessage }).string();
        await this.commandApi.dispatch({
            type: ProofOfPlayType_1.default.ItemPlayed,
            itemName: name,
            customId,
            itemType: type,
            itemTags: tags,
            fileName,
            playbackSuccess,
            errorMessage,
        });
    }
}
exports.default = ProofOfPlay;
//# sourceMappingURL=ProofOfPlay.js.map