'use strict'

const express = require('express')
const router  = express.Router()
const c       = require('../controllers/clienteController')

// Todas as rotas de clientes exigem auth de admin
const { verifyToken } = require('../middleware/auth')
router.use(verifyToken)

router.get('/',                               c.list)
router.get('/:id',                            c.get)
router.post('/',                              c.create)
router.put('/:id',                            c.update)
router.delete('/:id',                         c.remove)

// Endereços
router.get('/:id/enderecos',                  c.listEnderecos)
router.post('/:id/enderecos',                 c.addEndereco)
router.put('/:id/enderecos/:endId',           c.updateEndereco)
router.delete('/:id/enderecos/:endId',        c.removeEndereco)

// Telefones
router.get('/:id/telefones',                  c.listTelefones)
router.post('/:id/telefones',                 c.addTelefone)
router.put('/:id/telefones/:telId',           c.updateTelefone)
router.delete('/:id/telefones/:telId',        c.removeTelefone)

// Responsáveis
router.get('/:id/responsaveis',               c.listResponsaveis)
router.post('/:id/responsaveis',              c.addResponsavel)
router.put('/:id/responsaveis/:respId',       c.updateResponsavel)
router.delete('/:id/responsaveis/:respId',    c.removeResponsavel)

module.exports = router
