Built motion from commit (unavailable).|2.5.11
[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 _0x3ad4=['include','model','attributes','catch','CreateMemberReport','create','body','UpdateMemberReport','update','debug','lodash','util','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','client','http','request','then','MemberReport,\x20%s,\x20%s','request\x20sent','MemberReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','GetMemberReport','MemberReport','findAll','options','raw','where','limit','map'];(function(_0x36ed48,_0x1ee0d4){var _0x51c63a=function(_0x2d0a40){while(--_0x2d0a40){_0x36ed48['push'](_0x36ed48['shift']());}};_0x51c63a(++_0x1ee0d4);}(_0x3ad4,0xee));var _0x43ad=function(_0x2290ae,_0xbbbf35){_0x2290ae=_0x2290ae-0x0;var _0x38bdd0=_0x3ad4[_0x2290ae];return _0x38bdd0;};'use strict';var _=require(_0x43ad('0x0'));var util=require(_0x43ad('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x43ad('0x2'));var fs=require('fs');var Redis=require(_0x43ad('0x3'));var db=require(_0x43ad('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x43ad('0x5'));var config=require(_0x43ad('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x43ad('0x7')][_0x43ad('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x5ba324,_0x1b03ad,_0x170a12){return new BPromise(function(_0x192304,_0x2789fe){return client[_0x43ad('0x9')](_0x5ba324,_0x170a12)[_0x43ad('0xa')](function(_0x2a7ca8){logger['info'](_0x43ad('0xb'),_0x1b03ad,_0x43ad('0xc'));logger['debug'](_0x43ad('0xd'),_0x1b03ad,'request\x20sent',JSON[_0x43ad('0xe')](_0x2a7ca8));if(_0x2a7ca8[_0x43ad('0xf')]){if(_0x2a7ca8[_0x43ad('0xf')][_0x43ad('0x10')]===0x1f4){logger[_0x43ad('0xf')]('MemberReport,\x20%s,\x20%s',_0x1b03ad,_0x2a7ca8[_0x43ad('0xf')][_0x43ad('0x11')]);return _0x2789fe(_0x2a7ca8[_0x43ad('0xf')][_0x43ad('0x11')]);}logger[_0x43ad('0xf')](_0x43ad('0xb'),_0x1b03ad,_0x2a7ca8[_0x43ad('0xf')]['message']);return _0x192304(_0x2a7ca8[_0x43ad('0xf')]['message']);}else{logger[_0x43ad('0x12')](_0x43ad('0xb'),_0x1b03ad,_0x43ad('0xc'));_0x192304(_0x2a7ca8[_0x43ad('0x13')][_0x43ad('0x11')]);}})['catch'](function(_0x439db9){logger[_0x43ad('0xf')]('MemberReport,\x20%s,\x20%s',_0x1b03ad,_0x439db9);_0x2789fe(_0x439db9);});});}exports[_0x43ad('0x14')]=function(_0x2e4795){var _0x4c2723=this;return new Promise(function(_0x5a3856,_0xea6f8d){return db[_0x43ad('0x15')][_0x43ad('0x16')]({'raw':_0x2e4795[_0x43ad('0x17')]?_0x2e4795[_0x43ad('0x17')][_0x43ad('0x18')]===undefined?!![]:![]:!![],'where':_0x2e4795[_0x43ad('0x17')]?_0x2e4795['options'][_0x43ad('0x19')]||null:null,'attributes':_0x2e4795[_0x43ad('0x17')]?_0x2e4795[_0x43ad('0x17')]['attributes']||null:null,'limit':_0x2e4795['options']?_0x2e4795['options'][_0x43ad('0x1a')]||null:null,'include':_0x2e4795[_0x43ad('0x17')]?_0x2e4795[_0x43ad('0x17')]['include']?_[_0x43ad('0x1b')](_0x2e4795[_0x43ad('0x17')][_0x43ad('0x1c')],function(_0x360ba7){return{'model':db[_0x360ba7['model']],'as':_0x360ba7['as'],'attributes':_0x360ba7['attributes'],'include':_0x360ba7[_0x43ad('0x1c')]?_[_0x43ad('0x1b')](_0x360ba7[_0x43ad('0x1c')],function(_0x3061c2){return{'model':db[_0x3061c2[_0x43ad('0x1d')]],'as':_0x3061c2['as'],'attributes':_0x3061c2[_0x43ad('0x1e')],'include':_0x3061c2[_0x43ad('0x1c')]?_[_0x43ad('0x1b')](_0x3061c2[_0x43ad('0x1c')],function(_0x1f858f){return{'model':db[_0x1f858f[_0x43ad('0x1d')]],'as':_0x1f858f['as'],'attributes':_0x1f858f[_0x43ad('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x43ad('0xa')](function(_0x5e05cc){logger[_0x43ad('0x12')](_0x43ad('0x14'),_0x2e4795);logger['debug'](_0x43ad('0x14'),_0x2e4795,JSON['stringify'](_0x5e05cc));_0x5a3856(_0x5e05cc);})[_0x43ad('0x1f')](function(_0x2002c7){logger[_0x43ad('0xf')](_0x43ad('0x14'),_0x2002c7[_0x43ad('0x11')],_0x2e4795);_0xea6f8d(_0x4c2723[_0x43ad('0xf')](0x1f4,_0x2002c7[_0x43ad('0x11')]));});});};exports[_0x43ad('0x20')]=function(_0x3635c7){var _0x37d413=this;return new Promise(function(_0x4eebe6,_0x14abd2){return db['MemberReport'][_0x43ad('0x21')](_0x3635c7[_0x43ad('0x22')],{'raw':_0x3635c7[_0x43ad('0x17')]?_0x3635c7[_0x43ad('0x17')][_0x43ad('0x18')]===undefined?!![]:![]:!![]})['then'](function(_0x59cd02){logger[_0x43ad('0x12')](_0x43ad('0x20'),_0x3635c7);logger['debug'](_0x43ad('0x20'),_0x3635c7,JSON[_0x43ad('0xe')](_0x59cd02));_0x4eebe6(_0x59cd02);})[_0x43ad('0x1f')](function(_0x17f9d2){logger[_0x43ad('0xf')](_0x43ad('0x20'),_0x17f9d2[_0x43ad('0x11')],_0x3635c7);_0x14abd2(_0x37d413['error'](0x1f4,_0x17f9d2['message']));});});};exports[_0x43ad('0x23')]=function(_0x5efa51){var _0x117d45=this;return new Promise(function(_0x581516,_0x579879){return db[_0x43ad('0x15')][_0x43ad('0x24')](_0x5efa51[_0x43ad('0x22')],{'raw':_0x5efa51[_0x43ad('0x17')]?_0x5efa51[_0x43ad('0x17')][_0x43ad('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5efa51[_0x43ad('0x17')]?_0x5efa51[_0x43ad('0x17')][_0x43ad('0x19')]||null:null,'attributes':_0x5efa51['options']?_0x5efa51[_0x43ad('0x17')]['attributes']||null:null,'limit':_0x5efa51[_0x43ad('0x17')]?_0x5efa51[_0x43ad('0x17')][_0x43ad('0x1a')]||null:null})['then'](function(_0x4aa589){logger[_0x43ad('0x12')]('UpdateMemberReport',_0x5efa51);logger[_0x43ad('0x25')](_0x43ad('0x23'),_0x5efa51,JSON[_0x43ad('0xe')](_0x4aa589));_0x581516(_0x4aa589);})['catch'](function(_0x59d5d1){logger[_0x43ad('0xf')]('UpdateMemberReport',_0x59d5d1[_0x43ad('0x11')],_0x5efa51);_0x579879(_0x117d45['error'](0x1f4,_0x59d5d1[_0x43ad('0x11')]));});});};