c5295d58b6f3e70b3fafc0e32588ff5a4edbd350
[motion2.git] / server / api / chatQueueReport / chatQueueReport.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 _0x6741=['jayson/promise','client','http','request','then','ChatQueueReport,\x20%s,\x20%s','request\x20sent','debug','ChatQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','CreateChatQueueReport','ChatQueueReport','options','catch','update','body','raw','where','attributes','limit','UpdateChatQueueReport','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment'];(function(_0x1c4797,_0x30e7fa){var _0x5db0a5=function(_0x482945){while(--_0x482945){_0x1c4797['push'](_0x1c4797['shift']());}};_0x5db0a5(++_0x30e7fa);}(_0x6741,0x1d6));var _0x1674=function(_0x4dfd90,_0x4bc9ad){_0x4dfd90=_0x4dfd90-0x0;var _0x46e27f=_0x6741[_0x4dfd90];return _0x46e27f;};'use strict';var _=require(_0x1674('0x0'));var util=require(_0x1674('0x1'));var moment=require(_0x1674('0x2'));var BPromise=require(_0x1674('0x3'));var rs=require(_0x1674('0x4'));var fs=require('fs');var Redis=require(_0x1674('0x5'));var db=require(_0x1674('0x6'))['db'];var utils=require(_0x1674('0x7'));var logger=require(_0x1674('0x8'))(_0x1674('0x9'));var config=require(_0x1674('0xa'));var jayson=require(_0x1674('0xb'));var client=jayson[_0x1674('0xc')][_0x1674('0xd')]({'port':0x232a});function respondWithRpcPromise(_0x2ad0f5,_0x119c3f,_0x38a7f6){return new BPromise(function(_0x49b2ad,_0x36a1c7){return client[_0x1674('0xe')](_0x2ad0f5,_0x38a7f6)[_0x1674('0xf')](function(_0x1fa115){logger['info'](_0x1674('0x10'),_0x119c3f,_0x1674('0x11'));logger[_0x1674('0x12')](_0x1674('0x13'),_0x119c3f,_0x1674('0x11'),JSON[_0x1674('0x14')](_0x1fa115));if(_0x1fa115['error']){if(_0x1fa115[_0x1674('0x15')][_0x1674('0x16')]===0x1f4){logger['error']('ChatQueueReport,\x20%s,\x20%s',_0x119c3f,_0x1fa115[_0x1674('0x15')][_0x1674('0x17')]);return _0x36a1c7(_0x1fa115[_0x1674('0x15')][_0x1674('0x17')]);}logger[_0x1674('0x15')]('ChatQueueReport,\x20%s,\x20%s',_0x119c3f,_0x1fa115[_0x1674('0x15')][_0x1674('0x17')]);return _0x49b2ad(_0x1fa115[_0x1674('0x15')]['message']);}else{logger[_0x1674('0x18')](_0x1674('0x10'),_0x119c3f,_0x1674('0x11'));_0x49b2ad(_0x1fa115[_0x1674('0x19')]['message']);}})['catch'](function(_0x22d34e){logger[_0x1674('0x15')](_0x1674('0x10'),_0x119c3f,_0x22d34e);_0x36a1c7(_0x22d34e);});});}exports[_0x1674('0x1a')]=function(_0x2c7415){var _0x5d391f=this;return new Promise(function(_0x27a090,_0x2eab47){return db[_0x1674('0x1b')]['create'](_0x2c7415['body'],{'raw':_0x2c7415[_0x1674('0x1c')]?_0x2c7415[_0x1674('0x1c')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x2667ac){logger[_0x1674('0x18')]('CreateChatQueueReport',_0x2c7415);logger[_0x1674('0x12')](_0x1674('0x1a'),_0x2c7415,JSON[_0x1674('0x14')](_0x2667ac));_0x27a090(_0x2667ac);})[_0x1674('0x1d')](function(_0xc81b77){logger['error'](_0x1674('0x1a'),_0xc81b77['message'],_0x2c7415);_0x2eab47(_0x5d391f[_0x1674('0x15')](0x1f4,_0xc81b77[_0x1674('0x17')]));});});};exports['UpdateChatQueueReport']=function(_0x7d4246){var _0x25f4ce=this;return new Promise(function(_0x1f3d82,_0x1a2e48){return db['ChatQueueReport'][_0x1674('0x1e')](_0x7d4246[_0x1674('0x1f')],{'raw':_0x7d4246[_0x1674('0x1c')]?_0x7d4246[_0x1674('0x1c')][_0x1674('0x20')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x7d4246['options']?_0x7d4246['options'][_0x1674('0x21')]||null:null,'attributes':_0x7d4246[_0x1674('0x1c')]?_0x7d4246[_0x1674('0x1c')][_0x1674('0x22')]||null:null,'limit':_0x7d4246[_0x1674('0x1c')]?_0x7d4246[_0x1674('0x1c')][_0x1674('0x23')]||null:null})[_0x1674('0xf')](function(_0x1a476b){logger['info'](_0x1674('0x24'),_0x7d4246);logger[_0x1674('0x12')]('UpdateChatQueueReport',_0x7d4246,JSON[_0x1674('0x14')](_0x1a476b));_0x1f3d82(_0x1a476b);})[_0x1674('0x1d')](function(_0xb9047e){logger[_0x1674('0x15')](_0x1674('0x24'),_0xb9047e[_0x1674('0x17')],_0x7d4246);_0x1a2e48(_0x25f4ce[_0x1674('0x15')](0x1f4,_0xb9047e[_0x1674('0x17')]));});});};