5ded315a18212583d9bb610d71b8603c12bfd2c2
[motion2.git] / server / api / openchannelQueueReport / openchannelQueueReport.rpc.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x02f4=['request\x20sent','debug','OpenchannelQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreateOpenchannelQueueReport','OpenchannelQueueReport','body','UpdateOpenchannelQueueReport','update','where','options','attributes','limit','then','lodash','util','moment','bluebird','ioredis','../../config/logger','rpc','jayson/promise','client','http','request','info','OpenchannelQueueReport,\x20%s,\x20%s'];(function(_0x3bab60,_0x172c70){var _0x44105b=function(_0x2f00f8){while(--_0x2f00f8){_0x3bab60['push'](_0x3bab60['shift']());}};_0x44105b(++_0x172c70);}(_0x02f4,0xb3));var _0x402f=function(_0x40a045,_0x516f0e){_0x40a045=_0x40a045-0x0;var _0x1a687c=_0x02f4[_0x40a045];return _0x1a687c;};'use strict';var _=require(_0x402f('0x0'));var util=require(_0x402f('0x1'));var moment=require(_0x402f('0x2'));var BPromise=require(_0x402f('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x402f('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x402f('0x5'))(_0x402f('0x6'));var config=require('../../config/environment');var jayson=require(_0x402f('0x7'));var client=jayson[_0x402f('0x8')][_0x402f('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3ce70d,_0x2cdf93,_0x9d792d){return new BPromise(function(_0x5b3f16,_0x81e3f4){return client[_0x402f('0xa')](_0x3ce70d,_0x9d792d)['then'](function(_0x3b7cb3){logger[_0x402f('0xb')](_0x402f('0xc'),_0x2cdf93,_0x402f('0xd'));logger[_0x402f('0xe')](_0x402f('0xf'),_0x2cdf93,_0x402f('0xd'),JSON[_0x402f('0x10')](_0x3b7cb3));if(_0x3b7cb3[_0x402f('0x11')]){if(_0x3b7cb3[_0x402f('0x11')][_0x402f('0x12')]===0x1f4){logger['error'](_0x402f('0xc'),_0x2cdf93,_0x3b7cb3['error'][_0x402f('0x13')]);return _0x81e3f4(_0x3b7cb3[_0x402f('0x11')]['message']);}logger['error'](_0x402f('0xc'),_0x2cdf93,_0x3b7cb3['error']['message']);return _0x5b3f16(_0x3b7cb3[_0x402f('0x11')][_0x402f('0x13')]);}else{logger['info'](_0x402f('0xc'),_0x2cdf93,_0x402f('0xd'));_0x5b3f16(_0x3b7cb3[_0x402f('0x14')][_0x402f('0x13')]);}})[_0x402f('0x15')](function(_0x5ea3d0){logger[_0x402f('0x11')]('OpenchannelQueueReport,\x20%s,\x20%s',_0x2cdf93,_0x5ea3d0);_0x81e3f4(_0x5ea3d0);});});}exports[_0x402f('0x16')]=function(_0x2ccc15){var _0x5ed522=this;return new Promise(function(_0x135a64,_0x87ea56){return db[_0x402f('0x17')]['create'](_0x2ccc15[_0x402f('0x18')],{'raw':_0x2ccc15['options']?_0x2ccc15['options']['raw']===undefined?!![]:![]:!![]})['then'](function(_0x359303){logger['info'](_0x402f('0x16'),_0x2ccc15);logger[_0x402f('0xe')](_0x402f('0x16'),_0x2ccc15,JSON[_0x402f('0x10')](_0x359303));_0x135a64(_0x359303);})[_0x402f('0x15')](function(_0x1cf242){logger[_0x402f('0x11')](_0x402f('0x16'),_0x1cf242['message'],_0x2ccc15);_0x87ea56(_0x5ed522[_0x402f('0x11')](0x1f4,_0x1cf242[_0x402f('0x13')]));});});};exports[_0x402f('0x19')]=function(_0x4d750c){var _0x5cee31=this;return new Promise(function(_0xa4e241,_0x2b00b7){return db[_0x402f('0x17')][_0x402f('0x1a')](_0x4d750c[_0x402f('0x18')],{'raw':_0x4d750c['options']?_0x4d750c['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4d750c['options']?_0x4d750c['options'][_0x402f('0x1b')]||null:null,'attributes':_0x4d750c[_0x402f('0x1c')]?_0x4d750c[_0x402f('0x1c')][_0x402f('0x1d')]||null:null,'limit':_0x4d750c[_0x402f('0x1c')]?_0x4d750c[_0x402f('0x1c')][_0x402f('0x1e')]||null:null})[_0x402f('0x1f')](function(_0x1c21f4){logger[_0x402f('0xb')](_0x402f('0x19'),_0x4d750c);logger[_0x402f('0xe')]('UpdateOpenchannelQueueReport',_0x4d750c,JSON['stringify'](_0x1c21f4));_0xa4e241(_0x1c21f4);})['catch'](function(_0x3c5108){logger[_0x402f('0x11')]('UpdateOpenchannelQueueReport',_0x3c5108[_0x402f('0x13')],_0x4d750c);_0x2b00b7(_0x5cee31[_0x402f('0x11')](0x1f4,_0x3c5108['message']));});});};