This commit is contained in:
Josh Harvey 2018-05-01 19:35:54 +03:00
parent f7561acf3c
commit 80e851fb59
9 changed files with 131 additions and 76 deletions

View file

@ -186,11 +186,14 @@ function getCustomerWithPhoneCode (req, res, next) {
function updateCustomer (req, res, next) {
const id = req.params.id
const patch = req.body
const config = configManager.unscoped(req.settings.config)
customers.getById(id)
.then(customer => {
if (!customer) { throw httpError('Not Found', 404) }
return customers.update(id, patch)
})
.then(customer => customers.validate(config, customer))
.then(customer => respond(req, res, {customer}))
.catch(next)
}