"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SyncAudiences = void 0;
class SyncAudiences {
    constructor(request, settings) {
        this.request = request;
        this.partnerApiKey = (settings.endpoint.includes('eu')
            ? process.env.BRAZE_COHORTS_PARTNER_API_KEY_EU
            : process.env.BRAZE_COHORTS_PARTNER_API_KEY_US);
    }
    async createCohort(settings, payload) {
        return this.request(`${settings.endpoint}/partners/segment/cohorts`, {
            method: 'POST',
            json: {
                partner_api_key: this.partnerApiKey,
                client_secret: settings.client_secret,
                name: payload?.cohort_name,
                cohort_id: payload?.cohort_id,
                created_at: payload?.time
            }
        });
    }
    async batchUpdate(settings, cohort_id, cohortChanges) {
        return this.request(`${settings.endpoint}/partners/segment/cohorts/users`, {
            method: 'POST',
            json: {
                partner_api_key: this.partnerApiKey,
                client_secret: settings.client_secret,
                cohort_id: cohort_id,
                cohort_changes: cohortChanges.map((change) => ({
                    user_ids: change.user_ids,
                    device_ids: change.device_ids,
                    aliases: change.aliases,
                    should_remove: change.should_remove
                }))
            }
        });
    }
}
exports.SyncAudiences = SyncAudiences;
//# sourceMappingURL=index.js.map