"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.SubscriptionsController = void 0; const common_1 = require("@nestjs/common"); const swagger_1 = require("@nestjs/swagger"); const jwt_auth_guard_1 = require("../auth/guards/jwt-auth.guard"); const subscriptions_service_1 = require("./subscriptions.service"); let SubscriptionsController = class SubscriptionsController { constructor(subscriptionsService) { this.subscriptionsService = subscriptionsService; } getPlans() { return this.subscriptionsService.getPlans(); } getPlan(code) { return this.subscriptionsService.getPlanByCode(code); } getCurrent(req) { return this.subscriptionsService.getSubscription(req.user.tenantId); } getStats(req) { return this.subscriptionsService.getSubscriptionStats(req.user.tenantId); } cancel(req) { return this.subscriptionsService.cancelSubscription(req.user.tenantId); } getTokenBalance(req) { return this.subscriptionsService.getTokenBalance(req.user.tenantId); } getTokenUsage(req, limit) { return this.subscriptionsService.getTokenUsage(req.user.tenantId, limit); } }; exports.SubscriptionsController = SubscriptionsController; __decorate([ (0, common_1.Get)('plans'), (0, swagger_1.ApiOperation)({ summary: 'Listar planes disponibles' }), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], SubscriptionsController.prototype, "getPlans", null); __decorate([ (0, common_1.Get)('plans/:code'), (0, swagger_1.ApiOperation)({ summary: 'Obtener plan por código' }), __param(0, (0, common_1.Param)('code')), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], SubscriptionsController.prototype, "getPlan", null); __decorate([ (0, common_1.Get)('current'), (0, swagger_1.ApiOperation)({ summary: 'Obtener suscripción actual' }), __param(0, (0, common_1.Request)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], SubscriptionsController.prototype, "getCurrent", null); __decorate([ (0, common_1.Get)('stats'), (0, swagger_1.ApiOperation)({ summary: 'Estadísticas de suscripción y tokens' }), __param(0, (0, common_1.Request)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], SubscriptionsController.prototype, "getStats", null); __decorate([ (0, common_1.Post)('cancel'), (0, swagger_1.ApiOperation)({ summary: 'Cancelar suscripción al final del período' }), __param(0, (0, common_1.Request)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], SubscriptionsController.prototype, "cancel", null); __decorate([ (0, common_1.Get)('tokens/balance'), (0, swagger_1.ApiOperation)({ summary: 'Obtener balance de tokens' }), __param(0, (0, common_1.Request)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], SubscriptionsController.prototype, "getTokenBalance", null); __decorate([ (0, common_1.Get)('tokens/usage'), (0, swagger_1.ApiOperation)({ summary: 'Historial de uso de tokens' }), (0, swagger_1.ApiQuery)({ name: 'limit', required: false }), __param(0, (0, common_1.Request)()), __param(1, (0, common_1.Query)('limit')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Number]), __metadata("design:returntype", void 0) ], SubscriptionsController.prototype, "getTokenUsage", null); exports.SubscriptionsController = SubscriptionsController = __decorate([ (0, swagger_1.ApiTags)('subscriptions'), (0, swagger_1.ApiBearerAuth)(), (0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard), (0, common_1.Controller)('v1/subscriptions'), __metadata("design:paramtypes", [subscriptions_service_1.SubscriptionsService]) ], SubscriptionsController); //# sourceMappingURL=subscriptions.controller.js.map