4153a2f4471361b6786f6a6dc0cabf73a0e0afdc
[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 _0xab36=['where','include','map','model','attributes','stringify','CreateMemberReport','create','body','UpdateMemberReport','update','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','then','info','MemberReport,\x20%s,\x20%s','request\x20sent','debug','MemberReport,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','GetMemberReport','MemberReport','findAll','options','raw'];(function(_0x5426b3,_0x5f38d6){var _0x3746c3=function(_0x19cdc9){while(--_0x19cdc9){_0x5426b3['push'](_0x5426b3['shift']());}};_0x3746c3(++_0x5f38d6);}(_0xab36,0x1df));var _0x6ab3=function(_0xc34e70,_0x559d04){_0xc34e70=_0xc34e70-0x0;var _0x2c000e=_0xab36[_0xc34e70];return _0x2c000e;};'use strict';var _=require(_0x6ab3('0x0'));var util=require(_0x6ab3('0x1'));var moment=require(_0x6ab3('0x2'));var BPromise=require(_0x6ab3('0x3'));var rs=require(_0x6ab3('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x6ab3('0x5'))['db'];var utils=require(_0x6ab3('0x6'));var logger=require(_0x6ab3('0x7'))('rpc');var config=require(_0x6ab3('0x8'));var jayson=require(_0x6ab3('0x9'));var client=jayson[_0x6ab3('0xa')][_0x6ab3('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x33fc2a,_0x416eb2,_0x4ba5e3){return new BPromise(function(_0x2a9076,_0x1a795a){return client['request'](_0x33fc2a,_0x4ba5e3)[_0x6ab3('0xc')](function(_0x4b05d5){logger[_0x6ab3('0xd')](_0x6ab3('0xe'),_0x416eb2,_0x6ab3('0xf'));logger[_0x6ab3('0x10')](_0x6ab3('0x11'),_0x416eb2,_0x6ab3('0xf'),JSON['stringify'](_0x4b05d5));if(_0x4b05d5[_0x6ab3('0x12')]){if(_0x4b05d5['error'][_0x6ab3('0x13')]===0x1f4){logger[_0x6ab3('0x12')](_0x6ab3('0xe'),_0x416eb2,_0x4b05d5[_0x6ab3('0x12')][_0x6ab3('0x14')]);return _0x1a795a(_0x4b05d5['error'][_0x6ab3('0x14')]);}logger[_0x6ab3('0x12')](_0x6ab3('0xe'),_0x416eb2,_0x4b05d5[_0x6ab3('0x12')][_0x6ab3('0x14')]);return _0x2a9076(_0x4b05d5['error'][_0x6ab3('0x14')]);}else{logger['info'](_0x6ab3('0xe'),_0x416eb2,_0x6ab3('0xf'));_0x2a9076(_0x4b05d5[_0x6ab3('0x15')][_0x6ab3('0x14')]);}})[_0x6ab3('0x16')](function(_0x32dd54){logger[_0x6ab3('0x12')](_0x6ab3('0xe'),_0x416eb2,_0x32dd54);_0x1a795a(_0x32dd54);});});}exports[_0x6ab3('0x17')]=function(_0x586dcb){var _0x99ef3d=this;return new Promise(function(_0x5db46c,_0x8af982){return db[_0x6ab3('0x18')][_0x6ab3('0x19')]({'raw':_0x586dcb[_0x6ab3('0x1a')]?_0x586dcb[_0x6ab3('0x1a')][_0x6ab3('0x1b')]===undefined?!![]:![]:!![],'where':_0x586dcb[_0x6ab3('0x1a')]?_0x586dcb['options'][_0x6ab3('0x1c')]||null:null,'attributes':_0x586dcb[_0x6ab3('0x1a')]?_0x586dcb[_0x6ab3('0x1a')]['attributes']||null:null,'limit':_0x586dcb[_0x6ab3('0x1a')]?_0x586dcb['options']['limit']||null:null,'include':_0x586dcb[_0x6ab3('0x1a')]?_0x586dcb['options'][_0x6ab3('0x1d')]?_[_0x6ab3('0x1e')](_0x586dcb[_0x6ab3('0x1a')][_0x6ab3('0x1d')],function(_0x344e9f){return{'model':db[_0x344e9f[_0x6ab3('0x1f')]],'as':_0x344e9f['as'],'attributes':_0x344e9f[_0x6ab3('0x20')],'include':_0x344e9f[_0x6ab3('0x1d')]?_[_0x6ab3('0x1e')](_0x344e9f[_0x6ab3('0x1d')],function(_0x16cfb2){return{'model':db[_0x16cfb2[_0x6ab3('0x1f')]],'as':_0x16cfb2['as'],'attributes':_0x16cfb2[_0x6ab3('0x20')],'include':_0x16cfb2[_0x6ab3('0x1d')]?_['map'](_0x16cfb2[_0x6ab3('0x1d')],function(_0x554cf0){return{'model':db[_0x554cf0[_0x6ab3('0x1f')]],'as':_0x554cf0['as'],'attributes':_0x554cf0[_0x6ab3('0x20')]};}):[]};}):[]};}):[]:[]})[_0x6ab3('0xc')](function(_0x2c5692){logger[_0x6ab3('0xd')](_0x6ab3('0x17'),_0x586dcb);logger['debug']('GetMemberReport',_0x586dcb,JSON[_0x6ab3('0x21')](_0x2c5692));_0x5db46c(_0x2c5692);})['catch'](function(_0x5370d7){logger[_0x6ab3('0x12')](_0x6ab3('0x17'),_0x5370d7[_0x6ab3('0x14')],_0x586dcb);_0x8af982(_0x99ef3d[_0x6ab3('0x12')](0x1f4,_0x5370d7[_0x6ab3('0x14')]));});});};exports[_0x6ab3('0x22')]=function(_0x345b14){var _0x376e4f=this;return new Promise(function(_0x5d109e,_0x340a6d){return db[_0x6ab3('0x18')][_0x6ab3('0x23')](_0x345b14[_0x6ab3('0x24')],{'raw':_0x345b14[_0x6ab3('0x1a')]?_0x345b14[_0x6ab3('0x1a')][_0x6ab3('0x1b')]===undefined?!![]:![]:!![]})[_0x6ab3('0xc')](function(_0x5c7b3e){logger[_0x6ab3('0xd')]('CreateMemberReport',_0x345b14);logger['debug'](_0x6ab3('0x22'),_0x345b14,JSON['stringify'](_0x5c7b3e));_0x5d109e(_0x5c7b3e);})[_0x6ab3('0x16')](function(_0xec01b7){logger[_0x6ab3('0x12')](_0x6ab3('0x22'),_0xec01b7[_0x6ab3('0x14')],_0x345b14);_0x340a6d(_0x376e4f[_0x6ab3('0x12')](0x1f4,_0xec01b7[_0x6ab3('0x14')]));});});};exports[_0x6ab3('0x25')]=function(_0x1e24f7){var _0x1ff824=this;return new Promise(function(_0x4a4737,_0x22e39a){return db[_0x6ab3('0x18')][_0x6ab3('0x26')](_0x1e24f7['body'],{'raw':_0x1e24f7[_0x6ab3('0x1a')]?_0x1e24f7[_0x6ab3('0x1a')][_0x6ab3('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1e24f7[_0x6ab3('0x1a')]?_0x1e24f7[_0x6ab3('0x1a')][_0x6ab3('0x1c')]||null:null,'attributes':_0x1e24f7['options']?_0x1e24f7[_0x6ab3('0x1a')]['attributes']||null:null,'limit':_0x1e24f7[_0x6ab3('0x1a')]?_0x1e24f7[_0x6ab3('0x1a')]['limit']||null:null})[_0x6ab3('0xc')](function(_0x33c9dc){logger['info']('UpdateMemberReport',_0x1e24f7);logger[_0x6ab3('0x10')]('UpdateMemberReport',_0x1e24f7,JSON[_0x6ab3('0x21')](_0x33c9dc));_0x4a4737(_0x33c9dc);})[_0x6ab3('0x16')](function(_0x571a4c){logger['error'](_0x6ab3('0x25'),_0x571a4c[_0x6ab3('0x14')],_0x1e24f7);_0x22e39a(_0x1ff824['error'](0x1f4,_0x571a4c['message']));});});};