Built motion from commit d5e4af8c.|2.6.23
[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 _0x6c14=['findAll','raw','where','options','attributes','limit','include','map','model','catch','create','CreateMemberReport','UpdateMemberReport','body','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','then','info','request\x20sent','debug','MemberReport,\x20%s,\x20%s,\x20%s','stringify','error','code','MemberReport,\x20%s,\x20%s','message','result','GetMemberReport','MemberReport'];(function(_0x302d79,_0x4df472){var _0xa7c5b8=function(_0x753c08){while(--_0x753c08){_0x302d79['push'](_0x302d79['shift']());}};_0xa7c5b8(++_0x4df472);}(_0x6c14,0xd1));var _0x46c1=function(_0x360122,_0x3d1b8c){_0x360122=_0x360122-0x0;var _0x431219=_0x6c14[_0x360122];return _0x431219;};'use strict';var _=require(_0x46c1('0x0'));var util=require(_0x46c1('0x1'));var moment=require(_0x46c1('0x2'));var BPromise=require(_0x46c1('0x3'));var rs=require(_0x46c1('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x46c1('0x5'))['db'];var utils=require(_0x46c1('0x6'));var logger=require(_0x46c1('0x7'))('rpc');var config=require(_0x46c1('0x8'));var jayson=require(_0x46c1('0x9'));var client=jayson[_0x46c1('0xa')][_0x46c1('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x29b2d8,_0x10b22d,_0xfaf798){return new BPromise(function(_0x1277f7,_0x2997e1){return client['request'](_0x29b2d8,_0xfaf798)[_0x46c1('0xc')](function(_0x5f5b75){logger[_0x46c1('0xd')]('MemberReport,\x20%s,\x20%s',_0x10b22d,_0x46c1('0xe'));logger[_0x46c1('0xf')](_0x46c1('0x10'),_0x10b22d,'request\x20sent',JSON[_0x46c1('0x11')](_0x5f5b75));if(_0x5f5b75[_0x46c1('0x12')]){if(_0x5f5b75[_0x46c1('0x12')][_0x46c1('0x13')]===0x1f4){logger['error'](_0x46c1('0x14'),_0x10b22d,_0x5f5b75[_0x46c1('0x12')]['message']);return _0x2997e1(_0x5f5b75['error'][_0x46c1('0x15')]);}logger[_0x46c1('0x12')](_0x46c1('0x14'),_0x10b22d,_0x5f5b75[_0x46c1('0x12')][_0x46c1('0x15')]);return _0x1277f7(_0x5f5b75['error'][_0x46c1('0x15')]);}else{logger[_0x46c1('0xd')](_0x46c1('0x14'),_0x10b22d,_0x46c1('0xe'));_0x1277f7(_0x5f5b75[_0x46c1('0x16')]['message']);}})['catch'](function(_0x23e912){logger[_0x46c1('0x12')](_0x46c1('0x14'),_0x10b22d,_0x23e912);_0x2997e1(_0x23e912);});});}exports[_0x46c1('0x17')]=function(_0x466899){var _0xae104a=this;return new Promise(function(_0x2ec920,_0x4c42b8){return db[_0x46c1('0x18')][_0x46c1('0x19')]({'raw':_0x466899['options']?_0x466899['options'][_0x46c1('0x1a')]===undefined?!![]:![]:!![],'where':_0x466899['options']?_0x466899['options'][_0x46c1('0x1b')]||null:null,'attributes':_0x466899[_0x46c1('0x1c')]?_0x466899[_0x46c1('0x1c')][_0x46c1('0x1d')]||null:null,'limit':_0x466899[_0x46c1('0x1c')]?_0x466899[_0x46c1('0x1c')][_0x46c1('0x1e')]||null:null,'include':_0x466899[_0x46c1('0x1c')]?_0x466899[_0x46c1('0x1c')][_0x46c1('0x1f')]?_[_0x46c1('0x20')](_0x466899[_0x46c1('0x1c')][_0x46c1('0x1f')],function(_0x712eb8){return{'model':db[_0x712eb8[_0x46c1('0x21')]],'as':_0x712eb8['as'],'attributes':_0x712eb8[_0x46c1('0x1d')],'include':_0x712eb8[_0x46c1('0x1f')]?_[_0x46c1('0x20')](_0x712eb8[_0x46c1('0x1f')],function(_0x361c66){return{'model':db[_0x361c66[_0x46c1('0x21')]],'as':_0x361c66['as'],'attributes':_0x361c66[_0x46c1('0x1d')],'include':_0x361c66[_0x46c1('0x1f')]?_['map'](_0x361c66['include'],function(_0xa8b66e){return{'model':db[_0xa8b66e[_0x46c1('0x21')]],'as':_0xa8b66e['as'],'attributes':_0xa8b66e['attributes']};}):[]};}):[]};}):[]:[]})[_0x46c1('0xc')](function(_0xe710e8){logger[_0x46c1('0xd')](_0x46c1('0x17'),_0x466899);logger[_0x46c1('0xf')](_0x46c1('0x17'),_0x466899,JSON['stringify'](_0xe710e8));_0x2ec920(_0xe710e8);})[_0x46c1('0x22')](function(_0x4475f7){logger[_0x46c1('0x12')](_0x46c1('0x17'),_0x4475f7[_0x46c1('0x15')],_0x466899);_0x4c42b8(_0xae104a[_0x46c1('0x12')](0x1f4,_0x4475f7[_0x46c1('0x15')]));});});};exports['CreateMemberReport']=function(_0xb33e57){var _0x5448f4=this;return new Promise(function(_0x18072d,_0x1a3c5a){return db[_0x46c1('0x18')][_0x46c1('0x23')](_0xb33e57['body'],{'raw':_0xb33e57['options']?_0xb33e57[_0x46c1('0x1c')][_0x46c1('0x1a')]===undefined?!![]:![]:!![]})['then'](function(_0x666a49){logger[_0x46c1('0xd')](_0x46c1('0x24'),_0xb33e57);logger[_0x46c1('0xf')]('CreateMemberReport',_0xb33e57,JSON[_0x46c1('0x11')](_0x666a49));_0x18072d(_0x666a49);})[_0x46c1('0x22')](function(_0x5d5074){logger[_0x46c1('0x12')]('CreateMemberReport',_0x5d5074[_0x46c1('0x15')],_0xb33e57);_0x1a3c5a(_0x5448f4[_0x46c1('0x12')](0x1f4,_0x5d5074[_0x46c1('0x15')]));});});};exports[_0x46c1('0x25')]=function(_0x2a7212){var _0xccf843=this;return new Promise(function(_0x4e2b14,_0x50e68c){return db[_0x46c1('0x18')]['update'](_0x2a7212[_0x46c1('0x26')],{'raw':_0x2a7212['options']?_0x2a7212['options'][_0x46c1('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2a7212[_0x46c1('0x1c')]?_0x2a7212[_0x46c1('0x1c')]['where']||null:null,'attributes':_0x2a7212[_0x46c1('0x1c')]?_0x2a7212[_0x46c1('0x1c')][_0x46c1('0x1d')]||null:null,'limit':_0x2a7212['options']?_0x2a7212[_0x46c1('0x1c')][_0x46c1('0x1e')]||null:null})[_0x46c1('0xc')](function(_0x20f23d){logger[_0x46c1('0xd')](_0x46c1('0x25'),_0x2a7212);logger[_0x46c1('0xf')](_0x46c1('0x25'),_0x2a7212,JSON[_0x46c1('0x11')](_0x20f23d));_0x4e2b14(_0x20f23d);})['catch'](function(_0xcb59ca){logger[_0x46c1('0x12')](_0x46c1('0x25'),_0xcb59ca[_0x46c1('0x15')],_0x2a7212);_0x50e68c(_0xccf843[_0x46c1('0x12')](0x1f4,_0xcb59ca[_0x46c1('0x15')]));});});};