Create support_logs (db & api)

This commit is contained in:
goga-m 2017-10-27 17:36:40 +03:00 committed by Josh Harvey
parent b7d6f3f419
commit 62d606cc80
8 changed files with 279 additions and 58 deletions

View file

@ -29,6 +29,7 @@ const server = require('./server')
const transactions = require('./transactions')
const customers = require('../customers')
const logs = require('../logs')
const supportLogs = require('../support_logs')
const funding = require('./funding')
const _ = require('lodash/fp')
@ -202,6 +203,43 @@ app.get('/api/logs', (req, res, next) => {
.catch(next)
})
/**
* Get support_logs for the last 2 days
*
* @name get
* @function
* @async
*
* @param {string} '/api/support_logs/ URl to handle
* @param {object} req Request object
* @param {object} res Response object
* @param {function} next Callback
*/
app.get('/api/support_logs/:timestamp', (req, res, next) => {
const timestamp = req.params.timestamp || new Date().toISOString()
return supportLogs.batch(timestamp)
.then(r => res.send(r))
.catch(next)
})
/**
* Create a new support log
*
* @name post
* @function
* @async
*
* @param {string} '/api/support_logs' URL Endpoint
* @param {object} req Request object
* @param {object} res Response object
* @param {function} next Callback
*/
app.post('/api/support_logs', (req, res, next) => {
return supportLogs.insert(req.query.deviceId)
.then(r => res.send(r))
.catch(next)
})
/**
* Endpoint for patching customer's data
*