892af0de1c15a6616f2d3b36e1b058e57952a2c0
[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 _0xaa81=['then','info','request\x20sent','debug','VoiceCallReport,\x20%s,\x20%s,\x20%s','stringify','error','VoiceCallReport,\x20%s,\x20%s','message','result','findAll','options','raw','where','attributes','include','map','model','GetVoiceCallReport','catch','VoiceCallReport','create','body','CreateVoiceCallReport','UpdateVoiceCallReport','limit','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','client','http','request'];(function(_0x39c11a,_0x51d778){var _0x554541=function(_0x4b7eea){while(--_0x4b7eea){_0x39c11a['push'](_0x39c11a['shift']());}};_0x554541(++_0x51d778);}(_0xaa81,0x182));var _0x1aa8=function(_0x469f1c,_0xa5d6d2){_0x469f1c=_0x469f1c-0x0;var _0x3eb27e=_0xaa81[_0x469f1c];return _0x3eb27e;};'use strict';var _=require(_0x1aa8('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x1aa8('0x1'));var rs=require(_0x1aa8('0x2'));var fs=require('fs');var Redis=require(_0x1aa8('0x3'));var db=require(_0x1aa8('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x1aa8('0x5'))('rpc');var config=require(_0x1aa8('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x1aa8('0x7')][_0x1aa8('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x30a0f1,_0x295ac4,_0x5a676a){return new BPromise(function(_0x2ca251,_0x221062){return client[_0x1aa8('0x9')](_0x30a0f1,_0x5a676a)[_0x1aa8('0xa')](function(_0x13d261){logger[_0x1aa8('0xb')]('VoiceCallReport,\x20%s,\x20%s',_0x295ac4,_0x1aa8('0xc'));logger[_0x1aa8('0xd')](_0x1aa8('0xe'),_0x295ac4,_0x1aa8('0xc'),JSON[_0x1aa8('0xf')](_0x13d261));if(_0x13d261[_0x1aa8('0x10')]){if(_0x13d261[_0x1aa8('0x10')]['code']===0x1f4){logger[_0x1aa8('0x10')](_0x1aa8('0x11'),_0x295ac4,_0x13d261['error']['message']);return _0x221062(_0x13d261[_0x1aa8('0x10')][_0x1aa8('0x12')]);}logger[_0x1aa8('0x10')](_0x1aa8('0x11'),_0x295ac4,_0x13d261[_0x1aa8('0x10')][_0x1aa8('0x12')]);return _0x2ca251(_0x13d261[_0x1aa8('0x10')][_0x1aa8('0x12')]);}else{logger[_0x1aa8('0xb')](_0x1aa8('0x11'),_0x295ac4,_0x1aa8('0xc'));_0x2ca251(_0x13d261[_0x1aa8('0x13')]['message']);}})['catch'](function(_0x58dafb){logger[_0x1aa8('0x10')]('VoiceCallReport,\x20%s,\x20%s',_0x295ac4,_0x58dafb);_0x221062(_0x58dafb);});});}exports['GetVoiceCallReport']=function(_0x245c2d){var _0x159f10=this;return new Promise(function(_0x4f6197,_0x4b2387){return db['VoiceCallReport'][_0x1aa8('0x14')]({'raw':_0x245c2d[_0x1aa8('0x15')]?_0x245c2d[_0x1aa8('0x15')][_0x1aa8('0x16')]===undefined?!![]:![]:!![],'where':_0x245c2d[_0x1aa8('0x15')]?_0x245c2d[_0x1aa8('0x15')][_0x1aa8('0x17')]||null:null,'attributes':_0x245c2d['options']?_0x245c2d[_0x1aa8('0x15')][_0x1aa8('0x18')]||null:null,'limit':_0x245c2d[_0x1aa8('0x15')]?_0x245c2d[_0x1aa8('0x15')]['limit']||null:null,'include':_0x245c2d[_0x1aa8('0x15')]?_0x245c2d[_0x1aa8('0x15')]['include']?_['map'](_0x245c2d[_0x1aa8('0x15')][_0x1aa8('0x19')],function(_0x475069){return{'model':db[_0x475069['model']],'as':_0x475069['as'],'attributes':_0x475069[_0x1aa8('0x18')],'include':_0x475069['include']?_[_0x1aa8('0x1a')](_0x475069['include'],function(_0x3caf68){return{'model':db[_0x3caf68[_0x1aa8('0x1b')]],'as':_0x3caf68['as'],'attributes':_0x3caf68[_0x1aa8('0x18')],'include':_0x3caf68[_0x1aa8('0x19')]?_['map'](_0x3caf68[_0x1aa8('0x19')],function(_0x1bcdc0){return{'model':db[_0x1bcdc0[_0x1aa8('0x1b')]],'as':_0x1bcdc0['as'],'attributes':_0x1bcdc0[_0x1aa8('0x18')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2a7d64){logger[_0x1aa8('0xb')]('GetVoiceCallReport',_0x245c2d);logger[_0x1aa8('0xd')](_0x1aa8('0x1c'),_0x245c2d,JSON[_0x1aa8('0xf')](_0x2a7d64));_0x4f6197(_0x2a7d64);})[_0x1aa8('0x1d')](function(_0x2031b1){logger[_0x1aa8('0x10')](_0x1aa8('0x1c'),_0x2031b1[_0x1aa8('0x12')],_0x245c2d);_0x4b2387(_0x159f10[_0x1aa8('0x10')](0x1f4,_0x2031b1['message']));});});};exports['CreateVoiceCallReport']=function(_0x128e2b){var _0x1393f8=this;return new Promise(function(_0x86b04b,_0x146997){return db[_0x1aa8('0x1e')][_0x1aa8('0x1f')](_0x128e2b[_0x1aa8('0x20')],{'raw':_0x128e2b[_0x1aa8('0x15')]?_0x128e2b['options'][_0x1aa8('0x16')]===undefined?!![]:![]:!![]})[_0x1aa8('0xa')](function(_0x34602b){logger[_0x1aa8('0xb')]('CreateVoiceCallReport',_0x128e2b);logger[_0x1aa8('0xd')](_0x1aa8('0x21'),_0x128e2b,JSON[_0x1aa8('0xf')](_0x34602b));_0x86b04b(_0x34602b);})[_0x1aa8('0x1d')](function(_0x3c09cf){logger[_0x1aa8('0x10')](_0x1aa8('0x21'),_0x3c09cf[_0x1aa8('0x12')],_0x128e2b);_0x146997(_0x1393f8[_0x1aa8('0x10')](0x1f4,_0x3c09cf['message']));});});};exports[_0x1aa8('0x22')]=function(_0x3288a4){var _0x3f86d0=this;return new Promise(function(_0x3cd8a0,_0x327a13){return db[_0x1aa8('0x1e')]['update'](_0x3288a4[_0x1aa8('0x20')],{'raw':_0x3288a4[_0x1aa8('0x15')]?_0x3288a4[_0x1aa8('0x15')][_0x1aa8('0x16')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3288a4[_0x1aa8('0x15')]?_0x3288a4[_0x1aa8('0x15')]['where']||null:null,'attributes':_0x3288a4['options']?_0x3288a4['options'][_0x1aa8('0x18')]||null:null,'limit':_0x3288a4[_0x1aa8('0x15')]?_0x3288a4[_0x1aa8('0x15')][_0x1aa8('0x23')]||null:null})['then'](function(_0x3167ac){logger['info']('UpdateVoiceCallReport',_0x3288a4);logger['debug'](_0x1aa8('0x22'),_0x3288a4,JSON[_0x1aa8('0xf')](_0x3167ac));_0x3cd8a0(_0x3167ac);})['catch'](function(_0xe4338e){logger[_0x1aa8('0x10')](_0x1aa8('0x22'),_0xe4338e[_0x1aa8('0x12')],_0x3288a4);_0x327a13(_0x3f86d0[_0x1aa8('0x10')](0x1f4,_0xe4338e[_0x1aa8('0x12')]));});});};