"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.PaymentController = void 0;
const common_1 = require("@nestjs/common");
const payment_service_1 = require("./payment.service");
const payment_dto_1 = require("./payment.dto");
const swagger_1 = require("@nestjs/swagger");
let PaymentController = class PaymentController {
    constructor(paymentService) {
        this.paymentService = paymentService;
    }
    async requestPayment(createPaymentRequestDto) {
        try {
            const res = await this.paymentService.create(createPaymentRequestDto);
            if (res) {
                return {
                    status: true,
                    message: "Successfully saved.",
                };
            }
            else {
                return {
                    status: false,
                    message: "Something wrong.",
                };
            }
        }
        catch (error) {
            throw new common_1.BadRequestException(error.message);
        }
    }
    async findByUserId(userId) {
        try {
            const res = await this.paymentService.findByUserId(+userId);
            return {
                status: true,
                payments: res,
                message: "Payments list",
            };
        }
        catch (error) {
            throw new common_1.BadRequestException(error.message);
        }
    }
    async findByShopId(shopId) {
        try {
            const res = await this.paymentService.findByShopId(+shopId);
            return {
                status: true,
                payments: res,
                message: "Payments list",
            };
        }
        catch (error) {
            throw new common_1.BadRequestException(error.message);
        }
    }
    async findByDriverId(driverId) {
        try {
            const res = await this.paymentService.findByDriverId(+driverId);
            return {
                status: true,
                payments: res,
                message: "Payments list",
            };
        }
        catch (error) {
            throw new common_1.BadRequestException(error.message);
        }
    }
    findOne(id) {
        return this.paymentService.findOne(+id);
    }
};
exports.PaymentController = PaymentController;
__decorate([
    (0, common_1.Post)("collect"),
    __param(0, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [payment_dto_1.CreatePaymentDto]),
    __metadata("design:returntype", Promise)
], PaymentController.prototype, "requestPayment", null);
__decorate([
    (0, common_1.Get)("by-user/:userId"),
    (0, swagger_1.ApiOperation)({ summary: "Get all payments by user id" }),
    (0, swagger_1.ApiResponse)({ status: 200, description: "Payments list" }),
    __param(0, (0, common_1.Param)("userId")),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], PaymentController.prototype, "findByUserId", null);
__decorate([
    (0, common_1.Get)("by-shop/:shopId"),
    (0, swagger_1.ApiOperation)({ summary: "Get all payments by shop id" }),
    (0, swagger_1.ApiResponse)({ status: 200, description: "Payments list" }),
    __param(0, (0, common_1.Param)("shopId")),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], PaymentController.prototype, "findByShopId", null);
__decorate([
    (0, common_1.Get)("by-driver/:driverId"),
    (0, swagger_1.ApiOperation)({ summary: "Get all payments by shop id" }),
    (0, swagger_1.ApiResponse)({ status: 200, description: "Payments list" }),
    __param(0, (0, common_1.Param)("driverId")),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], PaymentController.prototype, "findByDriverId", null);
__decorate([
    (0, common_1.Get)(":id"),
    (0, swagger_1.ApiOperation)({ summary: "Get payment detail by ID" }),
    __param(0, (0, common_1.Param)("id")),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", void 0)
], PaymentController.prototype, "findOne", null);
exports.PaymentController = PaymentController = __decorate([
    (0, common_1.Controller)("app/payment"),
    __metadata("design:paramtypes", [payment_service_1.PaymentService])
], PaymentController);
//# sourceMappingURL=payment.controller.js.map