b8265b6fbea2b29e7cd2370009f0c3ca86ddcac8
[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 _0x6146=['attributes','limit','UpdateChatQueueReport','util','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','request','then','info','ChatQueueReport,\x20%s,\x20%s','request\x20sent','debug','ChatQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','CreateChatQueueReport','ChatQueueReport','options','raw','update','body','where'];(function(_0x1e123b,_0x2482e5){var _0x31b527=function(_0x166e1a){while(--_0x166e1a){_0x1e123b['push'](_0x1e123b['shift']());}};_0x31b527(++_0x2482e5);}(_0x6146,0x111));var _0x6614=function(_0x590b72,_0x2f603e){_0x590b72=_0x590b72-0x0;var _0x37df5b=_0x6146[_0x590b72];return _0x37df5b;};'use strict';var _=require('lodash');var util=require(_0x6614('0x0'));var moment=require('moment');var BPromise=require(_0x6614('0x1'));var rs=require(_0x6614('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x6614('0x3'))['db'];var utils=require(_0x6614('0x4'));var logger=require(_0x6614('0x5'))(_0x6614('0x6'));var config=require(_0x6614('0x7'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x1d9fce,_0x23d03a,_0x46224e){return new BPromise(function(_0x41725f,_0x181fdd){return client[_0x6614('0x8')](_0x1d9fce,_0x46224e)[_0x6614('0x9')](function(_0x1e4be8){logger[_0x6614('0xa')](_0x6614('0xb'),_0x23d03a,_0x6614('0xc'));logger[_0x6614('0xd')](_0x6614('0xe'),_0x23d03a,_0x6614('0xc'),JSON[_0x6614('0xf')](_0x1e4be8));if(_0x1e4be8[_0x6614('0x10')]){if(_0x1e4be8[_0x6614('0x10')][_0x6614('0x11')]===0x1f4){logger[_0x6614('0x10')](_0x6614('0xb'),_0x23d03a,_0x1e4be8[_0x6614('0x10')]['message']);return _0x181fdd(_0x1e4be8[_0x6614('0x10')]['message']);}logger[_0x6614('0x10')](_0x6614('0xb'),_0x23d03a,_0x1e4be8[_0x6614('0x10')][_0x6614('0x12')]);return _0x41725f(_0x1e4be8['error'][_0x6614('0x12')]);}else{logger[_0x6614('0xa')](_0x6614('0xb'),_0x23d03a,_0x6614('0xc'));_0x41725f(_0x1e4be8['result'][_0x6614('0x12')]);}})[_0x6614('0x13')](function(_0x11ab1a){logger['error']('ChatQueueReport,\x20%s,\x20%s',_0x23d03a,_0x11ab1a);_0x181fdd(_0x11ab1a);});});}exports[_0x6614('0x14')]=function(_0x4d1496){var _0x30e2d6=this;return new Promise(function(_0x5529fc,_0x4ead5a){return db[_0x6614('0x15')]['create'](_0x4d1496['body'],{'raw':_0x4d1496[_0x6614('0x16')]?_0x4d1496['options'][_0x6614('0x17')]===undefined?!![]:![]:!![]})[_0x6614('0x9')](function(_0x675ee6){logger[_0x6614('0xa')](_0x6614('0x14'),_0x4d1496);logger[_0x6614('0xd')](_0x6614('0x14'),_0x4d1496,JSON[_0x6614('0xf')](_0x675ee6));_0x5529fc(_0x675ee6);})[_0x6614('0x13')](function(_0x40ee29){logger[_0x6614('0x10')](_0x6614('0x14'),_0x40ee29[_0x6614('0x12')],_0x4d1496);_0x4ead5a(_0x30e2d6[_0x6614('0x10')](0x1f4,_0x40ee29[_0x6614('0x12')]));});});};exports['UpdateChatQueueReport']=function(_0x285a35){var _0x1c2d69=this;return new Promise(function(_0x205c71,_0x2bb1f8){return db[_0x6614('0x15')][_0x6614('0x18')](_0x285a35[_0x6614('0x19')],{'raw':_0x285a35[_0x6614('0x16')]?_0x285a35[_0x6614('0x16')][_0x6614('0x17')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x285a35[_0x6614('0x16')]?_0x285a35[_0x6614('0x16')][_0x6614('0x1a')]||null:null,'attributes':_0x285a35[_0x6614('0x16')]?_0x285a35['options'][_0x6614('0x1b')]||null:null,'limit':_0x285a35[_0x6614('0x16')]?_0x285a35[_0x6614('0x16')][_0x6614('0x1c')]||null:null})['then'](function(_0x45c15d){logger[_0x6614('0xa')](_0x6614('0x1d'),_0x285a35);logger[_0x6614('0xd')](_0x6614('0x1d'),_0x285a35,JSON[_0x6614('0xf')](_0x45c15d));_0x205c71(_0x45c15d);})[_0x6614('0x13')](function(_0x37975d){logger[_0x6614('0x10')]('UpdateChatQueueReport',_0x37975d[_0x6614('0x12')],_0x285a35);_0x2bb1f8(_0x1c2d69[_0x6614('0x10')](0x1f4,_0x37975d['message']));});});};