bcb50858bf9a8158aaf85cbba3d90619cd7a6b4e
[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 _0x4a68=['../../config/environment','http','request','info','VoiceDialReport,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','VoiceDialReport,\x20%s,\x20%s','message','result','catch','CreateVoiceDialReport','create','body','options','raw','then','debug','VoiceDialReport','update','where','attributes','limit','UpdateVoiceDialReport','util','moment','bluebird','randomstring','ioredis','../../config/logger'];(function(_0x2a3dda,_0x24416a){var _0x169117=function(_0x3b35ee){while(--_0x3b35ee){_0x2a3dda['push'](_0x2a3dda['shift']());}};_0x169117(++_0x24416a);}(_0x4a68,0xb4));var _0x84a6=function(_0x18e77d,_0x3ee711){_0x18e77d=_0x18e77d-0x0;var _0x513b54=_0x4a68[_0x18e77d];return _0x513b54;};'use strict';var _=require('lodash');var util=require(_0x84a6('0x0'));var moment=require(_0x84a6('0x1'));var BPromise=require(_0x84a6('0x2'));var rs=require(_0x84a6('0x3'));var fs=require('fs');var Redis=require(_0x84a6('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x84a6('0x5'))('rpc');var config=require(_0x84a6('0x6'));var jayson=require('jayson/promise');var client=jayson['client'][_0x84a6('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x388e94,_0x31e21b,_0x5b4f71){return new BPromise(function(_0x17b84a,_0x952540){return client[_0x84a6('0x8')](_0x388e94,_0x5b4f71)['then'](function(_0xc5992f){logger[_0x84a6('0x9')]('VoiceDialReport,\x20%s,\x20%s',_0x31e21b,'request\x20sent');logger['debug'](_0x84a6('0xa'),_0x31e21b,_0x84a6('0xb'),JSON[_0x84a6('0xc')](_0xc5992f));if(_0xc5992f[_0x84a6('0xd')]){if(_0xc5992f['error']['code']===0x1f4){logger[_0x84a6('0xd')](_0x84a6('0xe'),_0x31e21b,_0xc5992f[_0x84a6('0xd')][_0x84a6('0xf')]);return _0x952540(_0xc5992f[_0x84a6('0xd')][_0x84a6('0xf')]);}logger[_0x84a6('0xd')](_0x84a6('0xe'),_0x31e21b,_0xc5992f['error']['message']);return _0x17b84a(_0xc5992f[_0x84a6('0xd')][_0x84a6('0xf')]);}else{logger[_0x84a6('0x9')]('VoiceDialReport,\x20%s,\x20%s',_0x31e21b,'request\x20sent');_0x17b84a(_0xc5992f[_0x84a6('0x10')][_0x84a6('0xf')]);}})[_0x84a6('0x11')](function(_0x38d16e){logger[_0x84a6('0xd')](_0x84a6('0xe'),_0x31e21b,_0x38d16e);_0x952540(_0x38d16e);});});}exports[_0x84a6('0x12')]=function(_0x1effdc){var _0xc1e0a6=this;return new Promise(function(_0x2f4221,_0x4369ed){return db['VoiceDialReport'][_0x84a6('0x13')](_0x1effdc[_0x84a6('0x14')],{'raw':_0x1effdc['options']?_0x1effdc[_0x84a6('0x15')][_0x84a6('0x16')]===undefined?!![]:![]:!![]})[_0x84a6('0x17')](function(_0x15ba29){logger['info'](_0x84a6('0x12'),_0x1effdc);logger[_0x84a6('0x18')](_0x84a6('0x12'),_0x1effdc,JSON['stringify'](_0x15ba29));_0x2f4221(_0x15ba29);})[_0x84a6('0x11')](function(_0x2fb6d9){logger['error'](_0x84a6('0x12'),_0x2fb6d9['message'],_0x1effdc);_0x4369ed(_0xc1e0a6[_0x84a6('0xd')](0x1f4,_0x2fb6d9[_0x84a6('0xf')]));});});};exports['UpdateVoiceDialReport']=function(_0x12e614){var _0x141d2e=this;return new Promise(function(_0x1a4165,_0x11b33c){return db[_0x84a6('0x19')][_0x84a6('0x1a')](_0x12e614[_0x84a6('0x14')],{'raw':_0x12e614[_0x84a6('0x15')]?_0x12e614['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x12e614[_0x84a6('0x15')]?_0x12e614['options'][_0x84a6('0x1b')]||null:null,'attributes':_0x12e614['options']?_0x12e614[_0x84a6('0x15')][_0x84a6('0x1c')]||null:null,'limit':_0x12e614[_0x84a6('0x15')]?_0x12e614[_0x84a6('0x15')][_0x84a6('0x1d')]||null:null})[_0x84a6('0x17')](function(_0x210c03){logger[_0x84a6('0x9')](_0x84a6('0x1e'),_0x12e614);logger[_0x84a6('0x18')](_0x84a6('0x1e'),_0x12e614,JSON['stringify'](_0x210c03));_0x1a4165(_0x210c03);})[_0x84a6('0x11')](function(_0x4e2ac6){logger['error'](_0x84a6('0x1e'),_0x4e2ac6[_0x84a6('0xf')],_0x12e614);_0x11b33c(_0x141d2e[_0x84a6('0xd')](0x1f4,_0x4e2ac6['message']));});});};