"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.OwnerController = void 0;
const common_1 = require("@nestjs/common");
const zod_validation_pipe_1 = require("../../common/pipes/zod-validation.pipe");
const config_1 = require("../../config");
const shared_dto_1 = require("../shared/shared.dto");
const login_throttle_guard_1 = require("./guards/login-throttle.guard");
const owner_dto_1 = require("./owner.dto");
const owner_service_1 = require("./owner.service");
let OwnerController = class OwnerController {
    constructor(service) {
        this.service = service;
    }
    async signup(data, res) {
        const result = await this.service.createOwner(data);
        return res.status(common_1.HttpStatus.CREATED).json(result);
    }
    async resendOtp(data, res) {
        const result = await this.service.resendOtp(data?.email);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async verifyOtp(data, res) {
        config_1.logger.info(`Received OTP verification request for email: ${data?.email}`);
        const result = await this.service.verifyOtp(data?.email, data?.otp);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async singin(data, res) {
        const result = await this.service.signin(data);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async update(id, data, res) {
        config_1.logger.info(`Received update request for owner ID: ${id} data ${JSON.stringify(data)}`);
        const result = await this.service.updateOwner(data, id);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async forgotPassword(data, res) {
        const result = await this.service.forgotPassword(data?.email);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async resetVerifyOtp(data, res) {
        const result = await this.service.resetVerifyOtp(data);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async resetPassword(data, res) {
        const result = await this.service.resetPassword(data);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async changePassword(id, data, res) {
        const result = await this.service.changePassword(id, data);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
};
exports.OwnerController = OwnerController;
__decorate([
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(owner_dto_1.createOwnerSchema)),
    (0, common_1.Post)('signup'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], OwnerController.prototype, "signup", null);
__decorate([
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(owner_dto_1.resendOtpSchema)),
    (0, common_1.Post)('resend-otp'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], OwnerController.prototype, "resendOtp", null);
__decorate([
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(shared_dto_1.verifyOtpSchema)),
    (0, common_1.Post)('verify-otp'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], OwnerController.prototype, "verifyOtp", null);
__decorate([
    (0, common_1.UseGuards)(login_throttle_guard_1.LoginThrottlerGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(owner_dto_1.signinOwnerSchema)),
    (0, common_1.Post)('signin'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], OwnerController.prototype, "singin", null);
__decorate([
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(owner_dto_1.updateOwnerSchema)),
    (0, common_1.Patch)('update/:id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, Object]),
    __metadata("design:returntype", Promise)
], OwnerController.prototype, "update", null);
__decorate([
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(owner_dto_1.resendOtpSchema)),
    (0, common_1.Post)('forgot-password'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], OwnerController.prototype, "forgotPassword", null);
__decorate([
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(shared_dto_1.resetOtpSchema)),
    (0, common_1.Post)('reset-verify-otp'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], OwnerController.prototype, "resetVerifyOtp", null);
__decorate([
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(shared_dto_1.resetPasswordSchema)),
    (0, common_1.Post)('reset-password'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], OwnerController.prototype, "resetPassword", null);
__decorate([
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(shared_dto_1.changePasswordSchema)),
    (0, common_1.Patch)('change-password/:id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, Object]),
    __metadata("design:returntype", Promise)
], OwnerController.prototype, "changePassword", null);
exports.OwnerController = OwnerController = __decorate([
    (0, common_1.Controller)('owner'),
    __metadata("design:paramtypes", [owner_service_1.OwnerService])
], OwnerController);
//# sourceMappingURL=owner.controller.js.map