Built motion from commit 538092ac.|2.6.10
[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 _0xbd98=['jayson/promise','client','http','request','then','info','VoiceCallReport,\x20%s,\x20%s','request\x20sent','debug','VoiceCallReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','GetVoiceCallReport','options','where','limit','include','model','attributes','map','CreateVoiceCallReport','VoiceCallReport','body','raw','UpdateVoiceCallReport','update','lodash','util','bluebird','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment'];(function(_0x5202a4,_0x506f30){var _0x42640a=function(_0x41bbc4){while(--_0x41bbc4){_0x5202a4['push'](_0x5202a4['shift']());}};_0x42640a(++_0x506f30);}(_0xbd98,0xfb));var _0x8bd9=function(_0x3648cc,_0x508da3){_0x3648cc=_0x3648cc-0x0;var _0x25d9d4=_0xbd98[_0x3648cc];return _0x25d9d4;};'use strict';var _=require(_0x8bd9('0x0'));var util=require(_0x8bd9('0x1'));var moment=require('moment');var BPromise=require(_0x8bd9('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x8bd9('0x3'));var db=require(_0x8bd9('0x4'))['db'];var utils=require(_0x8bd9('0x5'));var logger=require('../../config/logger')(_0x8bd9('0x6'));var config=require(_0x8bd9('0x7'));var jayson=require(_0x8bd9('0x8'));var client=jayson[_0x8bd9('0x9')][_0x8bd9('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x5b6dae,_0x5ccd77,_0x29d154){return new BPromise(function(_0x45c432,_0x271ca1){return client[_0x8bd9('0xb')](_0x5b6dae,_0x29d154)[_0x8bd9('0xc')](function(_0x57ed78){logger[_0x8bd9('0xd')](_0x8bd9('0xe'),_0x5ccd77,_0x8bd9('0xf'));logger[_0x8bd9('0x10')](_0x8bd9('0x11'),_0x5ccd77,_0x8bd9('0xf'),JSON[_0x8bd9('0x12')](_0x57ed78));if(_0x57ed78[_0x8bd9('0x13')]){if(_0x57ed78[_0x8bd9('0x13')][_0x8bd9('0x14')]===0x1f4){logger[_0x8bd9('0x13')](_0x8bd9('0xe'),_0x5ccd77,_0x57ed78[_0x8bd9('0x13')]['message']);return _0x271ca1(_0x57ed78[_0x8bd9('0x13')][_0x8bd9('0x15')]);}logger[_0x8bd9('0x13')](_0x8bd9('0xe'),_0x5ccd77,_0x57ed78['error'][_0x8bd9('0x15')]);return _0x45c432(_0x57ed78[_0x8bd9('0x13')][_0x8bd9('0x15')]);}else{logger[_0x8bd9('0xd')](_0x8bd9('0xe'),_0x5ccd77,_0x8bd9('0xf'));_0x45c432(_0x57ed78['result'][_0x8bd9('0x15')]);}})[_0x8bd9('0x16')](function(_0x1acfed){logger[_0x8bd9('0x13')](_0x8bd9('0xe'),_0x5ccd77,_0x1acfed);_0x271ca1(_0x1acfed);});});}exports[_0x8bd9('0x17')]=function(_0x164ee4){var _0x4d002b=this;return new Promise(function(_0x393758,_0x36da05){return db['VoiceCallReport']['findAll']({'raw':_0x164ee4[_0x8bd9('0x18')]?_0x164ee4['options']['raw']===undefined?!![]:![]:!![],'where':_0x164ee4[_0x8bd9('0x18')]?_0x164ee4['options'][_0x8bd9('0x19')]||null:null,'attributes':_0x164ee4[_0x8bd9('0x18')]?_0x164ee4[_0x8bd9('0x18')]['attributes']||null:null,'limit':_0x164ee4[_0x8bd9('0x18')]?_0x164ee4[_0x8bd9('0x18')][_0x8bd9('0x1a')]||null:null,'include':_0x164ee4[_0x8bd9('0x18')]?_0x164ee4[_0x8bd9('0x18')][_0x8bd9('0x1b')]?_['map'](_0x164ee4['options'][_0x8bd9('0x1b')],function(_0x4b6002){return{'model':db[_0x4b6002[_0x8bd9('0x1c')]],'as':_0x4b6002['as'],'attributes':_0x4b6002['attributes'],'include':_0x4b6002[_0x8bd9('0x1b')]?_['map'](_0x4b6002[_0x8bd9('0x1b')],function(_0x4fd838){return{'model':db[_0x4fd838[_0x8bd9('0x1c')]],'as':_0x4fd838['as'],'attributes':_0x4fd838[_0x8bd9('0x1d')],'include':_0x4fd838[_0x8bd9('0x1b')]?_[_0x8bd9('0x1e')](_0x4fd838[_0x8bd9('0x1b')],function(_0x41edf7){return{'model':db[_0x41edf7[_0x8bd9('0x1c')]],'as':_0x41edf7['as'],'attributes':_0x41edf7[_0x8bd9('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x8bd9('0xc')](function(_0x46767f){logger[_0x8bd9('0xd')]('GetVoiceCallReport',_0x164ee4);logger['debug'](_0x8bd9('0x17'),_0x164ee4,JSON[_0x8bd9('0x12')](_0x46767f));_0x393758(_0x46767f);})[_0x8bd9('0x16')](function(_0x2f659f){logger[_0x8bd9('0x13')]('GetVoiceCallReport',_0x2f659f['message'],_0x164ee4);_0x36da05(_0x4d002b[_0x8bd9('0x13')](0x1f4,_0x2f659f[_0x8bd9('0x15')]));});});};exports[_0x8bd9('0x1f')]=function(_0xfb489b){var _0x1a8539=this;return new Promise(function(_0x7154,_0x41c911){return db[_0x8bd9('0x20')]['create'](_0xfb489b[_0x8bd9('0x21')],{'raw':_0xfb489b[_0x8bd9('0x18')]?_0xfb489b[_0x8bd9('0x18')][_0x8bd9('0x22')]===undefined?!![]:![]:!![]})['then'](function(_0x1452af){logger[_0x8bd9('0xd')](_0x8bd9('0x1f'),_0xfb489b);logger['debug']('CreateVoiceCallReport',_0xfb489b,JSON['stringify'](_0x1452af));_0x7154(_0x1452af);})['catch'](function(_0x53262d){logger['error'](_0x8bd9('0x1f'),_0x53262d[_0x8bd9('0x15')],_0xfb489b);_0x41c911(_0x1a8539['error'](0x1f4,_0x53262d['message']));});});};exports[_0x8bd9('0x23')]=function(_0x5543b5){var _0x17ce56=this;return new Promise(function(_0x163f2d,_0x41cc72){return db[_0x8bd9('0x20')][_0x8bd9('0x24')](_0x5543b5[_0x8bd9('0x21')],{'raw':_0x5543b5[_0x8bd9('0x18')]?_0x5543b5[_0x8bd9('0x18')][_0x8bd9('0x22')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5543b5[_0x8bd9('0x18')]?_0x5543b5[_0x8bd9('0x18')][_0x8bd9('0x19')]||null:null,'attributes':_0x5543b5[_0x8bd9('0x18')]?_0x5543b5[_0x8bd9('0x18')][_0x8bd9('0x1d')]||null:null,'limit':_0x5543b5[_0x8bd9('0x18')]?_0x5543b5[_0x8bd9('0x18')][_0x8bd9('0x1a')]||null:null})[_0x8bd9('0xc')](function(_0x4afbbd){logger[_0x8bd9('0xd')](_0x8bd9('0x23'),_0x5543b5);logger[_0x8bd9('0x10')]('UpdateVoiceCallReport',_0x5543b5,JSON[_0x8bd9('0x12')](_0x4afbbd));_0x163f2d(_0x4afbbd);})[_0x8bd9('0x16')](function(_0x46b6f4){logger['error'](_0x8bd9('0x23'),_0x46b6f4['message'],_0x5543b5);_0x41cc72(_0x17ce56['error'](0x1f4,_0x46b6f4['message']));});});};