import { z } from 'zod';
import { globalOptionsZod } from '../../../../Command.js';
import request from '../../../../request.js';
import PlannerCommand from '../../../base/PlannerCommand.js';
import commands from '../../commands.js';
export const options = z.strictObject({
    ...globalOptionsZod.shape,
    isPlannerAllowed: z.boolean().optional(),
    allowCalendarSharing: z.boolean().optional(),
    allowTenantMoveWithDataLoss: z.boolean().optional(),
    allowTenantMoveWithDataMigration: z.boolean().optional(),
    allowRosterCreation: z.boolean().optional(),
    allowPlannerMobilePushNotifications: z.boolean().optional()
});
class PlannerTenantSettingsSetCommand extends PlannerCommand {
    get name() {
        return commands.TENANT_SETTINGS_SET;
    }
    get description() {
        return 'Sets Microsoft Planner configuration of the tenant';
    }
    get schema() {
        return options;
    }
    getRefinedSchema(schema) {
        return schema
            .refine(opts => opts.isPlannerAllowed !== undefined || opts.allowCalendarSharing !== undefined || opts.allowTenantMoveWithDataLoss !== undefined || opts.allowTenantMoveWithDataMigration !== undefined || opts.allowRosterCreation !== undefined || opts.allowPlannerMobilePushNotifications !== undefined, {
            message: 'You must specify at least one option',
            params: {
                customCode: 'required'
            }
        });
    }
    async commandAction(logger, args) {
        const requestOptions = {
            url: `${this.resource}/taskAPI/tenantAdminSettings/Settings`,
            headers: {
                accept: 'application/json;odata.metadata=none',
                prefer: 'return=representation'
            },
            responseType: 'json',
            data: {
                isPlannerAllowed: args.options.isPlannerAllowed,
                allowCalendarSharing: args.options.allowCalendarSharing,
                allowTenantMoveWithDataLoss: args.options.allowTenantMoveWithDataLoss,
                allowTenantMoveWithDataMigration: args.options.allowTenantMoveWithDataMigration,
                allowRosterCreation: args.options.allowRosterCreation,
                allowPlannerMobilePushNotifications: args.options.allowPlannerMobilePushNotifications
            }
        };
        try {
            const result = await request.patch(requestOptions);
            await logger.log(result);
        }
        catch (err) {
            this.handleRejectedODataJsonPromise(err);
        }
    }
}
export default new PlannerTenantSettingsSetCommand();
//# sourceMappingURL=tenant-settings-set.js.map