c2239e45f53bb467629ac6236669f56bd87852ee
[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 _0xc1e5=['randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','then','info','debug','stringify','error','VoiceCallReport,\x20%s,\x20%s','message','catch','GetVoiceCallReport','VoiceCallReport','findAll','options','where','attributes','limit','include','map','model','CreateVoiceCallReport','create','body','raw','UpdateVoiceCallReport','update','lodash','moment','bluebird'];(function(_0x199af8,_0x3650a1){var _0x10f65e=function(_0x5630a5){while(--_0x5630a5){_0x199af8['push'](_0x199af8['shift']());}};_0x10f65e(++_0x3650a1);}(_0xc1e5,0x141));var _0x5c1e=function(_0x460886,_0x208afa){_0x460886=_0x460886-0x0;var _0xdb3a81=_0xc1e5[_0x460886];return _0xdb3a81;};'use strict';var _=require(_0x5c1e('0x0'));var util=require('util');var moment=require(_0x5c1e('0x1'));var BPromise=require(_0x5c1e('0x2'));var rs=require(_0x5c1e('0x3'));var fs=require('fs');var Redis=require(_0x5c1e('0x4'));var db=require(_0x5c1e('0x5'))['db'];var utils=require(_0x5c1e('0x6'));var logger=require(_0x5c1e('0x7'))(_0x5c1e('0x8'));var config=require(_0x5c1e('0x9'));var jayson=require(_0x5c1e('0xa'));var client=jayson['client'][_0x5c1e('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x358658,_0xe853db,_0x15e3a4){return new BPromise(function(_0x223d81,_0x2e0461){return client['request'](_0x358658,_0x15e3a4)[_0x5c1e('0xc')](function(_0x2d0051){logger[_0x5c1e('0xd')]('VoiceCallReport,\x20%s,\x20%s',_0xe853db,'request\x20sent');logger[_0x5c1e('0xe')]('VoiceCallReport,\x20%s,\x20%s,\x20%s',_0xe853db,'request\x20sent',JSON[_0x5c1e('0xf')](_0x2d0051));if(_0x2d0051[_0x5c1e('0x10')]){if(_0x2d0051[_0x5c1e('0x10')]['code']===0x1f4){logger['error'](_0x5c1e('0x11'),_0xe853db,_0x2d0051['error'][_0x5c1e('0x12')]);return _0x2e0461(_0x2d0051['error'][_0x5c1e('0x12')]);}logger['error'](_0x5c1e('0x11'),_0xe853db,_0x2d0051[_0x5c1e('0x10')]['message']);return _0x223d81(_0x2d0051['error'][_0x5c1e('0x12')]);}else{logger[_0x5c1e('0xd')](_0x5c1e('0x11'),_0xe853db,'request\x20sent');_0x223d81(_0x2d0051['result'][_0x5c1e('0x12')]);}})[_0x5c1e('0x13')](function(_0x3fd2dd){logger[_0x5c1e('0x10')]('VoiceCallReport,\x20%s,\x20%s',_0xe853db,_0x3fd2dd);_0x2e0461(_0x3fd2dd);});});}exports[_0x5c1e('0x14')]=function(_0x4de557){var _0x11b243=this;return new Promise(function(_0x16b907,_0xbb451f){return db[_0x5c1e('0x15')][_0x5c1e('0x16')]({'raw':_0x4de557[_0x5c1e('0x17')]?_0x4de557[_0x5c1e('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x4de557['options']?_0x4de557['options'][_0x5c1e('0x18')]||null:null,'attributes':_0x4de557[_0x5c1e('0x17')]?_0x4de557[_0x5c1e('0x17')][_0x5c1e('0x19')]||null:null,'limit':_0x4de557[_0x5c1e('0x17')]?_0x4de557['options'][_0x5c1e('0x1a')]||null:null,'include':_0x4de557[_0x5c1e('0x17')]?_0x4de557['options'][_0x5c1e('0x1b')]?_[_0x5c1e('0x1c')](_0x4de557['options']['include'],function(_0x36515c){return{'model':db[_0x36515c[_0x5c1e('0x1d')]],'as':_0x36515c['as'],'attributes':_0x36515c['attributes'],'include':_0x36515c[_0x5c1e('0x1b')]?_[_0x5c1e('0x1c')](_0x36515c['include'],function(_0x5e63cf){return{'model':db[_0x5e63cf[_0x5c1e('0x1d')]],'as':_0x5e63cf['as'],'attributes':_0x5e63cf[_0x5c1e('0x19')],'include':_0x5e63cf[_0x5c1e('0x1b')]?_['map'](_0x5e63cf[_0x5c1e('0x1b')],function(_0x415d66){return{'model':db[_0x415d66[_0x5c1e('0x1d')]],'as':_0x415d66['as'],'attributes':_0x415d66[_0x5c1e('0x19')]};}):[]};}):[]};}):[]:[]})[_0x5c1e('0xc')](function(_0x2ddf49){logger[_0x5c1e('0xd')](_0x5c1e('0x14'),_0x4de557);logger['debug']('GetVoiceCallReport',_0x4de557,JSON['stringify'](_0x2ddf49));_0x16b907(_0x2ddf49);})[_0x5c1e('0x13')](function(_0x5cad98){logger['error'](_0x5c1e('0x14'),_0x5cad98[_0x5c1e('0x12')],_0x4de557);_0xbb451f(_0x11b243[_0x5c1e('0x10')](0x1f4,_0x5cad98[_0x5c1e('0x12')]));});});};exports[_0x5c1e('0x1e')]=function(_0x16cd9a){var _0x16f13f=this;return new Promise(function(_0x5a2abb,_0x5528c6){return db['VoiceCallReport'][_0x5c1e('0x1f')](_0x16cd9a[_0x5c1e('0x20')],{'raw':_0x16cd9a['options']?_0x16cd9a[_0x5c1e('0x17')][_0x5c1e('0x21')]===undefined?!![]:![]:!![]})[_0x5c1e('0xc')](function(_0x45d92a){logger[_0x5c1e('0xd')](_0x5c1e('0x1e'),_0x16cd9a);logger[_0x5c1e('0xe')](_0x5c1e('0x1e'),_0x16cd9a,JSON['stringify'](_0x45d92a));_0x5a2abb(_0x45d92a);})[_0x5c1e('0x13')](function(_0x3468db){logger[_0x5c1e('0x10')](_0x5c1e('0x1e'),_0x3468db[_0x5c1e('0x12')],_0x16cd9a);_0x5528c6(_0x16f13f[_0x5c1e('0x10')](0x1f4,_0x3468db[_0x5c1e('0x12')]));});});};exports[_0x5c1e('0x22')]=function(_0x4a91e3){var _0x2cc4e8=this;return new Promise(function(_0x26f7ea,_0x3bed3f){return db['VoiceCallReport'][_0x5c1e('0x23')](_0x4a91e3[_0x5c1e('0x20')],{'raw':_0x4a91e3[_0x5c1e('0x17')]?_0x4a91e3[_0x5c1e('0x17')][_0x5c1e('0x21')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4a91e3['options']?_0x4a91e3['options']['where']||null:null,'attributes':_0x4a91e3['options']?_0x4a91e3[_0x5c1e('0x17')]['attributes']||null:null,'limit':_0x4a91e3[_0x5c1e('0x17')]?_0x4a91e3[_0x5c1e('0x17')]['limit']||null:null})['then'](function(_0x5a84d9){logger['info'](_0x5c1e('0x22'),_0x4a91e3);logger[_0x5c1e('0xe')](_0x5c1e('0x22'),_0x4a91e3,JSON[_0x5c1e('0xf')](_0x5a84d9));_0x26f7ea(_0x5a84d9);})[_0x5c1e('0x13')](function(_0x5173b9){logger[_0x5c1e('0x10')](_0x5c1e('0x22'),_0x5173b9[_0x5c1e('0x12')],_0x4a91e3);_0x3bed3f(_0x2cc4e8[_0x5c1e('0x10')](0x1f4,_0x5173b9[_0x5c1e('0x12')]));});});};