8cc009229330249400fbea104550c132d99b963f
[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 _0x69ea=['create','body','update','where','UpdateVoiceCallReport','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/logger','rpc','jayson/promise','client','http','request','then','VoiceCallReport,\x20%s,\x20%s','request\x20sent','debug','VoiceCallReport,\x20%s,\x20%s,\x20%s','code','message','error','info','VoiceCallReport','findAll','options','raw','attributes','limit','include','map','model','GetVoiceCallReport','stringify','catch','CreateVoiceCallReport'];(function(_0x1ba024,_0x56ea6b){var _0x107d32=function(_0x4bcc21){while(--_0x4bcc21){_0x1ba024['push'](_0x1ba024['shift']());}};_0x107d32(++_0x56ea6b);}(_0x69ea,0x10f));var _0xa69e=function(_0x2c91e9,_0x2fb965){_0x2c91e9=_0x2c91e9-0x0;var _0x13f0ff=_0x69ea[_0x2c91e9];return _0x13f0ff;};'use strict';var _=require(_0xa69e('0x0'));var util=require('util');var moment=require(_0xa69e('0x1'));var BPromise=require(_0xa69e('0x2'));var rs=require(_0xa69e('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xa69e('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xa69e('0x5'))(_0xa69e('0x6'));var config=require('../../config/environment');var jayson=require(_0xa69e('0x7'));var client=jayson[_0xa69e('0x8')][_0xa69e('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x61a9f7,_0x26ef6d,_0x34b967){return new BPromise(function(_0x3e5310,_0x1c75eb){return client[_0xa69e('0xa')](_0x61a9f7,_0x34b967)[_0xa69e('0xb')](function(_0x462e9f){logger['info'](_0xa69e('0xc'),_0x26ef6d,_0xa69e('0xd'));logger[_0xa69e('0xe')](_0xa69e('0xf'),_0x26ef6d,_0xa69e('0xd'),JSON['stringify'](_0x462e9f));if(_0x462e9f['error']){if(_0x462e9f['error'][_0xa69e('0x10')]===0x1f4){logger['error'](_0xa69e('0xc'),_0x26ef6d,_0x462e9f['error'][_0xa69e('0x11')]);return _0x1c75eb(_0x462e9f[_0xa69e('0x12')][_0xa69e('0x11')]);}logger[_0xa69e('0x12')]('VoiceCallReport,\x20%s,\x20%s',_0x26ef6d,_0x462e9f['error'][_0xa69e('0x11')]);return _0x3e5310(_0x462e9f[_0xa69e('0x12')]['message']);}else{logger[_0xa69e('0x13')](_0xa69e('0xc'),_0x26ef6d,_0xa69e('0xd'));_0x3e5310(_0x462e9f['result'][_0xa69e('0x11')]);}})['catch'](function(_0x33b2ef){logger[_0xa69e('0x12')](_0xa69e('0xc'),_0x26ef6d,_0x33b2ef);_0x1c75eb(_0x33b2ef);});});}exports['GetVoiceCallReport']=function(_0x5eb7fb){var _0x5b1b76=this;return new Promise(function(_0x1e01b2,_0x1e9512){return db[_0xa69e('0x14')][_0xa69e('0x15')]({'raw':_0x5eb7fb[_0xa69e('0x16')]?_0x5eb7fb[_0xa69e('0x16')][_0xa69e('0x17')]===undefined?!![]:![]:!![],'where':_0x5eb7fb[_0xa69e('0x16')]?_0x5eb7fb['options']['where']||null:null,'attributes':_0x5eb7fb['options']?_0x5eb7fb[_0xa69e('0x16')][_0xa69e('0x18')]||null:null,'limit':_0x5eb7fb[_0xa69e('0x16')]?_0x5eb7fb[_0xa69e('0x16')][_0xa69e('0x19')]||null:null,'include':_0x5eb7fb[_0xa69e('0x16')]?_0x5eb7fb[_0xa69e('0x16')][_0xa69e('0x1a')]?_[_0xa69e('0x1b')](_0x5eb7fb[_0xa69e('0x16')][_0xa69e('0x1a')],function(_0x7cc4b8){return{'model':db[_0x7cc4b8['model']],'as':_0x7cc4b8['as'],'attributes':_0x7cc4b8[_0xa69e('0x18')],'include':_0x7cc4b8['include']?_[_0xa69e('0x1b')](_0x7cc4b8[_0xa69e('0x1a')],function(_0x6c4a42){return{'model':db[_0x6c4a42[_0xa69e('0x1c')]],'as':_0x6c4a42['as'],'attributes':_0x6c4a42[_0xa69e('0x18')],'include':_0x6c4a42['include']?_[_0xa69e('0x1b')](_0x6c4a42[_0xa69e('0x1a')],function(_0x2262b0){return{'model':db[_0x2262b0[_0xa69e('0x1c')]],'as':_0x2262b0['as'],'attributes':_0x2262b0[_0xa69e('0x18')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x3df074){logger[_0xa69e('0x13')]('GetVoiceCallReport',_0x5eb7fb);logger[_0xa69e('0xe')](_0xa69e('0x1d'),_0x5eb7fb,JSON[_0xa69e('0x1e')](_0x3df074));_0x1e01b2(_0x3df074);})[_0xa69e('0x1f')](function(_0x69bb5c){logger[_0xa69e('0x12')](_0xa69e('0x1d'),_0x69bb5c[_0xa69e('0x11')],_0x5eb7fb);_0x1e9512(_0x5b1b76['error'](0x1f4,_0x69bb5c[_0xa69e('0x11')]));});});};exports[_0xa69e('0x20')]=function(_0x302a98){var _0x38f6b9=this;return new Promise(function(_0x15fa3d,_0x4cf9f7){return db[_0xa69e('0x14')][_0xa69e('0x21')](_0x302a98[_0xa69e('0x22')],{'raw':_0x302a98[_0xa69e('0x16')]?_0x302a98[_0xa69e('0x16')][_0xa69e('0x17')]===undefined?!![]:![]:!![]})[_0xa69e('0xb')](function(_0x23a851){logger[_0xa69e('0x13')]('CreateVoiceCallReport',_0x302a98);logger['debug'](_0xa69e('0x20'),_0x302a98,JSON[_0xa69e('0x1e')](_0x23a851));_0x15fa3d(_0x23a851);})['catch'](function(_0x24582e){logger[_0xa69e('0x12')](_0xa69e('0x20'),_0x24582e['message'],_0x302a98);_0x4cf9f7(_0x38f6b9[_0xa69e('0x12')](0x1f4,_0x24582e[_0xa69e('0x11')]));});});};exports['UpdateVoiceCallReport']=function(_0x5995c3){var _0x41b703=this;return new Promise(function(_0x3770be,_0x3b5405){return db[_0xa69e('0x14')][_0xa69e('0x23')](_0x5995c3[_0xa69e('0x22')],{'raw':_0x5995c3['options']?_0x5995c3[_0xa69e('0x16')][_0xa69e('0x17')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5995c3[_0xa69e('0x16')]?_0x5995c3[_0xa69e('0x16')][_0xa69e('0x24')]||null:null,'attributes':_0x5995c3[_0xa69e('0x16')]?_0x5995c3['options']['attributes']||null:null,'limit':_0x5995c3['options']?_0x5995c3[_0xa69e('0x16')][_0xa69e('0x19')]||null:null})[_0xa69e('0xb')](function(_0x2f9579){logger['info']('UpdateVoiceCallReport',_0x5995c3);logger['debug']('UpdateVoiceCallReport',_0x5995c3,JSON[_0xa69e('0x1e')](_0x2f9579));_0x3770be(_0x2f9579);})[_0xa69e('0x1f')](function(_0xc40f35){logger['error'](_0xa69e('0x25'),_0xc40f35[_0xa69e('0x11')],_0x5995c3);_0x3b5405(_0x41b703['error'](0x1f4,_0xc40f35[_0xa69e('0x11')]));});});};