import BaseDeleterApiConsumer from '../base-deleter-api-consumer/base-deleter-api-consumer';
export default class EndpointDeleterApiConsumer extends BaseDeleterApiConsumer {
    constructor({ baseUrl, instance }, params = {}) {
        super();
        this.instance = instance;
        this.baseUrl = baseUrl;
        if (params.nestedUrl)
            this.nestedUrl = params.nestedUrl;
    }
    deleteItem({ id }) {
        return this._deleteItem({ id });
    }
    deleteNestedItem({ parentId, id }) {
        const baseUrl = `${this.baseUrl}/${parentId}/${this.nestedUrl}`;
        return this._deleteItem({ id }, baseUrl);
    }
    async _deleteItem({ id }, baseUrl = this.baseUrl) {
        const delUrl = `${baseUrl}/${id}?permanent=true`;
        try {
            return this.instance.delete(delUrl);
        }
        catch (err) {
            throw err;
        }
    }
}
//# sourceMappingURL=endpoint-deleter-api-consumer.js.map