22d848e56ad55e7c2c4f20f39136fe364f4e297d
[motion2.git] / server / api / openchannelQueueReport / openchannelQueueReport.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 _0xcd2f=['bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','then','info','request\x20sent','debug','OpenchannelQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','message','OpenchannelQueueReport,\x20%s,\x20%s','result','catch','OpenchannelQueueReport','create','body','options','raw','CreateOpenchannelQueueReport','update','where','UpdateOpenchannelQueueReport'];(function(_0x382500,_0x43e04e){var _0x4aa842=function(_0x22c871){while(--_0x22c871){_0x382500['push'](_0x382500['shift']());}};_0x4aa842(++_0x43e04e);}(_0xcd2f,0xf8));var _0xfcd2=function(_0x3ab9ee,_0x4a74b8){_0x3ab9ee=_0x3ab9ee-0x0;var _0x82ee88=_0xcd2f[_0x3ab9ee];return _0x82ee88;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0xfcd2('0x0'));var rs=require(_0xfcd2('0x1'));var fs=require('fs');var Redis=require(_0xfcd2('0x2'));var db=require(_0xfcd2('0x3'))['db'];var utils=require(_0xfcd2('0x4'));var logger=require(_0xfcd2('0x5'))(_0xfcd2('0x6'));var config=require(_0xfcd2('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xfcd2('0x8')][_0xfcd2('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x41e836,_0x20ac59,_0x467e4f){return new BPromise(function(_0x13d9fa,_0xae2219){return client[_0xfcd2('0xa')](_0x41e836,_0x467e4f)[_0xfcd2('0xb')](function(_0x358fb4){logger[_0xfcd2('0xc')]('OpenchannelQueueReport,\x20%s,\x20%s',_0x20ac59,_0xfcd2('0xd'));logger[_0xfcd2('0xe')](_0xfcd2('0xf'),_0x20ac59,_0xfcd2('0xd'),JSON[_0xfcd2('0x10')](_0x358fb4));if(_0x358fb4['error']){if(_0x358fb4['error']['code']===0x1f4){logger['error']('OpenchannelQueueReport,\x20%s,\x20%s',_0x20ac59,_0x358fb4[_0xfcd2('0x11')][_0xfcd2('0x12')]);return _0xae2219(_0x358fb4['error'][_0xfcd2('0x12')]);}logger[_0xfcd2('0x11')]('OpenchannelQueueReport,\x20%s,\x20%s',_0x20ac59,_0x358fb4['error'][_0xfcd2('0x12')]);return _0x13d9fa(_0x358fb4[_0xfcd2('0x11')][_0xfcd2('0x12')]);}else{logger[_0xfcd2('0xc')](_0xfcd2('0x13'),_0x20ac59,'request\x20sent');_0x13d9fa(_0x358fb4[_0xfcd2('0x14')][_0xfcd2('0x12')]);}})[_0xfcd2('0x15')](function(_0x34aa38){logger[_0xfcd2('0x11')](_0xfcd2('0x13'),_0x20ac59,_0x34aa38);_0xae2219(_0x34aa38);});});}exports['CreateOpenchannelQueueReport']=function(_0xba3186){var _0x268e00=this;return new Promise(function(_0x32607c,_0x2c4b8f){return db[_0xfcd2('0x16')][_0xfcd2('0x17')](_0xba3186[_0xfcd2('0x18')],{'raw':_0xba3186[_0xfcd2('0x19')]?_0xba3186[_0xfcd2('0x19')][_0xfcd2('0x1a')]===undefined?!![]:![]:!![]})[_0xfcd2('0xb')](function(_0x266c86){logger['info'](_0xfcd2('0x1b'),_0xba3186);logger[_0xfcd2('0xe')](_0xfcd2('0x1b'),_0xba3186,JSON[_0xfcd2('0x10')](_0x266c86));_0x32607c(_0x266c86);})[_0xfcd2('0x15')](function(_0x37dafa){logger[_0xfcd2('0x11')](_0xfcd2('0x1b'),_0x37dafa[_0xfcd2('0x12')],_0xba3186);_0x2c4b8f(_0x268e00['error'](0x1f4,_0x37dafa[_0xfcd2('0x12')]));});});};exports['UpdateOpenchannelQueueReport']=function(_0xedae7a){var _0x9baa91=this;return new Promise(function(_0x4f220e,_0x567436){return db[_0xfcd2('0x16')][_0xfcd2('0x1c')](_0xedae7a[_0xfcd2('0x18')],{'raw':_0xedae7a[_0xfcd2('0x19')]?_0xedae7a['options'][_0xfcd2('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xedae7a[_0xfcd2('0x19')]?_0xedae7a[_0xfcd2('0x19')][_0xfcd2('0x1d')]||null:null,'attributes':_0xedae7a['options']?_0xedae7a[_0xfcd2('0x19')]['attributes']||null:null,'limit':_0xedae7a[_0xfcd2('0x19')]?_0xedae7a[_0xfcd2('0x19')]['limit']||null:null})[_0xfcd2('0xb')](function(_0x3cb642){logger[_0xfcd2('0xc')]('UpdateOpenchannelQueueReport',_0xedae7a);logger[_0xfcd2('0xe')](_0xfcd2('0x1e'),_0xedae7a,JSON[_0xfcd2('0x10')](_0x3cb642));_0x4f220e(_0x3cb642);})['catch'](function(_0x490c53){logger['error'](_0xfcd2('0x1e'),_0x490c53[_0xfcd2('0x12')],_0xedae7a);_0x567436(_0x9baa91[_0xfcd2('0x11')](0x1f4,_0x490c53['message']));});});};