9456c6d1eedc86caa696cbd8ab9a987bbce10e24
[motion2.git] / server / api / memberReport / memberReport.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 _0xbd3c=['findAll','options','raw','attributes','limit','map','include','model','stringify','CreateMemberReport','body','UpdateMemberReport','update','where','lodash','util','moment','randomstring','ioredis','../../mysqldb','rpc','jayson/promise','client','request','then','info','debug','MemberReport,\x20%s,\x20%s,\x20%s','error','code','message','MemberReport,\x20%s,\x20%s','result','catch','GetMemberReport','MemberReport'];(function(_0x48e1ae,_0x285bca){var _0x32b8d6=function(_0x46842e){while(--_0x46842e){_0x48e1ae['push'](_0x48e1ae['shift']());}};_0x32b8d6(++_0x285bca);}(_0xbd3c,0xc2));var _0xcbd3=function(_0x3c6a31,_0x32c7c4){_0x3c6a31=_0x3c6a31-0x0;var _0x3a4d6f=_0xbd3c[_0x3c6a31];return _0x3a4d6f;};'use strict';var _=require(_0xcbd3('0x0'));var util=require(_0xcbd3('0x1'));var moment=require(_0xcbd3('0x2'));var BPromise=require('bluebird');var rs=require(_0xcbd3('0x3'));var fs=require('fs');var Redis=require(_0xcbd3('0x4'));var db=require(_0xcbd3('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xcbd3('0x6'));var config=require('../../config/environment');var jayson=require(_0xcbd3('0x7'));var client=jayson[_0xcbd3('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x348468,_0x1c1483,_0x13b4aa){return new BPromise(function(_0x4b369b,_0x18fb60){return client[_0xcbd3('0x9')](_0x348468,_0x13b4aa)[_0xcbd3('0xa')](function(_0x64f732){logger[_0xcbd3('0xb')]('MemberReport,\x20%s,\x20%s',_0x1c1483,'request\x20sent');logger[_0xcbd3('0xc')](_0xcbd3('0xd'),_0x1c1483,'request\x20sent',JSON['stringify'](_0x64f732));if(_0x64f732['error']){if(_0x64f732[_0xcbd3('0xe')][_0xcbd3('0xf')]===0x1f4){logger[_0xcbd3('0xe')]('MemberReport,\x20%s,\x20%s',_0x1c1483,_0x64f732[_0xcbd3('0xe')][_0xcbd3('0x10')]);return _0x18fb60(_0x64f732[_0xcbd3('0xe')][_0xcbd3('0x10')]);}logger[_0xcbd3('0xe')](_0xcbd3('0x11'),_0x1c1483,_0x64f732['error'][_0xcbd3('0x10')]);return _0x4b369b(_0x64f732['error'][_0xcbd3('0x10')]);}else{logger[_0xcbd3('0xb')](_0xcbd3('0x11'),_0x1c1483,'request\x20sent');_0x4b369b(_0x64f732[_0xcbd3('0x12')]['message']);}})[_0xcbd3('0x13')](function(_0x5941a5){logger[_0xcbd3('0xe')](_0xcbd3('0x11'),_0x1c1483,_0x5941a5);_0x18fb60(_0x5941a5);});});}exports[_0xcbd3('0x14')]=function(_0x115336){var _0xb02b09=this;return new Promise(function(_0x4ee6a2,_0x4f0bd7){return db[_0xcbd3('0x15')][_0xcbd3('0x16')]({'raw':_0x115336[_0xcbd3('0x17')]?_0x115336['options'][_0xcbd3('0x18')]===undefined?!![]:![]:!![],'where':_0x115336['options']?_0x115336[_0xcbd3('0x17')]['where']||null:null,'attributes':_0x115336[_0xcbd3('0x17')]?_0x115336['options'][_0xcbd3('0x19')]||null:null,'limit':_0x115336['options']?_0x115336['options'][_0xcbd3('0x1a')]||null:null,'include':_0x115336[_0xcbd3('0x17')]?_0x115336[_0xcbd3('0x17')]['include']?_[_0xcbd3('0x1b')](_0x115336[_0xcbd3('0x17')][_0xcbd3('0x1c')],function(_0x334b34){return{'model':db[_0x334b34[_0xcbd3('0x1d')]],'as':_0x334b34['as'],'attributes':_0x334b34[_0xcbd3('0x19')],'include':_0x334b34[_0xcbd3('0x1c')]?_[_0xcbd3('0x1b')](_0x334b34['include'],function(_0x35fd76){return{'model':db[_0x35fd76['model']],'as':_0x35fd76['as'],'attributes':_0x35fd76[_0xcbd3('0x19')],'include':_0x35fd76['include']?_[_0xcbd3('0x1b')](_0x35fd76[_0xcbd3('0x1c')],function(_0x4fb411){return{'model':db[_0x4fb411[_0xcbd3('0x1d')]],'as':_0x4fb411['as'],'attributes':_0x4fb411['attributes']};}):[]};}):[]};}):[]:[]})[_0xcbd3('0xa')](function(_0xb3ae68){logger[_0xcbd3('0xb')](_0xcbd3('0x14'),_0x115336);logger[_0xcbd3('0xc')](_0xcbd3('0x14'),_0x115336,JSON[_0xcbd3('0x1e')](_0xb3ae68));_0x4ee6a2(_0xb3ae68);})['catch'](function(_0x3b2186){logger[_0xcbd3('0xe')](_0xcbd3('0x14'),_0x3b2186[_0xcbd3('0x10')],_0x115336);_0x4f0bd7(_0xb02b09[_0xcbd3('0xe')](0x1f4,_0x3b2186[_0xcbd3('0x10')]));});});};exports[_0xcbd3('0x1f')]=function(_0x15ed47){var _0x2df328=this;return new Promise(function(_0x58ac9c,_0x1bb1f3){return db['MemberReport']['create'](_0x15ed47[_0xcbd3('0x20')],{'raw':_0x15ed47[_0xcbd3('0x17')]?_0x15ed47[_0xcbd3('0x17')][_0xcbd3('0x18')]===undefined?!![]:![]:!![]})[_0xcbd3('0xa')](function(_0x9a7873){logger[_0xcbd3('0xb')]('CreateMemberReport',_0x15ed47);logger[_0xcbd3('0xc')]('CreateMemberReport',_0x15ed47,JSON[_0xcbd3('0x1e')](_0x9a7873));_0x58ac9c(_0x9a7873);})[_0xcbd3('0x13')](function(_0x3c2b0e){logger[_0xcbd3('0xe')](_0xcbd3('0x1f'),_0x3c2b0e[_0xcbd3('0x10')],_0x15ed47);_0x1bb1f3(_0x2df328[_0xcbd3('0xe')](0x1f4,_0x3c2b0e[_0xcbd3('0x10')]));});});};exports[_0xcbd3('0x21')]=function(_0x53b1a8){var _0x546756=this;return new Promise(function(_0x13da4f,_0x5a5d74){return db[_0xcbd3('0x15')][_0xcbd3('0x22')](_0x53b1a8[_0xcbd3('0x20')],{'raw':_0x53b1a8[_0xcbd3('0x17')]?_0x53b1a8[_0xcbd3('0x17')][_0xcbd3('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x53b1a8['options']?_0x53b1a8[_0xcbd3('0x17')][_0xcbd3('0x23')]||null:null,'attributes':_0x53b1a8['options']?_0x53b1a8[_0xcbd3('0x17')]['attributes']||null:null,'limit':_0x53b1a8[_0xcbd3('0x17')]?_0x53b1a8[_0xcbd3('0x17')][_0xcbd3('0x1a')]||null:null})[_0xcbd3('0xa')](function(_0x55147f){logger['info'](_0xcbd3('0x21'),_0x53b1a8);logger['debug'](_0xcbd3('0x21'),_0x53b1a8,JSON[_0xcbd3('0x1e')](_0x55147f));_0x13da4f(_0x55147f);})[_0xcbd3('0x13')](function(_0x4a2449){logger[_0xcbd3('0xe')](_0xcbd3('0x21'),_0x4a2449['message'],_0x53b1a8);_0x5a5d74(_0x546756[_0xcbd3('0xe')](0x1f4,_0x4a2449[_0xcbd3('0x10')]));});});};