6cc3f53c00381afbae15a126de5ec5144f92a563
[motion2.git] / server / api / voiceDialReport / voiceDialReport.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 _0x076f=['result','catch','VoiceDialReport','create','body','options','raw','then','CreateVoiceDialReport','UpdateVoiceDialReport','lodash','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','http','info','VoiceDialReport,\x20%s,\x20%s','request\x20sent','debug','VoiceDialReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message'];(function(_0x42858b,_0x4eba05){var _0x731031=function(_0x57538d){while(--_0x57538d){_0x42858b['push'](_0x42858b['shift']());}};_0x731031(++_0x4eba05);}(_0x076f,0x9b));var _0xf076=function(_0xba0c2,_0x54cc50){_0xba0c2=_0xba0c2-0x0;var _0x5a9fa0=_0x076f[_0xba0c2];return _0x5a9fa0;};'use strict';var _=require(_0xf076('0x0'));var util=require('util');var moment=require(_0xf076('0x1'));var BPromise=require(_0xf076('0x2'));var rs=require(_0xf076('0x3'));var fs=require('fs');var Redis=require(_0xf076('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xf076('0x5'));var logger=require(_0xf076('0x6'))(_0xf076('0x7'));var config=require(_0xf076('0x8'));var jayson=require('jayson/promise');var client=jayson['client'][_0xf076('0x9')]({'port':0x232a});function respondWithRpcPromise(_0xb66978,_0x439efc,_0x224cf5){return new BPromise(function(_0x3e61ab,_0x1910bb){return client['request'](_0xb66978,_0x224cf5)['then'](function(_0x40d946){logger[_0xf076('0xa')](_0xf076('0xb'),_0x439efc,_0xf076('0xc'));logger[_0xf076('0xd')](_0xf076('0xe'),_0x439efc,'request\x20sent',JSON[_0xf076('0xf')](_0x40d946));if(_0x40d946[_0xf076('0x10')]){if(_0x40d946['error'][_0xf076('0x11')]===0x1f4){logger[_0xf076('0x10')](_0xf076('0xb'),_0x439efc,_0x40d946[_0xf076('0x10')]['message']);return _0x1910bb(_0x40d946[_0xf076('0x10')][_0xf076('0x12')]);}logger[_0xf076('0x10')](_0xf076('0xb'),_0x439efc,_0x40d946['error'][_0xf076('0x12')]);return _0x3e61ab(_0x40d946['error'][_0xf076('0x12')]);}else{logger['info']('VoiceDialReport,\x20%s,\x20%s',_0x439efc,'request\x20sent');_0x3e61ab(_0x40d946[_0xf076('0x13')][_0xf076('0x12')]);}})[_0xf076('0x14')](function(_0x525cdc){logger['error'](_0xf076('0xb'),_0x439efc,_0x525cdc);_0x1910bb(_0x525cdc);});});}exports['CreateVoiceDialReport']=function(_0x58d655){var _0x1bd4f2=this;return new Promise(function(_0x78cf99,_0x186b4d){return db[_0xf076('0x15')][_0xf076('0x16')](_0x58d655[_0xf076('0x17')],{'raw':_0x58d655[_0xf076('0x18')]?_0x58d655[_0xf076('0x18')][_0xf076('0x19')]===undefined?!![]:![]:!![]})[_0xf076('0x1a')](function(_0xabe8f9){logger[_0xf076('0xa')](_0xf076('0x1b'),_0x58d655);logger[_0xf076('0xd')]('CreateVoiceDialReport',_0x58d655,JSON[_0xf076('0xf')](_0xabe8f9));_0x78cf99(_0xabe8f9);})[_0xf076('0x14')](function(_0x534bc4){logger[_0xf076('0x10')]('CreateVoiceDialReport',_0x534bc4[_0xf076('0x12')],_0x58d655);_0x186b4d(_0x1bd4f2[_0xf076('0x10')](0x1f4,_0x534bc4[_0xf076('0x12')]));});});};exports[_0xf076('0x1c')]=function(_0x1623c9){var _0x265fa0=this;return new Promise(function(_0x171ff2,_0x1b93f8){return db[_0xf076('0x15')]['update'](_0x1623c9[_0xf076('0x17')],{'raw':_0x1623c9['options']?_0x1623c9[_0xf076('0x18')][_0xf076('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1623c9[_0xf076('0x18')]?_0x1623c9['options']['where']||null:null,'attributes':_0x1623c9[_0xf076('0x18')]?_0x1623c9['options']['attributes']||null:null,'limit':_0x1623c9['options']?_0x1623c9[_0xf076('0x18')]['limit']||null:null})[_0xf076('0x1a')](function(_0x18092a){logger[_0xf076('0xa')]('UpdateVoiceDialReport',_0x1623c9);logger[_0xf076('0xd')](_0xf076('0x1c'),_0x1623c9,JSON[_0xf076('0xf')](_0x18092a));_0x171ff2(_0x18092a);})[_0xf076('0x14')](function(_0x190b4e){logger[_0xf076('0x10')](_0xf076('0x1c'),_0x190b4e[_0xf076('0x12')],_0x1623c9);_0x1b93f8(_0x265fa0[_0xf076('0x10')](0x1f4,_0x190b4e['message']));});});};