"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const commandBase_js_1 = require("../validation/commandBase.js");
class Getter extends commandBase_js_1.CommandBase {
    additional;
    after;
    className;
    limit;
    tenant;
    objectsPath;
    constructor(client, objectsPath) {
        super(client);
        this.objectsPath = objectsPath;
        this.additional = [];
    }
    withClassName = (className) => {
        this.className = className;
        return this;
    };
    withAfter = (id) => {
        this.after = id;
        return this;
    };
    withLimit = (limit) => {
        this.limit = limit;
        return this;
    };
    withTenant = (tenant) => {
        this.tenant = tenant;
        return this;
    };
    extendAdditional = (prop) => {
        this.additional = [...this.additional, prop];
        return this;
    };
    withAdditional = (additionalFlag) => this.extendAdditional(additionalFlag);
    withVector = () => this.extendAdditional('vector');
    validate() {
        // nothing to validate
    }
    do = () => {
        if (this.errors.length > 0) {
            return Promise.reject(new Error('invalid usage: ' + this.errors.join(', ')));
        }
        return this.objectsPath
            .buildGet(this.className, this.limit, this.additional, this.after, this.tenant)
            .then((path) => {
            return this.client.get(path);
        });
    };
}
exports.default = Getter;
