Built motion from commit 449495f6.|2.6.27
[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 _0xb7b6=['where','lodash','util','randomstring','ioredis','../../config/utils','../../config/logger','jayson/promise','client','http','request','then','debug','MemberReport,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','MemberReport,\x20%s,\x20%s','message','catch','GetMemberReport','MemberReport','findAll','options','raw','limit','include','map','model','attributes','info','CreateMemberReport','UpdateMemberReport','update','body'];(function(_0x121adf,_0x2bfc7a){var _0x3cf508=function(_0x33d257){while(--_0x33d257){_0x121adf['push'](_0x121adf['shift']());}};_0x3cf508(++_0x2bfc7a);}(_0xb7b6,0x15f));var _0x6b7b=function(_0x5be51b,_0x284a57){_0x5be51b=_0x5be51b-0x0;var _0x17ce3b=_0xb7b6[_0x5be51b];return _0x17ce3b;};'use strict';var _=require(_0x6b7b('0x0'));var util=require(_0x6b7b('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x6b7b('0x2'));var fs=require('fs');var Redis=require(_0x6b7b('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x6b7b('0x4'));var logger=require(_0x6b7b('0x5'))('rpc');var config=require('../../config/environment');var jayson=require(_0x6b7b('0x6'));var client=jayson[_0x6b7b('0x7')][_0x6b7b('0x8')]({'port':0x232a});function respondWithRpcPromise(_0xff519e,_0x24359f,_0x483b9c){return new BPromise(function(_0x49a6c8,_0x2bb86d){return client[_0x6b7b('0x9')](_0xff519e,_0x483b9c)[_0x6b7b('0xa')](function(_0x115f2d){logger['info']('MemberReport,\x20%s,\x20%s',_0x24359f,'request\x20sent');logger[_0x6b7b('0xb')](_0x6b7b('0xc'),_0x24359f,_0x6b7b('0xd'),JSON[_0x6b7b('0xe')](_0x115f2d));if(_0x115f2d[_0x6b7b('0xf')]){if(_0x115f2d[_0x6b7b('0xf')]['code']===0x1f4){logger[_0x6b7b('0xf')](_0x6b7b('0x10'),_0x24359f,_0x115f2d['error'][_0x6b7b('0x11')]);return _0x2bb86d(_0x115f2d[_0x6b7b('0xf')]['message']);}logger[_0x6b7b('0xf')]('MemberReport,\x20%s,\x20%s',_0x24359f,_0x115f2d[_0x6b7b('0xf')][_0x6b7b('0x11')]);return _0x49a6c8(_0x115f2d[_0x6b7b('0xf')]['message']);}else{logger['info'](_0x6b7b('0x10'),_0x24359f,'request\x20sent');_0x49a6c8(_0x115f2d['result'][_0x6b7b('0x11')]);}})[_0x6b7b('0x12')](function(_0x4ef35b){logger[_0x6b7b('0xf')](_0x6b7b('0x10'),_0x24359f,_0x4ef35b);_0x2bb86d(_0x4ef35b);});});}exports[_0x6b7b('0x13')]=function(_0x41f48e){var _0x51b01f=this;return new Promise(function(_0x3d025c,_0x2036ec){return db[_0x6b7b('0x14')][_0x6b7b('0x15')]({'raw':_0x41f48e[_0x6b7b('0x16')]?_0x41f48e[_0x6b7b('0x16')][_0x6b7b('0x17')]===undefined?!![]:![]:!![],'where':_0x41f48e[_0x6b7b('0x16')]?_0x41f48e['options']['where']||null:null,'attributes':_0x41f48e[_0x6b7b('0x16')]?_0x41f48e['options']['attributes']||null:null,'limit':_0x41f48e['options']?_0x41f48e['options'][_0x6b7b('0x18')]||null:null,'include':_0x41f48e[_0x6b7b('0x16')]?_0x41f48e['options'][_0x6b7b('0x19')]?_[_0x6b7b('0x1a')](_0x41f48e['options'][_0x6b7b('0x19')],function(_0x1d3c69){return{'model':db[_0x1d3c69[_0x6b7b('0x1b')]],'as':_0x1d3c69['as'],'attributes':_0x1d3c69[_0x6b7b('0x1c')],'include':_0x1d3c69[_0x6b7b('0x19')]?_[_0x6b7b('0x1a')](_0x1d3c69[_0x6b7b('0x19')],function(_0x6edf){return{'model':db[_0x6edf[_0x6b7b('0x1b')]],'as':_0x6edf['as'],'attributes':_0x6edf[_0x6b7b('0x1c')],'include':_0x6edf[_0x6b7b('0x19')]?_[_0x6b7b('0x1a')](_0x6edf[_0x6b7b('0x19')],function(_0x2fc275){return{'model':db[_0x2fc275[_0x6b7b('0x1b')]],'as':_0x2fc275['as'],'attributes':_0x2fc275['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x3120a3){logger[_0x6b7b('0x1d')](_0x6b7b('0x13'),_0x41f48e);logger['debug'](_0x6b7b('0x13'),_0x41f48e,JSON['stringify'](_0x3120a3));_0x3d025c(_0x3120a3);})[_0x6b7b('0x12')](function(_0x3117db){logger[_0x6b7b('0xf')](_0x6b7b('0x13'),_0x3117db['message'],_0x41f48e);_0x2036ec(_0x51b01f['error'](0x1f4,_0x3117db[_0x6b7b('0x11')]));});});};exports[_0x6b7b('0x1e')]=function(_0x3622e0){var _0x3ee2b6=this;return new Promise(function(_0x4f70e3,_0xef8922){return db[_0x6b7b('0x14')]['create'](_0x3622e0['body'],{'raw':_0x3622e0[_0x6b7b('0x16')]?_0x3622e0[_0x6b7b('0x16')][_0x6b7b('0x17')]===undefined?!![]:![]:!![]})[_0x6b7b('0xa')](function(_0x48e25b){logger['info'](_0x6b7b('0x1e'),_0x3622e0);logger[_0x6b7b('0xb')]('CreateMemberReport',_0x3622e0,JSON[_0x6b7b('0xe')](_0x48e25b));_0x4f70e3(_0x48e25b);})[_0x6b7b('0x12')](function(_0x2ae633){logger[_0x6b7b('0xf')](_0x6b7b('0x1e'),_0x2ae633['message'],_0x3622e0);_0xef8922(_0x3ee2b6[_0x6b7b('0xf')](0x1f4,_0x2ae633[_0x6b7b('0x11')]));});});};exports[_0x6b7b('0x1f')]=function(_0x5a1086){var _0x29e3e1=this;return new Promise(function(_0x1175dd,_0x5bb0f8){return db['MemberReport'][_0x6b7b('0x20')](_0x5a1086[_0x6b7b('0x21')],{'raw':_0x5a1086[_0x6b7b('0x16')]?_0x5a1086[_0x6b7b('0x16')][_0x6b7b('0x17')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5a1086['options']?_0x5a1086[_0x6b7b('0x16')][_0x6b7b('0x22')]||null:null,'attributes':_0x5a1086[_0x6b7b('0x16')]?_0x5a1086[_0x6b7b('0x16')][_0x6b7b('0x1c')]||null:null,'limit':_0x5a1086[_0x6b7b('0x16')]?_0x5a1086[_0x6b7b('0x16')][_0x6b7b('0x18')]||null:null})[_0x6b7b('0xa')](function(_0x49b593){logger[_0x6b7b('0x1d')](_0x6b7b('0x1f'),_0x5a1086);logger[_0x6b7b('0xb')](_0x6b7b('0x1f'),_0x5a1086,JSON[_0x6b7b('0xe')](_0x49b593));_0x1175dd(_0x49b593);})[_0x6b7b('0x12')](function(_0x28ba67){logger['error'](_0x6b7b('0x1f'),_0x28ba67[_0x6b7b('0x11')],_0x5a1086);_0x5bb0f8(_0x29e3e1[_0x6b7b('0xf')](0x1f4,_0x28ba67[_0x6b7b('0x11')]));});});};