"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ViewsCommand = void 0;
const tslib_1 = require("tslib");
const shared_1 = require("../shared");
class ViewsCommand extends shared_1.AbstractCommand {
    view(options) {
        const { id, xForwardedFor, viewEvent, currentTime } = options;
        const path = '/api/v1/videos/' + id + '/views';
        return this.postBodyRequest(Object.assign(Object.assign({}, options), { path,
            xForwardedFor, fields: {
                currentTime: currentTime !== null && currentTime !== void 0 ? currentTime : 1,
                viewEvent
            }, implicitToken: false, defaultExpectedStatus: 204 }));
    }
    simulateView(options) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield this.view(Object.assign(Object.assign({}, options), { currentTime: 0 }));
            yield this.view(Object.assign(Object.assign({}, options), { currentTime: 5 }));
        });
    }
    simulateViewer(options) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            let viewEvent = 'seek';
            for (const currentTime of options.currentTimes) {
                yield this.view(Object.assign(Object.assign({}, options), { currentTime, viewEvent }));
                viewEvent = undefined;
            }
        });
    }
}
exports.ViewsCommand = ViewsCommand;
//# sourceMappingURL=views-command.js.map