462515eeef271973f29b5285382edda67d6e0121
[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 _0x2f49=['util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','http','info','request\x20sent','debug','VoiceDialReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','VoiceDialReport,\x20%s,\x20%s','catch','create','body','options','raw','CreateVoiceDialReport','UpdateVoiceDialReport','VoiceDialReport','where','then','lodash'];(function(_0x542bf2,_0x4e369e){var _0x18dea4=function(_0x388fdb){while(--_0x388fdb){_0x542bf2['push'](_0x542bf2['shift']());}};_0x18dea4(++_0x4e369e);}(_0x2f49,0x10d));var _0x92f4=function(_0x246e88,_0x2fd69e){_0x246e88=_0x246e88-0x0;var _0x147a79=_0x2f49[_0x246e88];return _0x147a79;};'use strict';var _=require(_0x92f4('0x0'));var util=require(_0x92f4('0x1'));var moment=require(_0x92f4('0x2'));var BPromise=require(_0x92f4('0x3'));var rs=require(_0x92f4('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x92f4('0x5'))['db'];var utils=require(_0x92f4('0x6'));var logger=require(_0x92f4('0x7'))('rpc');var config=require(_0x92f4('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x92f4('0x9')][_0x92f4('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x4a253c,_0x306de3,_0x55de5e){return new BPromise(function(_0xf577ad,_0x5d8b98){return client['request'](_0x4a253c,_0x55de5e)['then'](function(_0xfc243f){logger[_0x92f4('0xb')]('VoiceDialReport,\x20%s,\x20%s',_0x306de3,_0x92f4('0xc'));logger[_0x92f4('0xd')](_0x92f4('0xe'),_0x306de3,_0x92f4('0xc'),JSON[_0x92f4('0xf')](_0xfc243f));if(_0xfc243f[_0x92f4('0x10')]){if(_0xfc243f[_0x92f4('0x10')][_0x92f4('0x11')]===0x1f4){logger[_0x92f4('0x10')]('VoiceDialReport,\x20%s,\x20%s',_0x306de3,_0xfc243f['error'][_0x92f4('0x12')]);return _0x5d8b98(_0xfc243f[_0x92f4('0x10')][_0x92f4('0x12')]);}logger['error'](_0x92f4('0x13'),_0x306de3,_0xfc243f[_0x92f4('0x10')][_0x92f4('0x12')]);return _0xf577ad(_0xfc243f['error'][_0x92f4('0x12')]);}else{logger[_0x92f4('0xb')](_0x92f4('0x13'),_0x306de3,_0x92f4('0xc'));_0xf577ad(_0xfc243f['result']['message']);}})[_0x92f4('0x14')](function(_0x10c809){logger['error'](_0x92f4('0x13'),_0x306de3,_0x10c809);_0x5d8b98(_0x10c809);});});}exports['CreateVoiceDialReport']=function(_0x207c69){var _0x3ffb1f=this;return new Promise(function(_0x417604,_0x81fd9){return db['VoiceDialReport'][_0x92f4('0x15')](_0x207c69[_0x92f4('0x16')],{'raw':_0x207c69[_0x92f4('0x17')]?_0x207c69[_0x92f4('0x17')][_0x92f4('0x18')]===undefined?!![]:![]:!![]})['then'](function(_0x433ff5){logger[_0x92f4('0xb')](_0x92f4('0x19'),_0x207c69);logger[_0x92f4('0xd')](_0x92f4('0x19'),_0x207c69,JSON[_0x92f4('0xf')](_0x433ff5));_0x417604(_0x433ff5);})[_0x92f4('0x14')](function(_0x21963b){logger[_0x92f4('0x10')]('CreateVoiceDialReport',_0x21963b[_0x92f4('0x12')],_0x207c69);_0x81fd9(_0x3ffb1f['error'](0x1f4,_0x21963b[_0x92f4('0x12')]));});});};exports[_0x92f4('0x1a')]=function(_0x3feee0){var _0x3693ac=this;return new Promise(function(_0x442118,_0x4869e9){return db[_0x92f4('0x1b')]['update'](_0x3feee0['body'],{'raw':_0x3feee0[_0x92f4('0x17')]?_0x3feee0[_0x92f4('0x17')][_0x92f4('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3feee0['options']?_0x3feee0[_0x92f4('0x17')][_0x92f4('0x1c')]||null:null,'attributes':_0x3feee0['options']?_0x3feee0[_0x92f4('0x17')]['attributes']||null:null,'limit':_0x3feee0['options']?_0x3feee0[_0x92f4('0x17')]['limit']||null:null})[_0x92f4('0x1d')](function(_0x2eed9c){logger[_0x92f4('0xb')]('UpdateVoiceDialReport',_0x3feee0);logger['debug'](_0x92f4('0x1a'),_0x3feee0,JSON[_0x92f4('0xf')](_0x2eed9c));_0x442118(_0x2eed9c);})['catch'](function(_0x5f09b7){logger[_0x92f4('0x10')](_0x92f4('0x1a'),_0x5f09b7[_0x92f4('0x12')],_0x3feee0);_0x4869e9(_0x3693ac[_0x92f4('0x10')](0x1f4,_0x5f09b7[_0x92f4('0x12')]));});});};