d0e190a246bf156a1425ddaacb9eb31971a5988e
[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 _0x5f60=['ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','request','then','ChatQueueReport,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','info','result','catch','CreateChatQueueReport','ChatQueueReport','create','body','options','raw','UpdateChatQueueReport','where','limit','util','bluebird'];(function(_0x34d171,_0x2dca17){var _0x35612a=function(_0x385f80){while(--_0x385f80){_0x34d171['push'](_0x34d171['shift']());}};_0x35612a(++_0x2dca17);}(_0x5f60,0x134));var _0x05f6=function(_0x13945b,_0x289c94){_0x13945b=_0x13945b-0x0;var _0x1b1643=_0x5f60[_0x13945b];return _0x1b1643;};'use strict';var _=require('lodash');var util=require(_0x05f6('0x0'));var moment=require('moment');var BPromise=require(_0x05f6('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x05f6('0x2'));var db=require(_0x05f6('0x3'))['db'];var utils=require(_0x05f6('0x4'));var logger=require('../../config/logger')(_0x05f6('0x5'));var config=require(_0x05f6('0x6'));var jayson=require(_0x05f6('0x7'));var client=jayson[_0x05f6('0x8')][_0x05f6('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x5cf6c0,_0x4fb112,_0x3d253c){return new BPromise(function(_0x344f3a,_0x139e9f){return client[_0x05f6('0xa')](_0x5cf6c0,_0x3d253c)[_0x05f6('0xb')](function(_0x25dcee){logger['info'](_0x05f6('0xc'),_0x4fb112,'request\x20sent');logger[_0x05f6('0xd')]('ChatQueueReport,\x20%s,\x20%s,\x20%s',_0x4fb112,_0x05f6('0xe'),JSON[_0x05f6('0xf')](_0x25dcee));if(_0x25dcee[_0x05f6('0x10')]){if(_0x25dcee[_0x05f6('0x10')][_0x05f6('0x11')]===0x1f4){logger[_0x05f6('0x10')](_0x05f6('0xc'),_0x4fb112,_0x25dcee['error']['message']);return _0x139e9f(_0x25dcee['error'][_0x05f6('0x12')]);}logger[_0x05f6('0x10')]('ChatQueueReport,\x20%s,\x20%s',_0x4fb112,_0x25dcee[_0x05f6('0x10')]['message']);return _0x344f3a(_0x25dcee[_0x05f6('0x10')][_0x05f6('0x12')]);}else{logger[_0x05f6('0x13')]('ChatQueueReport,\x20%s,\x20%s',_0x4fb112,_0x05f6('0xe'));_0x344f3a(_0x25dcee[_0x05f6('0x14')]['message']);}})[_0x05f6('0x15')](function(_0x1f6eb7){logger['error']('ChatQueueReport,\x20%s,\x20%s',_0x4fb112,_0x1f6eb7);_0x139e9f(_0x1f6eb7);});});}exports[_0x05f6('0x16')]=function(_0x19e29c){var _0x3c6c1d=this;return new Promise(function(_0x277af7,_0x2140cf){return db[_0x05f6('0x17')][_0x05f6('0x18')](_0x19e29c[_0x05f6('0x19')],{'raw':_0x19e29c['options']?_0x19e29c[_0x05f6('0x1a')][_0x05f6('0x1b')]===undefined?!![]:![]:!![]})[_0x05f6('0xb')](function(_0x3a98c9){logger[_0x05f6('0x13')]('CreateChatQueueReport',_0x19e29c);logger['debug'](_0x05f6('0x16'),_0x19e29c,JSON[_0x05f6('0xf')](_0x3a98c9));_0x277af7(_0x3a98c9);})['catch'](function(_0x187b2d){logger[_0x05f6('0x10')](_0x05f6('0x16'),_0x187b2d[_0x05f6('0x12')],_0x19e29c);_0x2140cf(_0x3c6c1d[_0x05f6('0x10')](0x1f4,_0x187b2d[_0x05f6('0x12')]));});});};exports[_0x05f6('0x1c')]=function(_0x983e4b){var _0x1b05d0=this;return new Promise(function(_0x90892c,_0x21a627){return db[_0x05f6('0x17')]['update'](_0x983e4b[_0x05f6('0x19')],{'raw':_0x983e4b[_0x05f6('0x1a')]?_0x983e4b[_0x05f6('0x1a')][_0x05f6('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x983e4b['options']?_0x983e4b['options'][_0x05f6('0x1d')]||null:null,'attributes':_0x983e4b[_0x05f6('0x1a')]?_0x983e4b[_0x05f6('0x1a')]['attributes']||null:null,'limit':_0x983e4b[_0x05f6('0x1a')]?_0x983e4b[_0x05f6('0x1a')][_0x05f6('0x1e')]||null:null})[_0x05f6('0xb')](function(_0x12fe30){logger[_0x05f6('0x13')]('UpdateChatQueueReport',_0x983e4b);logger[_0x05f6('0xd')]('UpdateChatQueueReport',_0x983e4b,JSON[_0x05f6('0xf')](_0x12fe30));_0x90892c(_0x12fe30);})[_0x05f6('0x15')](function(_0xd5116e){logger[_0x05f6('0x10')](_0x05f6('0x1c'),_0xd5116e[_0x05f6('0x12')],_0x983e4b);_0x21a627(_0x1b05d0[_0x05f6('0x10')](0x1f4,_0xd5116e[_0x05f6('0x12')]));});});};