{"size": 878, "ext": "js", "max_stars_repo_path": "src/controller/carrinho.controller.js", "max_stars_repo_name": "manuluzlemos/microprojeto_04_sd", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/controller/carrinho.controller.js", "max_issues_repo_name": "manuluzlemos/microprojeto_04_sd", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/controller/carrinho.controller.js", "max_forks_repo_name": "manuluzlemos/microprojeto_04_sd", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.1052631579, "max_line_length": 80, "alphanum_fraction": 0.5842824601}
const { carrinhoService } = require('../service/carrinho.service');

class CarrinhoController {
    exibir() {
        return (request, response) => {
            response.json(carrinhoService.exibirCarrinho());
        };
    }

    adicionar() {
        return (request, response) => {
            const { codigo, quantidade } = request.body;

            response.json(carrinhoService.adicionarProduto(codigo, quantidade));
        };
    }

    remover(){
        return (request, response) => {
            const { codigo } = request.params;

            response.json(carrinhoService.removerProduto(parseInt(codigo)));
        };
    }

    pagar(){
        return (request, response) => {
            response.json(carrinhoService.realizarPagamento());
        }
    }
}

const carrinhoController = new CarrinhoController();

module.exports = {
    carrinhoController
};
