export default class BaseListGetterApiConsumer {
    constructor({ defaultListObject = {}, listResponseHandler, } = {}) {
        this.responseHandler = (response) => {
            let items = [];
            const next = response.next || false;
            if (response.items) {
                items = response.items.map((item) => ({
                    ...this.defaultListObject,
                    ...item,
                }));
            }
            return { ...response, items, next };
        };
        this.defaultListObject = defaultListObject;
        if (listResponseHandler)
            this.userResponseHandler = listResponseHandler;
    }
    async getLookup(params = {}) {
        const defaultLookupParams = {
            size: 20,
            fields: ['id', 'name'],
        };
        try {
            const response = await this.getList({ ...defaultLookupParams, ...params });
            return response;
        }
        catch (err) {
            throw err;
        }
    }
    setGetListMethod(method) {
        this.getList = method(this._getList.bind(this));
        return this;
    }
}
//# sourceMappingURL=base-list-getter-api-consumer.js.map