75e2527ef4d2c8ca373db7c4514fbcfe9b7cfe31
[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 _0x4c60=['message','info','catch','GetMemberReport','MemberReport','findAll','options','attributes','limit','map','include','model','create','raw','CreateMemberReport','UpdateMemberReport','update','body','lodash','util','moment','bluebird','ioredis','../../config/environment','jayson/promise','client','http','request','then','debug','request\x20sent','stringify','error','code','MemberReport,\x20%s,\x20%s'];(function(_0x40a045,_0x516f0e){var _0x1a687c=function(_0x48c9fe){while(--_0x48c9fe){_0x40a045['push'](_0x40a045['shift']());}};_0x1a687c(++_0x516f0e);}(_0x4c60,0xc1));var _0x04c6=function(_0x23f929,_0x2f68dc){_0x23f929=_0x23f929-0x0;var _0x314cd9=_0x4c60[_0x23f929];return _0x314cd9;};'use strict';var _=require(_0x04c6('0x0'));var util=require(_0x04c6('0x1'));var moment=require(_0x04c6('0x2'));var BPromise=require(_0x04c6('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x04c6('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0x04c6('0x5'));var jayson=require(_0x04c6('0x6'));var client=jayson[_0x04c6('0x7')][_0x04c6('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x2b9041,_0x39be2d,_0x8f9b13){return new BPromise(function(_0x530a48,_0x2a4b51){return client[_0x04c6('0x9')](_0x2b9041,_0x8f9b13)[_0x04c6('0xa')](function(_0x30b901){logger['info']('MemberReport,\x20%s,\x20%s',_0x39be2d,'request\x20sent');logger[_0x04c6('0xb')]('MemberReport,\x20%s,\x20%s,\x20%s',_0x39be2d,_0x04c6('0xc'),JSON[_0x04c6('0xd')](_0x30b901));if(_0x30b901['error']){if(_0x30b901[_0x04c6('0xe')][_0x04c6('0xf')]===0x1f4){logger[_0x04c6('0xe')](_0x04c6('0x10'),_0x39be2d,_0x30b901['error'][_0x04c6('0x11')]);return _0x2a4b51(_0x30b901[_0x04c6('0xe')][_0x04c6('0x11')]);}logger['error'](_0x04c6('0x10'),_0x39be2d,_0x30b901[_0x04c6('0xe')][_0x04c6('0x11')]);return _0x530a48(_0x30b901[_0x04c6('0xe')][_0x04c6('0x11')]);}else{logger[_0x04c6('0x12')](_0x04c6('0x10'),_0x39be2d,_0x04c6('0xc'));_0x530a48(_0x30b901['result'][_0x04c6('0x11')]);}})[_0x04c6('0x13')](function(_0x382e58){logger[_0x04c6('0xe')](_0x04c6('0x10'),_0x39be2d,_0x382e58);_0x2a4b51(_0x382e58);});});}exports[_0x04c6('0x14')]=function(_0x21674a){var _0x423ea9=this;return new Promise(function(_0x47f400,_0x142065){return db[_0x04c6('0x15')][_0x04c6('0x16')]({'raw':_0x21674a['options']?_0x21674a['options']['raw']===undefined?!![]:![]:!![],'where':_0x21674a[_0x04c6('0x17')]?_0x21674a[_0x04c6('0x17')]['where']||null:null,'attributes':_0x21674a['options']?_0x21674a[_0x04c6('0x17')][_0x04c6('0x18')]||null:null,'limit':_0x21674a[_0x04c6('0x17')]?_0x21674a['options'][_0x04c6('0x19')]||null:null,'include':_0x21674a[_0x04c6('0x17')]?_0x21674a[_0x04c6('0x17')]['include']?_[_0x04c6('0x1a')](_0x21674a[_0x04c6('0x17')]['include'],function(_0x54a8b0){return{'model':db[_0x54a8b0['model']],'as':_0x54a8b0['as'],'attributes':_0x54a8b0[_0x04c6('0x18')],'include':_0x54a8b0[_0x04c6('0x1b')]?_[_0x04c6('0x1a')](_0x54a8b0[_0x04c6('0x1b')],function(_0x3e1328){return{'model':db[_0x3e1328['model']],'as':_0x3e1328['as'],'attributes':_0x3e1328['attributes'],'include':_0x3e1328[_0x04c6('0x1b')]?_[_0x04c6('0x1a')](_0x3e1328[_0x04c6('0x1b')],function(_0x3233d7){return{'model':db[_0x3233d7[_0x04c6('0x1c')]],'as':_0x3233d7['as'],'attributes':_0x3233d7[_0x04c6('0x18')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1d0d3f){logger[_0x04c6('0x12')]('GetMemberReport',_0x21674a);logger[_0x04c6('0xb')](_0x04c6('0x14'),_0x21674a,JSON['stringify'](_0x1d0d3f));_0x47f400(_0x1d0d3f);})['catch'](function(_0x115d84){logger[_0x04c6('0xe')](_0x04c6('0x14'),_0x115d84[_0x04c6('0x11')],_0x21674a);_0x142065(_0x423ea9[_0x04c6('0xe')](0x1f4,_0x115d84[_0x04c6('0x11')]));});});};exports['CreateMemberReport']=function(_0x5d8c88){var _0x4fd842=this;return new Promise(function(_0x375a03,_0x5241b5){return db[_0x04c6('0x15')][_0x04c6('0x1d')](_0x5d8c88['body'],{'raw':_0x5d8c88[_0x04c6('0x17')]?_0x5d8c88[_0x04c6('0x17')][_0x04c6('0x1e')]===undefined?!![]:![]:!![]})[_0x04c6('0xa')](function(_0x5b2056){logger[_0x04c6('0x12')](_0x04c6('0x1f'),_0x5d8c88);logger[_0x04c6('0xb')](_0x04c6('0x1f'),_0x5d8c88,JSON[_0x04c6('0xd')](_0x5b2056));_0x375a03(_0x5b2056);})[_0x04c6('0x13')](function(_0x3e59b2){logger[_0x04c6('0xe')](_0x04c6('0x1f'),_0x3e59b2[_0x04c6('0x11')],_0x5d8c88);_0x5241b5(_0x4fd842[_0x04c6('0xe')](0x1f4,_0x3e59b2[_0x04c6('0x11')]));});});};exports[_0x04c6('0x20')]=function(_0x3d56ea){var _0x209f88=this;return new Promise(function(_0x5bb584,_0x5cc26c){return db[_0x04c6('0x15')][_0x04c6('0x21')](_0x3d56ea[_0x04c6('0x22')],{'raw':_0x3d56ea['options']?_0x3d56ea[_0x04c6('0x17')][_0x04c6('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3d56ea['options']?_0x3d56ea['options']['where']||null:null,'attributes':_0x3d56ea[_0x04c6('0x17')]?_0x3d56ea[_0x04c6('0x17')]['attributes']||null:null,'limit':_0x3d56ea[_0x04c6('0x17')]?_0x3d56ea['options'][_0x04c6('0x19')]||null:null})[_0x04c6('0xa')](function(_0x3806ea){logger[_0x04c6('0x12')]('UpdateMemberReport',_0x3d56ea);logger['debug'](_0x04c6('0x20'),_0x3d56ea,JSON[_0x04c6('0xd')](_0x3806ea));_0x5bb584(_0x3806ea);})['catch'](function(_0x3f4fad){logger['error']('UpdateMemberReport',_0x3f4fad[_0x04c6('0x11')],_0x3d56ea);_0x5cc26c(_0x209f88['error'](0x1f4,_0x3f4fad[_0x04c6('0x11')]));});});};