Patch Customer with authorized_verified status

This commit is contained in:
goga-m 2017-09-21 19:30:02 +03:00 committed by Josh Harvey
parent e347ddc608
commit 3623e41302
3 changed files with 424 additions and 98 deletions

View file

@ -183,6 +183,26 @@ app.get('/api/customer/:id', (req, res, next) => {
})
})
/**
* Endpoint for patching customer's authorized_override status
*
* Possible values: blocked, verified, automatic
*
* @param {string} '/api/customer/ Url to handle
* @param {object} req Request object
* @param {object} res Response object
* @param {function} next Callback
*/
app.patch('/api/customer/:id', (req, res, next) => {
if (!req.query.authorized_override) return res.status(400).send({Error: 'Requires authorized'})
return customers.patch(req.params.id, {
authorized_override: req.query.authorized_override
})
.then(r => res.send(r))
.catch(() => res.status(404).send({Error: 'Not found'}))
})
app.use((err, req, res, next) => {
console.error(err)