2d0c8261d16656180f345224a1c08a6c8909af20
[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 _0x14f5=['../../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','options','raw','where','attributes','limit','include','model','map','stringify','CreateMemberReport','create','body','UpdateMemberReport','util','bluebird','randomstring','ioredis','../../config/utils','../../config/logger'];(function(_0xaec2a3,_0x5973b9){var _0x56955a=function(_0x277b25){while(--_0x277b25){_0xaec2a3['push'](_0xaec2a3['shift']());}};_0x56955a(++_0x5973b9);}(_0x14f5,0xae));var _0x514f=function(_0x21c7e4,_0x2d61be){_0x21c7e4=_0x21c7e4-0x0;var _0x310cd2=_0x14f5[_0x21c7e4];return _0x310cd2;};'use strict';var _=require('lodash');var util=require(_0x514f('0x0'));var moment=require('moment');var BPromise=require(_0x514f('0x1'));var rs=require(_0x514f('0x2'));var fs=require('fs');var Redis=require(_0x514f('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x514f('0x4'));var logger=require(_0x514f('0x5'))('rpc');var config=require(_0x514f('0x6'));var jayson=require(_0x514f('0x7'));var client=jayson[_0x514f('0x8')][_0x514f('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x463985,_0x43ec42,_0xdb9614){return new BPromise(function(_0x4a5497,_0x203b02){return client['request'](_0x463985,_0xdb9614)[_0x514f('0xa')](function(_0x1e3fa7){logger[_0x514f('0xb')](_0x514f('0xc'),_0x43ec42,_0x514f('0xd'));logger[_0x514f('0xe')](_0x514f('0xf'),_0x43ec42,'request\x20sent',JSON['stringify'](_0x1e3fa7));if(_0x1e3fa7['error']){if(_0x1e3fa7[_0x514f('0x10')][_0x514f('0x11')]===0x1f4){logger[_0x514f('0x10')](_0x514f('0xc'),_0x43ec42,_0x1e3fa7[_0x514f('0x10')][_0x514f('0x12')]);return _0x203b02(_0x1e3fa7[_0x514f('0x10')][_0x514f('0x12')]);}logger[_0x514f('0x10')](_0x514f('0xc'),_0x43ec42,_0x1e3fa7[_0x514f('0x10')][_0x514f('0x12')]);return _0x4a5497(_0x1e3fa7[_0x514f('0x10')][_0x514f('0x12')]);}else{logger[_0x514f('0xb')]('MemberReport,\x20%s,\x20%s',_0x43ec42,_0x514f('0xd'));_0x4a5497(_0x1e3fa7[_0x514f('0x13')]['message']);}})[_0x514f('0x14')](function(_0x53851d){logger[_0x514f('0x10')](_0x514f('0xc'),_0x43ec42,_0x53851d);_0x203b02(_0x53851d);});});}exports[_0x514f('0x15')]=function(_0x5a5641){var _0x28e99a=this;return new Promise(function(_0x3673a4,_0x2cdd0d){return db[_0x514f('0x16')]['findAll']({'raw':_0x5a5641['options']?_0x5a5641[_0x514f('0x17')][_0x514f('0x18')]===undefined?!![]:![]:!![],'where':_0x5a5641[_0x514f('0x17')]?_0x5a5641['options'][_0x514f('0x19')]||null:null,'attributes':_0x5a5641[_0x514f('0x17')]?_0x5a5641['options'][_0x514f('0x1a')]||null:null,'limit':_0x5a5641[_0x514f('0x17')]?_0x5a5641['options'][_0x514f('0x1b')]||null:null,'include':_0x5a5641[_0x514f('0x17')]?_0x5a5641[_0x514f('0x17')][_0x514f('0x1c')]?_['map'](_0x5a5641['options']['include'],function(_0x5d80cb){return{'model':db[_0x5d80cb[_0x514f('0x1d')]],'as':_0x5d80cb['as'],'attributes':_0x5d80cb[_0x514f('0x1a')],'include':_0x5d80cb[_0x514f('0x1c')]?_[_0x514f('0x1e')](_0x5d80cb[_0x514f('0x1c')],function(_0x26df04){return{'model':db[_0x26df04[_0x514f('0x1d')]],'as':_0x26df04['as'],'attributes':_0x26df04[_0x514f('0x1a')],'include':_0x26df04[_0x514f('0x1c')]?_['map'](_0x26df04[_0x514f('0x1c')],function(_0x37b3db){return{'model':db[_0x37b3db[_0x514f('0x1d')]],'as':_0x37b3db['as'],'attributes':_0x37b3db[_0x514f('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x514f('0xa')](function(_0x32f3e1){logger[_0x514f('0xb')](_0x514f('0x15'),_0x5a5641);logger[_0x514f('0xe')]('GetMemberReport',_0x5a5641,JSON[_0x514f('0x1f')](_0x32f3e1));_0x3673a4(_0x32f3e1);})['catch'](function(_0x2b43e0){logger['error'](_0x514f('0x15'),_0x2b43e0[_0x514f('0x12')],_0x5a5641);_0x2cdd0d(_0x28e99a[_0x514f('0x10')](0x1f4,_0x2b43e0[_0x514f('0x12')]));});});};exports[_0x514f('0x20')]=function(_0x5d9017){var _0x56e83e=this;return new Promise(function(_0x3e788b,_0x5d564b){return db[_0x514f('0x16')][_0x514f('0x21')](_0x5d9017[_0x514f('0x22')],{'raw':_0x5d9017[_0x514f('0x17')]?_0x5d9017[_0x514f('0x17')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x5eee93){logger[_0x514f('0xb')](_0x514f('0x20'),_0x5d9017);logger[_0x514f('0xe')](_0x514f('0x20'),_0x5d9017,JSON[_0x514f('0x1f')](_0x5eee93));_0x3e788b(_0x5eee93);})[_0x514f('0x14')](function(_0x1cd65a){logger[_0x514f('0x10')](_0x514f('0x20'),_0x1cd65a[_0x514f('0x12')],_0x5d9017);_0x5d564b(_0x56e83e['error'](0x1f4,_0x1cd65a['message']));});});};exports['UpdateMemberReport']=function(_0x63d383){var _0x4e028b=this;return new Promise(function(_0x450d04,_0x50c120){return db[_0x514f('0x16')]['update'](_0x63d383['body'],{'raw':_0x63d383[_0x514f('0x17')]?_0x63d383['options'][_0x514f('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x63d383[_0x514f('0x17')]?_0x63d383[_0x514f('0x17')][_0x514f('0x19')]||null:null,'attributes':_0x63d383[_0x514f('0x17')]?_0x63d383['options'][_0x514f('0x1a')]||null:null,'limit':_0x63d383[_0x514f('0x17')]?_0x63d383[_0x514f('0x17')][_0x514f('0x1b')]||null:null})['then'](function(_0x196a2b){logger[_0x514f('0xb')](_0x514f('0x23'),_0x63d383);logger[_0x514f('0xe')]('UpdateMemberReport',_0x63d383,JSON[_0x514f('0x1f')](_0x196a2b));_0x450d04(_0x196a2b);})[_0x514f('0x14')](function(_0x420c77){logger[_0x514f('0x10')]('UpdateMemberReport',_0x420c77[_0x514f('0x12')],_0x63d383);_0x50c120(_0x4e028b['error'](0x1f4,_0x420c77[_0x514f('0x12')]));});});};