9cf7484580069638089b7c2c64ae3bdc213505a0
[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 _0x527c=['ChatQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','ChatQueueReport,\x20%s,\x20%s','message','result','catch','CreateChatQueueReport','ChatQueueReport','create','body','options','raw','then','update','attributes','limit','UpdateChatQueueReport','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','http','info','request\x20sent','debug'];(function(_0x4bc65f,_0x39ec43){var _0x44f85f=function(_0x175343){while(--_0x175343){_0x4bc65f['push'](_0x4bc65f['shift']());}};_0x44f85f(++_0x39ec43);}(_0x527c,0xb3));var _0xc527=function(_0x22bf47,_0x5b3cfd){_0x22bf47=_0x22bf47-0x0;var _0x63e280=_0x527c[_0x22bf47];return _0x63e280;};'use strict';var _=require(_0xc527('0x0'));var util=require(_0xc527('0x1'));var moment=require(_0xc527('0x2'));var BPromise=require(_0xc527('0x3'));var rs=require(_0xc527('0x4'));var fs=require('fs');var Redis=require(_0xc527('0x5'));var db=require(_0xc527('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0xc527('0x7'))('rpc');var config=require(_0xc527('0x8'));var jayson=require('jayson/promise');var client=jayson['client'][_0xc527('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3a1f35,_0x3550fe,_0x330bec){return new BPromise(function(_0x21c660,_0x14e539){return client['request'](_0x3a1f35,_0x330bec)['then'](function(_0x43e10e){logger[_0xc527('0xa')]('ChatQueueReport,\x20%s,\x20%s',_0x3550fe,_0xc527('0xb'));logger[_0xc527('0xc')](_0xc527('0xd'),_0x3550fe,_0xc527('0xb'),JSON[_0xc527('0xe')](_0x43e10e));if(_0x43e10e[_0xc527('0xf')]){if(_0x43e10e[_0xc527('0xf')][_0xc527('0x10')]===0x1f4){logger['error'](_0xc527('0x11'),_0x3550fe,_0x43e10e[_0xc527('0xf')]['message']);return _0x14e539(_0x43e10e['error'][_0xc527('0x12')]);}logger[_0xc527('0xf')]('ChatQueueReport,\x20%s,\x20%s',_0x3550fe,_0x43e10e[_0xc527('0xf')][_0xc527('0x12')]);return _0x21c660(_0x43e10e[_0xc527('0xf')][_0xc527('0x12')]);}else{logger[_0xc527('0xa')](_0xc527('0x11'),_0x3550fe,'request\x20sent');_0x21c660(_0x43e10e[_0xc527('0x13')][_0xc527('0x12')]);}})[_0xc527('0x14')](function(_0x1faeec){logger[_0xc527('0xf')](_0xc527('0x11'),_0x3550fe,_0x1faeec);_0x14e539(_0x1faeec);});});}exports[_0xc527('0x15')]=function(_0x2be737){var _0x45823e=this;return new Promise(function(_0x26b215,_0x2caad1){return db[_0xc527('0x16')][_0xc527('0x17')](_0x2be737[_0xc527('0x18')],{'raw':_0x2be737['options']?_0x2be737[_0xc527('0x19')][_0xc527('0x1a')]===undefined?!![]:![]:!![]})[_0xc527('0x1b')](function(_0x287e5d){logger[_0xc527('0xa')](_0xc527('0x15'),_0x2be737);logger[_0xc527('0xc')]('CreateChatQueueReport',_0x2be737,JSON[_0xc527('0xe')](_0x287e5d));_0x26b215(_0x287e5d);})['catch'](function(_0x585a9d){logger['error']('CreateChatQueueReport',_0x585a9d['message'],_0x2be737);_0x2caad1(_0x45823e[_0xc527('0xf')](0x1f4,_0x585a9d[_0xc527('0x12')]));});});};exports['UpdateChatQueueReport']=function(_0x5e4364){var _0x160574=this;return new Promise(function(_0x2ad84d,_0x1ae64e){return db[_0xc527('0x16')][_0xc527('0x1c')](_0x5e4364[_0xc527('0x18')],{'raw':_0x5e4364[_0xc527('0x19')]?_0x5e4364['options'][_0xc527('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5e4364[_0xc527('0x19')]?_0x5e4364['options']['where']||null:null,'attributes':_0x5e4364[_0xc527('0x19')]?_0x5e4364[_0xc527('0x19')][_0xc527('0x1d')]||null:null,'limit':_0x5e4364[_0xc527('0x19')]?_0x5e4364[_0xc527('0x19')][_0xc527('0x1e')]||null:null})[_0xc527('0x1b')](function(_0x26469b){logger['info'](_0xc527('0x1f'),_0x5e4364);logger[_0xc527('0xc')](_0xc527('0x1f'),_0x5e4364,JSON['stringify'](_0x26469b));_0x2ad84d(_0x26469b);})[_0xc527('0x14')](function(_0x3d7dd5){logger[_0xc527('0xf')](_0xc527('0x1f'),_0x3d7dd5[_0xc527('0x12')],_0x5e4364);_0x1ae64e(_0x160574[_0xc527('0xf')](0x1f4,_0x3d7dd5[_0xc527('0x12')]));});});};