191740bd02a9f143ff82be646457e9c574b0a2c7
[motion2.git] / server / api / voiceCallReport / voiceCallReport.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 _0xf3f9=['../../config/utils','rpc','../../config/environment','client','http','request','VoiceCallReport,\x20%s,\x20%s','request\x20sent','debug','error','code','message','catch','GetVoiceCallReport','VoiceCallReport','findAll','options','raw','attributes','limit','include','map','model','then','info','CreateVoiceCallReport','create','body','UpdateVoiceCallReport','update','where','stringify','lodash','util','moment','randomstring','ioredis','../../mysqldb'];(function(_0x496688,_0x2236bf){var _0x3caf1d=function(_0x3b9d76){while(--_0x3b9d76){_0x496688['push'](_0x496688['shift']());}};_0x3caf1d(++_0x2236bf);}(_0xf3f9,0xb8));var _0x9f3f=function(_0x28a0c4,_0x1ddea7){_0x28a0c4=_0x28a0c4-0x0;var _0x6c8fc0=_0xf3f9[_0x28a0c4];return _0x6c8fc0;};'use strict';var _=require(_0x9f3f('0x0'));var util=require(_0x9f3f('0x1'));var moment=require(_0x9f3f('0x2'));var BPromise=require('bluebird');var rs=require(_0x9f3f('0x3'));var fs=require('fs');var Redis=require(_0x9f3f('0x4'));var db=require(_0x9f3f('0x5'))['db'];var utils=require(_0x9f3f('0x6'));var logger=require('../../config/logger')(_0x9f3f('0x7'));var config=require(_0x9f3f('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x9f3f('0x9')][_0x9f3f('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x110018,_0x5c80f8,_0x69df71){return new BPromise(function(_0x10cbfb,_0xcf859c){return client[_0x9f3f('0xb')](_0x110018,_0x69df71)['then'](function(_0x7e5fc2){logger['info'](_0x9f3f('0xc'),_0x5c80f8,_0x9f3f('0xd'));logger[_0x9f3f('0xe')]('VoiceCallReport,\x20%s,\x20%s,\x20%s',_0x5c80f8,'request\x20sent',JSON['stringify'](_0x7e5fc2));if(_0x7e5fc2[_0x9f3f('0xf')]){if(_0x7e5fc2[_0x9f3f('0xf')][_0x9f3f('0x10')]===0x1f4){logger[_0x9f3f('0xf')]('VoiceCallReport,\x20%s,\x20%s',_0x5c80f8,_0x7e5fc2['error']['message']);return _0xcf859c(_0x7e5fc2[_0x9f3f('0xf')][_0x9f3f('0x11')]);}logger[_0x9f3f('0xf')](_0x9f3f('0xc'),_0x5c80f8,_0x7e5fc2[_0x9f3f('0xf')][_0x9f3f('0x11')]);return _0x10cbfb(_0x7e5fc2['error']['message']);}else{logger['info'](_0x9f3f('0xc'),_0x5c80f8,'request\x20sent');_0x10cbfb(_0x7e5fc2['result'][_0x9f3f('0x11')]);}})[_0x9f3f('0x12')](function(_0x52b4db){logger['error'](_0x9f3f('0xc'),_0x5c80f8,_0x52b4db);_0xcf859c(_0x52b4db);});});}exports[_0x9f3f('0x13')]=function(_0x3afba7){var _0x19620c=this;return new Promise(function(_0x25d65b,_0x13d6f6){return db[_0x9f3f('0x14')][_0x9f3f('0x15')]({'raw':_0x3afba7[_0x9f3f('0x16')]?_0x3afba7[_0x9f3f('0x16')][_0x9f3f('0x17')]===undefined?!![]:![]:!![],'where':_0x3afba7[_0x9f3f('0x16')]?_0x3afba7[_0x9f3f('0x16')]['where']||null:null,'attributes':_0x3afba7['options']?_0x3afba7[_0x9f3f('0x16')][_0x9f3f('0x18')]||null:null,'limit':_0x3afba7[_0x9f3f('0x16')]?_0x3afba7[_0x9f3f('0x16')][_0x9f3f('0x19')]||null:null,'include':_0x3afba7['options']?_0x3afba7[_0x9f3f('0x16')][_0x9f3f('0x1a')]?_[_0x9f3f('0x1b')](_0x3afba7[_0x9f3f('0x16')][_0x9f3f('0x1a')],function(_0x404d47){return{'model':db[_0x404d47['model']],'as':_0x404d47['as'],'attributes':_0x404d47[_0x9f3f('0x18')],'include':_0x404d47['include']?_[_0x9f3f('0x1b')](_0x404d47[_0x9f3f('0x1a')],function(_0x59bf6f){return{'model':db[_0x59bf6f['model']],'as':_0x59bf6f['as'],'attributes':_0x59bf6f['attributes'],'include':_0x59bf6f[_0x9f3f('0x1a')]?_[_0x9f3f('0x1b')](_0x59bf6f[_0x9f3f('0x1a')],function(_0x38def2){return{'model':db[_0x38def2[_0x9f3f('0x1c')]],'as':_0x38def2['as'],'attributes':_0x38def2['attributes']};}):[]};}):[]};}):[]:[]})[_0x9f3f('0x1d')](function(_0x5ed5d0){logger[_0x9f3f('0x1e')](_0x9f3f('0x13'),_0x3afba7);logger[_0x9f3f('0xe')]('GetVoiceCallReport',_0x3afba7,JSON['stringify'](_0x5ed5d0));_0x25d65b(_0x5ed5d0);})[_0x9f3f('0x12')](function(_0x24b3e7){logger[_0x9f3f('0xf')](_0x9f3f('0x13'),_0x24b3e7[_0x9f3f('0x11')],_0x3afba7);_0x13d6f6(_0x19620c[_0x9f3f('0xf')](0x1f4,_0x24b3e7[_0x9f3f('0x11')]));});});};exports[_0x9f3f('0x1f')]=function(_0x87b7a0){var _0x5e30fe=this;return new Promise(function(_0x2d430a,_0x2c42e1){return db[_0x9f3f('0x14')][_0x9f3f('0x20')](_0x87b7a0[_0x9f3f('0x21')],{'raw':_0x87b7a0[_0x9f3f('0x16')]?_0x87b7a0[_0x9f3f('0x16')]['raw']===undefined?!![]:![]:!![]})[_0x9f3f('0x1d')](function(_0x4c8208){logger['info']('CreateVoiceCallReport',_0x87b7a0);logger[_0x9f3f('0xe')](_0x9f3f('0x1f'),_0x87b7a0,JSON['stringify'](_0x4c8208));_0x2d430a(_0x4c8208);})[_0x9f3f('0x12')](function(_0x26d103){logger[_0x9f3f('0xf')](_0x9f3f('0x1f'),_0x26d103[_0x9f3f('0x11')],_0x87b7a0);_0x2c42e1(_0x5e30fe[_0x9f3f('0xf')](0x1f4,_0x26d103['message']));});});};exports[_0x9f3f('0x22')]=function(_0x3101ae){var _0x1b8232=this;return new Promise(function(_0x5618fa,_0x33ee06){return db[_0x9f3f('0x14')][_0x9f3f('0x23')](_0x3101ae['body'],{'raw':_0x3101ae[_0x9f3f('0x16')]?_0x3101ae['options'][_0x9f3f('0x17')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3101ae[_0x9f3f('0x16')]?_0x3101ae[_0x9f3f('0x16')][_0x9f3f('0x24')]||null:null,'attributes':_0x3101ae['options']?_0x3101ae['options'][_0x9f3f('0x18')]||null:null,'limit':_0x3101ae['options']?_0x3101ae['options'][_0x9f3f('0x19')]||null:null})[_0x9f3f('0x1d')](function(_0x4a946b){logger['info'](_0x9f3f('0x22'),_0x3101ae);logger[_0x9f3f('0xe')]('UpdateVoiceCallReport',_0x3101ae,JSON[_0x9f3f('0x25')](_0x4a946b));_0x5618fa(_0x4a946b);})['catch'](function(_0x18ea4d){logger[_0x9f3f('0xf')](_0x9f3f('0x22'),_0x18ea4d['message'],_0x3101ae);_0x33ee06(_0x1b8232[_0x9f3f('0xf')](0x1f4,_0x18ea4d[_0x9f3f('0x11')]));});});};