"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.SettlementsController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const settlements_service_1 = require("./settlements.service");
const create_settlement_dto_1 = require("./dto/create-settlement.dto");
const settlement_query_dto_1 = require("./dto/settlement-query.dto");
const settlement_response_dto_1 = require("./dto/settlement-response.dto");
const current_user_decorator_1 = require("../../common/decorators/current-user.decorator");
const group_member_guard_1 = require("../../common/guards/group-member.guard");
let SettlementsController = class SettlementsController {
    constructor(settlementsService) {
        this.settlementsService = settlementsService;
    }
    createSettlement(user, dto) {
        return this.settlementsService.createSettlement(user.id, dto);
    }
    listMySettlements(user, query) {
        return this.settlementsService.listMySettlements(user.id, query);
    }
    listGroupSettlements(groupId, query) {
        return this.settlementsService.listGroupSettlements(groupId, query);
    }
    getSettlement(id, user) {
        return this.settlementsService.getSettlement(id, user.id);
    }
    confirmSettlement(id, user) {
        return this.settlementsService.confirmSettlement(id, user.id);
    }
};
exports.SettlementsController = SettlementsController;
__decorate([
    (0, common_1.Post)('settlements'),
    (0, swagger_1.ApiOperation)({ summary: 'Record a payment' }),
    (0, swagger_1.ApiResponse)({ status: 201, type: settlement_response_dto_1.SettlementDto }),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, create_settlement_dto_1.CreateSettlementDto]),
    __metadata("design:returntype", Promise)
], SettlementsController.prototype, "createSettlement", null);
__decorate([
    (0, common_1.Get)('settlements'),
    (0, swagger_1.ApiOperation)({ summary: 'List my settlements' }),
    (0, swagger_1.ApiResponse)({ status: 200, type: settlement_response_dto_1.PaginatedSettlementsDto }),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Query)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, settlement_query_dto_1.SettlementQueryDto]),
    __metadata("design:returntype", Promise)
], SettlementsController.prototype, "listMySettlements", null);
__decorate([
    (0, common_1.Get)('groups/:id/settlements'),
    (0, common_1.UseGuards)(group_member_guard_1.GroupMemberGuard),
    (0, swagger_1.ApiParam)({ name: 'id', description: 'Group ID' }),
    (0, swagger_1.ApiOperation)({ summary: 'List settlements in a group' }),
    (0, swagger_1.ApiResponse)({ status: 200, type: settlement_response_dto_1.PaginatedSettlementsDto }),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Query)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, settlement_query_dto_1.SettlementQueryDto]),
    __metadata("design:returntype", Promise)
], SettlementsController.prototype, "listGroupSettlements", null);
__decorate([
    (0, common_1.Get)('settlements/:id'),
    (0, swagger_1.ApiParam)({ name: 'id', description: 'Settlement ID' }),
    (0, swagger_1.ApiOperation)({ summary: 'Get settlement detail' }),
    (0, swagger_1.ApiResponse)({ status: 200, type: settlement_response_dto_1.SettlementDto }),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object]),
    __metadata("design:returntype", Promise)
], SettlementsController.prototype, "getSettlement", null);
__decorate([
    (0, common_1.Patch)('settlements/:id/confirm'),
    (0, common_1.HttpCode)(common_1.HttpStatus.OK),
    (0, swagger_1.ApiParam)({ name: 'id', description: 'Settlement ID' }),
    (0, swagger_1.ApiOperation)({ summary: 'Confirm receipt of payment (payee only)' }),
    (0, swagger_1.ApiResponse)({ status: 200, type: settlement_response_dto_1.SettlementDto }),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object]),
    __metadata("design:returntype", Promise)
], SettlementsController.prototype, "confirmSettlement", null);
exports.SettlementsController = SettlementsController = __decorate([
    (0, swagger_1.ApiTags)('Settlements'),
    (0, swagger_1.ApiBearerAuth)(),
    (0, common_1.Controller)({ version: '1' }),
    __metadata("design:paramtypes", [settlements_service_1.SettlementsService])
], SettlementsController);
//# sourceMappingURL=settlements.controller.js.map