dfd7e72d091abb3dc628fa01edd21cc8c42184d2
[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 _0xf80b=['request\x20sent','stringify','error','code','message','result','catch','GetMemberReport','findAll','options','raw','where','attributes','map','include','model','info','CreateMemberReport','MemberReport','body','debug','UpdateMemberReport','update','lodash','moment','bluebird','ioredis','../../config/utils','rpc','../../config/environment','client','http','request','then','MemberReport,\x20%s,\x20%s'];(function(_0x117e52,_0x2a686c){var _0x225734=function(_0x5abb36){while(--_0x5abb36){_0x117e52['push'](_0x117e52['shift']());}};_0x225734(++_0x2a686c);}(_0xf80b,0x198));var _0xbf80=function(_0x41681a,_0x3270fa){_0x41681a=_0x41681a-0x0;var _0x5e07ab=_0xf80b[_0x41681a];return _0x5e07ab;};'use strict';var _=require(_0xbf80('0x0'));var util=require('util');var moment=require(_0xbf80('0x1'));var BPromise=require(_0xbf80('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xbf80('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0xbf80('0x4'));var logger=require('../../config/logger')(_0xbf80('0x5'));var config=require(_0xbf80('0x6'));var jayson=require('jayson/promise');var client=jayson[_0xbf80('0x7')][_0xbf80('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x5313a4,_0x1b4d2c,_0x13e384){return new BPromise(function(_0xbc2a18,_0x5eeb90){return client[_0xbf80('0x9')](_0x5313a4,_0x13e384)[_0xbf80('0xa')](function(_0x4c99a4){logger['info'](_0xbf80('0xb'),_0x1b4d2c,_0xbf80('0xc'));logger['debug']('MemberReport,\x20%s,\x20%s,\x20%s',_0x1b4d2c,'request\x20sent',JSON[_0xbf80('0xd')](_0x4c99a4));if(_0x4c99a4[_0xbf80('0xe')]){if(_0x4c99a4[_0xbf80('0xe')][_0xbf80('0xf')]===0x1f4){logger[_0xbf80('0xe')](_0xbf80('0xb'),_0x1b4d2c,_0x4c99a4[_0xbf80('0xe')][_0xbf80('0x10')]);return _0x5eeb90(_0x4c99a4[_0xbf80('0xe')]['message']);}logger['error'](_0xbf80('0xb'),_0x1b4d2c,_0x4c99a4[_0xbf80('0xe')]['message']);return _0xbc2a18(_0x4c99a4[_0xbf80('0xe')]['message']);}else{logger['info'](_0xbf80('0xb'),_0x1b4d2c,_0xbf80('0xc'));_0xbc2a18(_0x4c99a4[_0xbf80('0x11')]['message']);}})[_0xbf80('0x12')](function(_0x545769){logger[_0xbf80('0xe')](_0xbf80('0xb'),_0x1b4d2c,_0x545769);_0x5eeb90(_0x545769);});});}exports[_0xbf80('0x13')]=function(_0x63bef0){var _0xa33163=this;return new Promise(function(_0x4a86f6,_0x26facd){return db['MemberReport'][_0xbf80('0x14')]({'raw':_0x63bef0[_0xbf80('0x15')]?_0x63bef0['options'][_0xbf80('0x16')]===undefined?!![]:![]:!![],'where':_0x63bef0['options']?_0x63bef0[_0xbf80('0x15')][_0xbf80('0x17')]||null:null,'attributes':_0x63bef0[_0xbf80('0x15')]?_0x63bef0[_0xbf80('0x15')][_0xbf80('0x18')]||null:null,'limit':_0x63bef0[_0xbf80('0x15')]?_0x63bef0['options']['limit']||null:null,'include':_0x63bef0[_0xbf80('0x15')]?_0x63bef0['options']['include']?_[_0xbf80('0x19')](_0x63bef0[_0xbf80('0x15')][_0xbf80('0x1a')],function(_0x4eafaa){return{'model':db[_0x4eafaa[_0xbf80('0x1b')]],'as':_0x4eafaa['as'],'attributes':_0x4eafaa[_0xbf80('0x18')],'include':_0x4eafaa[_0xbf80('0x1a')]?_[_0xbf80('0x19')](_0x4eafaa[_0xbf80('0x1a')],function(_0x1e14d7){return{'model':db[_0x1e14d7[_0xbf80('0x1b')]],'as':_0x1e14d7['as'],'attributes':_0x1e14d7[_0xbf80('0x18')],'include':_0x1e14d7['include']?_[_0xbf80('0x19')](_0x1e14d7[_0xbf80('0x1a')],function(_0x1c0a79){return{'model':db[_0x1c0a79['model']],'as':_0x1c0a79['as'],'attributes':_0x1c0a79[_0xbf80('0x18')]};}):[]};}):[]};}):[]:[]})[_0xbf80('0xa')](function(_0x44af70){logger[_0xbf80('0x1c')](_0xbf80('0x13'),_0x63bef0);logger['debug'](_0xbf80('0x13'),_0x63bef0,JSON[_0xbf80('0xd')](_0x44af70));_0x4a86f6(_0x44af70);})['catch'](function(_0x1f8ada){logger[_0xbf80('0xe')](_0xbf80('0x13'),_0x1f8ada[_0xbf80('0x10')],_0x63bef0);_0x26facd(_0xa33163[_0xbf80('0xe')](0x1f4,_0x1f8ada[_0xbf80('0x10')]));});});};exports[_0xbf80('0x1d')]=function(_0x156e40){var _0x36ae2d=this;return new Promise(function(_0x4433c4,_0x57224a){return db[_0xbf80('0x1e')]['create'](_0x156e40[_0xbf80('0x1f')],{'raw':_0x156e40['options']?_0x156e40[_0xbf80('0x15')][_0xbf80('0x16')]===undefined?!![]:![]:!![]})[_0xbf80('0xa')](function(_0x543fa8){logger[_0xbf80('0x1c')]('CreateMemberReport',_0x156e40);logger[_0xbf80('0x20')](_0xbf80('0x1d'),_0x156e40,JSON[_0xbf80('0xd')](_0x543fa8));_0x4433c4(_0x543fa8);})[_0xbf80('0x12')](function(_0x5c648d){logger['error']('CreateMemberReport',_0x5c648d[_0xbf80('0x10')],_0x156e40);_0x57224a(_0x36ae2d[_0xbf80('0xe')](0x1f4,_0x5c648d['message']));});});};exports[_0xbf80('0x21')]=function(_0x159513){var _0x47c7e0=this;return new Promise(function(_0x500e33,_0xba34e8){return db[_0xbf80('0x1e')][_0xbf80('0x22')](_0x159513[_0xbf80('0x1f')],{'raw':_0x159513[_0xbf80('0x15')]?_0x159513[_0xbf80('0x15')][_0xbf80('0x16')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x159513[_0xbf80('0x15')]?_0x159513[_0xbf80('0x15')][_0xbf80('0x17')]||null:null,'attributes':_0x159513[_0xbf80('0x15')]?_0x159513[_0xbf80('0x15')][_0xbf80('0x18')]||null:null,'limit':_0x159513[_0xbf80('0x15')]?_0x159513[_0xbf80('0x15')]['limit']||null:null})[_0xbf80('0xa')](function(_0x185e7c){logger[_0xbf80('0x1c')](_0xbf80('0x21'),_0x159513);logger[_0xbf80('0x20')]('UpdateMemberReport',_0x159513,JSON[_0xbf80('0xd')](_0x185e7c));_0x500e33(_0x185e7c);})['catch'](function(_0x4ae67d){logger[_0xbf80('0xe')](_0xbf80('0x21'),_0x4ae67d['message'],_0x159513);_0xba34e8(_0x47c7e0[_0xbf80('0xe')](0x1f4,_0x4ae67d['message']));});});};