Built motion from commit c0cdc9d8.|2.6.28
[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 _0x847b=['findAll','options','raw','where','attributes','limit','map','include','model','GetVoiceCallReport','create','CreateVoiceCallReport','UpdateVoiceCallReport','update','lodash','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','VoiceCallReport,\x20%s,\x20%s','request\x20sent','debug','VoiceCallReport,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','VoiceCallReport'];(function(_0x26b729,_0x5a770c){var _0x5e5ea5=function(_0x4ef74e){while(--_0x4ef74e){_0x26b729['push'](_0x26b729['shift']());}};_0x5e5ea5(++_0x5a770c);}(_0x847b,0xf2));var _0xb847=function(_0x397e5f,_0x454c8f){_0x397e5f=_0x397e5f-0x0;var _0x5302b8=_0x847b[_0x397e5f];return _0x5302b8;};'use strict';var _=require(_0xb847('0x0'));var util=require('util');var moment=require(_0xb847('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb847('0x2'));var db=require(_0xb847('0x3'))['db'];var utils=require(_0xb847('0x4'));var logger=require(_0xb847('0x5'))(_0xb847('0x6'));var config=require(_0xb847('0x7'));var jayson=require(_0xb847('0x8'));var client=jayson[_0xb847('0x9')][_0xb847('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x498e33,_0x1225ee,_0x1da7c8){return new BPromise(function(_0x46274d,_0x233ef1){return client[_0xb847('0xb')](_0x498e33,_0x1da7c8)[_0xb847('0xc')](function(_0x4ab21d){logger[_0xb847('0xd')](_0xb847('0xe'),_0x1225ee,_0xb847('0xf'));logger[_0xb847('0x10')](_0xb847('0x11'),_0x1225ee,_0xb847('0xf'),JSON[_0xb847('0x12')](_0x4ab21d));if(_0x4ab21d['error']){if(_0x4ab21d['error']['code']===0x1f4){logger[_0xb847('0x13')]('VoiceCallReport,\x20%s,\x20%s',_0x1225ee,_0x4ab21d[_0xb847('0x13')][_0xb847('0x14')]);return _0x233ef1(_0x4ab21d[_0xb847('0x13')][_0xb847('0x14')]);}logger[_0xb847('0x13')](_0xb847('0xe'),_0x1225ee,_0x4ab21d['error'][_0xb847('0x14')]);return _0x46274d(_0x4ab21d[_0xb847('0x13')][_0xb847('0x14')]);}else{logger['info'](_0xb847('0xe'),_0x1225ee,_0xb847('0xf'));_0x46274d(_0x4ab21d[_0xb847('0x15')]['message']);}})[_0xb847('0x16')](function(_0x25b8b5){logger['error'](_0xb847('0xe'),_0x1225ee,_0x25b8b5);_0x233ef1(_0x25b8b5);});});}exports['GetVoiceCallReport']=function(_0x2bdd18){var _0x11d00d=this;return new Promise(function(_0x292f00,_0xe31ce7){return db[_0xb847('0x17')][_0xb847('0x18')]({'raw':_0x2bdd18[_0xb847('0x19')]?_0x2bdd18['options'][_0xb847('0x1a')]===undefined?!![]:![]:!![],'where':_0x2bdd18[_0xb847('0x19')]?_0x2bdd18['options'][_0xb847('0x1b')]||null:null,'attributes':_0x2bdd18[_0xb847('0x19')]?_0x2bdd18['options'][_0xb847('0x1c')]||null:null,'limit':_0x2bdd18['options']?_0x2bdd18[_0xb847('0x19')][_0xb847('0x1d')]||null:null,'include':_0x2bdd18[_0xb847('0x19')]?_0x2bdd18[_0xb847('0x19')]['include']?_[_0xb847('0x1e')](_0x2bdd18[_0xb847('0x19')][_0xb847('0x1f')],function(_0x4a078f){return{'model':db[_0x4a078f['model']],'as':_0x4a078f['as'],'attributes':_0x4a078f[_0xb847('0x1c')],'include':_0x4a078f[_0xb847('0x1f')]?_[_0xb847('0x1e')](_0x4a078f[_0xb847('0x1f')],function(_0xe21669){return{'model':db[_0xe21669['model']],'as':_0xe21669['as'],'attributes':_0xe21669['attributes'],'include':_0xe21669['include']?_[_0xb847('0x1e')](_0xe21669['include'],function(_0x5e0cf1){return{'model':db[_0x5e0cf1[_0xb847('0x20')]],'as':_0x5e0cf1['as'],'attributes':_0x5e0cf1[_0xb847('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x20b63b){logger['info']('GetVoiceCallReport',_0x2bdd18);logger['debug']('GetVoiceCallReport',_0x2bdd18,JSON[_0xb847('0x12')](_0x20b63b));_0x292f00(_0x20b63b);})[_0xb847('0x16')](function(_0x3dac15){logger[_0xb847('0x13')](_0xb847('0x21'),_0x3dac15['message'],_0x2bdd18);_0xe31ce7(_0x11d00d[_0xb847('0x13')](0x1f4,_0x3dac15['message']));});});};exports['CreateVoiceCallReport']=function(_0x4601bc){var _0x1bf669=this;return new Promise(function(_0x4d4e0d,_0x3aa941){return db['VoiceCallReport'][_0xb847('0x22')](_0x4601bc['body'],{'raw':_0x4601bc['options']?_0x4601bc[_0xb847('0x19')][_0xb847('0x1a')]===undefined?!![]:![]:!![]})[_0xb847('0xc')](function(_0x58f9ab){logger[_0xb847('0xd')](_0xb847('0x23'),_0x4601bc);logger[_0xb847('0x10')](_0xb847('0x23'),_0x4601bc,JSON[_0xb847('0x12')](_0x58f9ab));_0x4d4e0d(_0x58f9ab);})[_0xb847('0x16')](function(_0x4f4ef2){logger[_0xb847('0x13')](_0xb847('0x23'),_0x4f4ef2['message'],_0x4601bc);_0x3aa941(_0x1bf669[_0xb847('0x13')](0x1f4,_0x4f4ef2[_0xb847('0x14')]));});});};exports[_0xb847('0x24')]=function(_0x49b8f2){var _0x16aace=this;return new Promise(function(_0x1c8123,_0x7e66f3){return db[_0xb847('0x17')][_0xb847('0x25')](_0x49b8f2['body'],{'raw':_0x49b8f2['options']?_0x49b8f2[_0xb847('0x19')][_0xb847('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x49b8f2[_0xb847('0x19')]?_0x49b8f2['options']['where']||null:null,'attributes':_0x49b8f2[_0xb847('0x19')]?_0x49b8f2[_0xb847('0x19')][_0xb847('0x1c')]||null:null,'limit':_0x49b8f2['options']?_0x49b8f2[_0xb847('0x19')][_0xb847('0x1d')]||null:null})[_0xb847('0xc')](function(_0x3c3c40){logger[_0xb847('0xd')]('UpdateVoiceCallReport',_0x49b8f2);logger[_0xb847('0x10')](_0xb847('0x24'),_0x49b8f2,JSON[_0xb847('0x12')](_0x3c3c40));_0x1c8123(_0x3c3c40);})[_0xb847('0x16')](function(_0x2543b1){logger[_0xb847('0x13')](_0xb847('0x24'),_0x2543b1[_0xb847('0x14')],_0x49b8f2);_0x7e66f3(_0x16aace['error'](0x1f4,_0x2543b1[_0xb847('0x14')]));});});};