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

@ -21,6 +21,19 @@ function get (phone) {
})
}
/**
* Patch Customer
* Note: Currently patching only authorized_verified field
*
* @param {string} id Customer's id
* @param {object} values Values to patch
* @returns {object} Updated customer
*/
function patch (id, values) {
const sql = 'update customers set authorized_override=$2 where id=$1 returning *'
return db.oneOrNone(sql, [id, values.authorized_override])
}
function getById (id) {
const sql = 'select * from customers where id=$1'
return db.oneOrNone(sql, [id])
@ -65,4 +78,4 @@ function batch () {
order by created desc limit $2`
return db.any(sql, [ anonymous.uuid, NUM_RESULTS ])
}
module.exports = { add, get, batch, getById }
module.exports = { add, get, batch, getById, patch}