94042d29d9505bdf6b8fab472e0bc87d244a9f7e
[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 _0xf2b0=['MemberReport,\x20%s,\x20%s','request\x20sent','MemberReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','MemberReport','findAll','options','raw','where','attributes','limit','include','map','model','GetMemberReport','debug','CreateMemberReport','create','body','UpdateMemberReport','update','lodash','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','request','then'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0xf2b0,0x18d));var _0x0f2b=function(_0x15aede,_0x1874e2){_0x15aede=_0x15aede-0x0;var _0x307118=_0xf2b0[_0x15aede];return _0x307118;};'use strict';var _=require(_0x0f2b('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x0f2b('0x1'));var rs=require(_0x0f2b('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x0f2b('0x3'))['db'];var utils=require(_0x0f2b('0x4'));var logger=require(_0x0f2b('0x5'))('rpc');var config=require(_0x0f2b('0x6'));var jayson=require(_0x0f2b('0x7'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x32c483,_0x589a04,_0xd20de3){return new BPromise(function(_0x501636,_0x35dc17){return client[_0x0f2b('0x8')](_0x32c483,_0xd20de3)[_0x0f2b('0x9')](function(_0x3a03ec){logger['info'](_0x0f2b('0xa'),_0x589a04,_0x0f2b('0xb'));logger['debug'](_0x0f2b('0xc'),_0x589a04,_0x0f2b('0xb'),JSON[_0x0f2b('0xd')](_0x3a03ec));if(_0x3a03ec[_0x0f2b('0xe')]){if(_0x3a03ec[_0x0f2b('0xe')][_0x0f2b('0xf')]===0x1f4){logger['error'](_0x0f2b('0xa'),_0x589a04,_0x3a03ec[_0x0f2b('0xe')][_0x0f2b('0x10')]);return _0x35dc17(_0x3a03ec[_0x0f2b('0xe')]['message']);}logger[_0x0f2b('0xe')](_0x0f2b('0xa'),_0x589a04,_0x3a03ec[_0x0f2b('0xe')][_0x0f2b('0x10')]);return _0x501636(_0x3a03ec['error'][_0x0f2b('0x10')]);}else{logger[_0x0f2b('0x11')](_0x0f2b('0xa'),_0x589a04,_0x0f2b('0xb'));_0x501636(_0x3a03ec[_0x0f2b('0x12')][_0x0f2b('0x10')]);}})[_0x0f2b('0x13')](function(_0x11aa0a){logger[_0x0f2b('0xe')]('MemberReport,\x20%s,\x20%s',_0x589a04,_0x11aa0a);_0x35dc17(_0x11aa0a);});});}exports['GetMemberReport']=function(_0x36c2f6){var _0x505849=this;return new Promise(function(_0x372eee,_0x45d099){return db[_0x0f2b('0x14')][_0x0f2b('0x15')]({'raw':_0x36c2f6[_0x0f2b('0x16')]?_0x36c2f6[_0x0f2b('0x16')][_0x0f2b('0x17')]===undefined?!![]:![]:!![],'where':_0x36c2f6[_0x0f2b('0x16')]?_0x36c2f6[_0x0f2b('0x16')][_0x0f2b('0x18')]||null:null,'attributes':_0x36c2f6[_0x0f2b('0x16')]?_0x36c2f6[_0x0f2b('0x16')][_0x0f2b('0x19')]||null:null,'limit':_0x36c2f6[_0x0f2b('0x16')]?_0x36c2f6['options'][_0x0f2b('0x1a')]||null:null,'include':_0x36c2f6['options']?_0x36c2f6[_0x0f2b('0x16')][_0x0f2b('0x1b')]?_[_0x0f2b('0x1c')](_0x36c2f6[_0x0f2b('0x16')]['include'],function(_0x3d4e1c){return{'model':db[_0x3d4e1c[_0x0f2b('0x1d')]],'as':_0x3d4e1c['as'],'attributes':_0x3d4e1c[_0x0f2b('0x19')],'include':_0x3d4e1c[_0x0f2b('0x1b')]?_['map'](_0x3d4e1c[_0x0f2b('0x1b')],function(_0x45087e){return{'model':db[_0x45087e[_0x0f2b('0x1d')]],'as':_0x45087e['as'],'attributes':_0x45087e[_0x0f2b('0x19')],'include':_0x45087e['include']?_[_0x0f2b('0x1c')](_0x45087e['include'],function(_0x57e68e){return{'model':db[_0x57e68e['model']],'as':_0x57e68e['as'],'attributes':_0x57e68e[_0x0f2b('0x19')]};}):[]};}):[]};}):[]:[]})[_0x0f2b('0x9')](function(_0x3f3c64){logger['info'](_0x0f2b('0x1e'),_0x36c2f6);logger[_0x0f2b('0x1f')](_0x0f2b('0x1e'),_0x36c2f6,JSON[_0x0f2b('0xd')](_0x3f3c64));_0x372eee(_0x3f3c64);})[_0x0f2b('0x13')](function(_0x45219d){logger['error'](_0x0f2b('0x1e'),_0x45219d['message'],_0x36c2f6);_0x45d099(_0x505849[_0x0f2b('0xe')](0x1f4,_0x45219d[_0x0f2b('0x10')]));});});};exports[_0x0f2b('0x20')]=function(_0x61d191){var _0x2afc83=this;return new Promise(function(_0x4c9185,_0x383505){return db[_0x0f2b('0x14')][_0x0f2b('0x21')](_0x61d191[_0x0f2b('0x22')],{'raw':_0x61d191[_0x0f2b('0x16')]?_0x61d191[_0x0f2b('0x16')][_0x0f2b('0x17')]===undefined?!![]:![]:!![]})[_0x0f2b('0x9')](function(_0x2f445a){logger[_0x0f2b('0x11')](_0x0f2b('0x20'),_0x61d191);logger[_0x0f2b('0x1f')](_0x0f2b('0x20'),_0x61d191,JSON[_0x0f2b('0xd')](_0x2f445a));_0x4c9185(_0x2f445a);})[_0x0f2b('0x13')](function(_0x24e698){logger['error'](_0x0f2b('0x20'),_0x24e698[_0x0f2b('0x10')],_0x61d191);_0x383505(_0x2afc83[_0x0f2b('0xe')](0x1f4,_0x24e698['message']));});});};exports[_0x0f2b('0x23')]=function(_0x5e24de){var _0x574fe6=this;return new Promise(function(_0x5284bb,_0x3162ff){return db[_0x0f2b('0x14')][_0x0f2b('0x24')](_0x5e24de[_0x0f2b('0x22')],{'raw':_0x5e24de[_0x0f2b('0x16')]?_0x5e24de[_0x0f2b('0x16')][_0x0f2b('0x17')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5e24de['options']?_0x5e24de['options'][_0x0f2b('0x18')]||null:null,'attributes':_0x5e24de[_0x0f2b('0x16')]?_0x5e24de[_0x0f2b('0x16')][_0x0f2b('0x19')]||null:null,'limit':_0x5e24de['options']?_0x5e24de[_0x0f2b('0x16')]['limit']||null:null})[_0x0f2b('0x9')](function(_0xabe7f5){logger['info'](_0x0f2b('0x23'),_0x5e24de);logger[_0x0f2b('0x1f')](_0x0f2b('0x23'),_0x5e24de,JSON[_0x0f2b('0xd')](_0xabe7f5));_0x5284bb(_0xabe7f5);})[_0x0f2b('0x13')](function(_0x2145c1){logger[_0x0f2b('0xe')](_0x0f2b('0x23'),_0x2145c1[_0x0f2b('0x10')],_0x5e24de);_0x3162ff(_0x574fe6['error'](0x1f4,_0x2145c1['message']));});});};