Built motion from commit (unavailable).|2.5.14
[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 _0x38a9=['catch','GetVoiceCallReport','options','limit','include','model','attributes','map','info','debug','VoiceCallReport','body','raw','CreateVoiceCallReport','UpdateVoiceCallReport','update','where','lodash','util','moment','bluebird','randomstring','../../config/utils','rpc','client','request','then','request\x20sent','VoiceCallReport,\x20%s,\x20%s,\x20%s','stringify','error','code','VoiceCallReport,\x20%s,\x20%s','message','result'];(function(_0x569397,_0xe36908){var _0x364485=function(_0x38bdc1){while(--_0x38bdc1){_0x569397['push'](_0x569397['shift']());}};_0x364485(++_0xe36908);}(_0x38a9,0x14c));var _0x938a=function(_0x4549f9,_0x143674){_0x4549f9=_0x4549f9-0x0;var _0x297902=_0x38a9[_0x4549f9];return _0x297902;};'use strict';var _=require(_0x938a('0x0'));var util=require(_0x938a('0x1'));var moment=require(_0x938a('0x2'));var BPromise=require(_0x938a('0x3'));var rs=require(_0x938a('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x938a('0x5'));var logger=require('../../config/logger')(_0x938a('0x6'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x938a('0x7')]['http']({'port':0x232a});function respondWithRpcPromise(_0x904d1d,_0x1880b3,_0x5c51c2){return new BPromise(function(_0x1ea1ac,_0x4dc8ae){return client[_0x938a('0x8')](_0x904d1d,_0x5c51c2)[_0x938a('0x9')](function(_0x4f9139){logger['info']('VoiceCallReport,\x20%s,\x20%s',_0x1880b3,_0x938a('0xa'));logger['debug'](_0x938a('0xb'),_0x1880b3,_0x938a('0xa'),JSON[_0x938a('0xc')](_0x4f9139));if(_0x4f9139[_0x938a('0xd')]){if(_0x4f9139[_0x938a('0xd')][_0x938a('0xe')]===0x1f4){logger[_0x938a('0xd')](_0x938a('0xf'),_0x1880b3,_0x4f9139[_0x938a('0xd')]['message']);return _0x4dc8ae(_0x4f9139[_0x938a('0xd')]['message']);}logger['error'](_0x938a('0xf'),_0x1880b3,_0x4f9139[_0x938a('0xd')][_0x938a('0x10')]);return _0x1ea1ac(_0x4f9139[_0x938a('0xd')][_0x938a('0x10')]);}else{logger['info'](_0x938a('0xf'),_0x1880b3,_0x938a('0xa'));_0x1ea1ac(_0x4f9139[_0x938a('0x11')]['message']);}})[_0x938a('0x12')](function(_0x1f659f){logger[_0x938a('0xd')](_0x938a('0xf'),_0x1880b3,_0x1f659f);_0x4dc8ae(_0x1f659f);});});}exports[_0x938a('0x13')]=function(_0x585184){var _0x1a86ea=this;return new Promise(function(_0x4ebf88,_0x4c14ec){return db['VoiceCallReport']['findAll']({'raw':_0x585184[_0x938a('0x14')]?_0x585184['options']['raw']===undefined?!![]:![]:!![],'where':_0x585184[_0x938a('0x14')]?_0x585184[_0x938a('0x14')]['where']||null:null,'attributes':_0x585184[_0x938a('0x14')]?_0x585184[_0x938a('0x14')]['attributes']||null:null,'limit':_0x585184[_0x938a('0x14')]?_0x585184['options'][_0x938a('0x15')]||null:null,'include':_0x585184[_0x938a('0x14')]?_0x585184[_0x938a('0x14')][_0x938a('0x16')]?_['map'](_0x585184[_0x938a('0x14')][_0x938a('0x16')],function(_0x260c24){return{'model':db[_0x260c24[_0x938a('0x17')]],'as':_0x260c24['as'],'attributes':_0x260c24[_0x938a('0x18')],'include':_0x260c24['include']?_[_0x938a('0x19')](_0x260c24[_0x938a('0x16')],function(_0x16448f){return{'model':db[_0x16448f[_0x938a('0x17')]],'as':_0x16448f['as'],'attributes':_0x16448f[_0x938a('0x18')],'include':_0x16448f[_0x938a('0x16')]?_[_0x938a('0x19')](_0x16448f['include'],function(_0x437911){return{'model':db[_0x437911[_0x938a('0x17')]],'as':_0x437911['as'],'attributes':_0x437911[_0x938a('0x18')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x548472){logger[_0x938a('0x1a')](_0x938a('0x13'),_0x585184);logger[_0x938a('0x1b')]('GetVoiceCallReport',_0x585184,JSON[_0x938a('0xc')](_0x548472));_0x4ebf88(_0x548472);})[_0x938a('0x12')](function(_0x346e95){logger[_0x938a('0xd')](_0x938a('0x13'),_0x346e95[_0x938a('0x10')],_0x585184);_0x4c14ec(_0x1a86ea[_0x938a('0xd')](0x1f4,_0x346e95[_0x938a('0x10')]));});});};exports['CreateVoiceCallReport']=function(_0x5780c0){var _0x43968e=this;return new Promise(function(_0x182574,_0x3b3851){return db[_0x938a('0x1c')]['create'](_0x5780c0[_0x938a('0x1d')],{'raw':_0x5780c0[_0x938a('0x14')]?_0x5780c0[_0x938a('0x14')][_0x938a('0x1e')]===undefined?!![]:![]:!![]})[_0x938a('0x9')](function(_0xfcd563){logger['info'](_0x938a('0x1f'),_0x5780c0);logger[_0x938a('0x1b')](_0x938a('0x1f'),_0x5780c0,JSON[_0x938a('0xc')](_0xfcd563));_0x182574(_0xfcd563);})[_0x938a('0x12')](function(_0x5b8097){logger[_0x938a('0xd')](_0x938a('0x1f'),_0x5b8097[_0x938a('0x10')],_0x5780c0);_0x3b3851(_0x43968e['error'](0x1f4,_0x5b8097[_0x938a('0x10')]));});});};exports[_0x938a('0x20')]=function(_0x9e368a){var _0x359a99=this;return new Promise(function(_0x4605f4,_0x34d343){return db[_0x938a('0x1c')][_0x938a('0x21')](_0x9e368a[_0x938a('0x1d')],{'raw':_0x9e368a[_0x938a('0x14')]?_0x9e368a[_0x938a('0x14')][_0x938a('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x9e368a['options']?_0x9e368a[_0x938a('0x14')][_0x938a('0x22')]||null:null,'attributes':_0x9e368a[_0x938a('0x14')]?_0x9e368a['options'][_0x938a('0x18')]||null:null,'limit':_0x9e368a[_0x938a('0x14')]?_0x9e368a[_0x938a('0x14')][_0x938a('0x15')]||null:null})['then'](function(_0x4db2d3){logger[_0x938a('0x1a')](_0x938a('0x20'),_0x9e368a);logger['debug'](_0x938a('0x20'),_0x9e368a,JSON[_0x938a('0xc')](_0x4db2d3));_0x4605f4(_0x4db2d3);})[_0x938a('0x12')](function(_0x47a9e7){logger[_0x938a('0xd')](_0x938a('0x20'),_0x47a9e7[_0x938a('0x10')],_0x9e368a);_0x34d343(_0x359a99[_0x938a('0xd')](0x1f4,_0x47a9e7[_0x938a('0x10')]));});});};