"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const dd_api_1 = __importDefault(require("../dd-api"));
class DDListsApi extends dd_api_1.default {
    constructor(settings, request) {
        super(settings, request);
    }
    async getListsPaging(select = 1000, skip = 0) {
        return await this.get('/v2/address-books', { select, skip });
    }
    async getLists() {
        const choices = [];
        const select = 200;
        let skip = 0;
        let hasMoreData = true;
        while (hasMoreData) {
            const response = await this.getListsPaging(select, skip);
            const content = response.data;
            if (content.length === 0) {
                hasMoreData = false;
                break;
            }
            else {
                choices.push(...content.map((list) => ({
                    value: list.id.toString(),
                    label: list.name
                })));
                skip += select;
            }
        }
        return { choices: choices };
    }
    async deleteContactFromList(listId, contactId) {
        await this.delete(`/v2/address-books/${listId}/contacts/${contactId}`);
    }
}
exports.default = DDListsApi;
//# sourceMappingURL=dd-lists-api.js.map