24e1f7ed9300fcf33ec3415b2cc020a39028131c
[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 _0x15b3=['moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','then','ChatQueueReport,\x20%s,\x20%s','request\x20sent','debug','ChatQueueReport,\x20%s,\x20%s,\x20%s','error','code','message','info','result','catch','CreateChatQueueReport','ChatQueueReport','body','options','update','limit','UpdateChatQueueReport','stringify','lodash','util'];(function(_0x583c17,_0x2afef1){var _0x8018b6=function(_0x407326){while(--_0x407326){_0x583c17['push'](_0x583c17['shift']());}};_0x8018b6(++_0x2afef1);}(_0x15b3,0x115));var _0x315b=function(_0x304c36,_0x2f311f){_0x304c36=_0x304c36-0x0;var _0x16cc10=_0x15b3[_0x304c36];return _0x16cc10;};'use strict';var _=require(_0x315b('0x0'));var util=require(_0x315b('0x1'));var moment=require(_0x315b('0x2'));var BPromise=require(_0x315b('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x315b('0x4'));var db=require(_0x315b('0x5'))['db'];var utils=require(_0x315b('0x6'));var logger=require(_0x315b('0x7'))('rpc');var config=require(_0x315b('0x8'));var jayson=require(_0x315b('0x9'));var client=jayson[_0x315b('0xa')][_0x315b('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x3db2bf,_0x42d69d,_0x257135){return new BPromise(function(_0x691786,_0x3bb45b){return client['request'](_0x3db2bf,_0x257135)[_0x315b('0xc')](function(_0x4f42ac){logger['info'](_0x315b('0xd'),_0x42d69d,_0x315b('0xe'));logger[_0x315b('0xf')](_0x315b('0x10'),_0x42d69d,_0x315b('0xe'),JSON['stringify'](_0x4f42ac));if(_0x4f42ac[_0x315b('0x11')]){if(_0x4f42ac['error'][_0x315b('0x12')]===0x1f4){logger[_0x315b('0x11')](_0x315b('0xd'),_0x42d69d,_0x4f42ac['error'][_0x315b('0x13')]);return _0x3bb45b(_0x4f42ac[_0x315b('0x11')][_0x315b('0x13')]);}logger['error']('ChatQueueReport,\x20%s,\x20%s',_0x42d69d,_0x4f42ac[_0x315b('0x11')][_0x315b('0x13')]);return _0x691786(_0x4f42ac[_0x315b('0x11')][_0x315b('0x13')]);}else{logger[_0x315b('0x14')](_0x315b('0xd'),_0x42d69d,'request\x20sent');_0x691786(_0x4f42ac[_0x315b('0x15')][_0x315b('0x13')]);}})[_0x315b('0x16')](function(_0x86c702){logger[_0x315b('0x11')]('ChatQueueReport,\x20%s,\x20%s',_0x42d69d,_0x86c702);_0x3bb45b(_0x86c702);});});}exports[_0x315b('0x17')]=function(_0xaf8aee){var _0x55383a=this;return new Promise(function(_0x41e023,_0x3712f7){return db[_0x315b('0x18')]['create'](_0xaf8aee[_0x315b('0x19')],{'raw':_0xaf8aee['options']?_0xaf8aee[_0x315b('0x1a')]['raw']===undefined?!![]:![]:!![]})[_0x315b('0xc')](function(_0x225c7e){logger[_0x315b('0x14')](_0x315b('0x17'),_0xaf8aee);logger[_0x315b('0xf')](_0x315b('0x17'),_0xaf8aee,JSON['stringify'](_0x225c7e));_0x41e023(_0x225c7e);})[_0x315b('0x16')](function(_0xdbefe5){logger[_0x315b('0x11')]('CreateChatQueueReport',_0xdbefe5[_0x315b('0x13')],_0xaf8aee);_0x3712f7(_0x55383a[_0x315b('0x11')](0x1f4,_0xdbefe5[_0x315b('0x13')]));});});};exports['UpdateChatQueueReport']=function(_0x442c91){var _0x44ac1f=this;return new Promise(function(_0x292744,_0x3a2f35){return db[_0x315b('0x18')][_0x315b('0x1b')](_0x442c91[_0x315b('0x19')],{'raw':_0x442c91[_0x315b('0x1a')]?_0x442c91[_0x315b('0x1a')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x442c91[_0x315b('0x1a')]?_0x442c91[_0x315b('0x1a')]['where']||null:null,'attributes':_0x442c91['options']?_0x442c91[_0x315b('0x1a')]['attributes']||null:null,'limit':_0x442c91['options']?_0x442c91[_0x315b('0x1a')][_0x315b('0x1c')]||null:null})['then'](function(_0x5bc223){logger[_0x315b('0x14')](_0x315b('0x1d'),_0x442c91);logger[_0x315b('0xf')]('UpdateChatQueueReport',_0x442c91,JSON[_0x315b('0x1e')](_0x5bc223));_0x292744(_0x5bc223);})[_0x315b('0x16')](function(_0x464631){logger['error'](_0x315b('0x1d'),_0x464631['message'],_0x442c91);_0x3a2f35(_0x44ac1f[_0x315b('0x11')](0x1f4,_0x464631['message']));});});};