Built motion from commit 19a84241.|2.5.34
[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 _0x1115=['model','GetMemberReport','debug','catch','CreateMemberReport','create','body','UpdateMemberReport','update','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','client','http','then','request\x20sent','MemberReport,\x20%s,\x20%s,\x20%s','stringify','error','code','MemberReport,\x20%s,\x20%s','message','info','result','MemberReport','findAll','options','raw','where','attributes','limit','include','map'];(function(_0x43e5f9,_0x4c3051){var _0x527e05=function(_0x5d6d56){while(--_0x5d6d56){_0x43e5f9['push'](_0x43e5f9['shift']());}};_0x527e05(++_0x4c3051);}(_0x1115,0x1b6));var _0x5111=function(_0x415ba8,_0x3f2c65){_0x415ba8=_0x415ba8-0x0;var _0x5374c2=_0x1115[_0x415ba8];return _0x5374c2;};'use strict';var _=require('lodash');var util=require(_0x5111('0x0'));var moment=require(_0x5111('0x1'));var BPromise=require(_0x5111('0x2'));var rs=require(_0x5111('0x3'));var fs=require('fs');var Redis=require(_0x5111('0x4'));var db=require(_0x5111('0x5'))['db'];var utils=require(_0x5111('0x6'));var logger=require(_0x5111('0x7'))(_0x5111('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x5111('0x9')][_0x5111('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x50f0a3,_0x400661,_0x2d2777){return new BPromise(function(_0x54d5ae,_0x42a3c5){return client['request'](_0x50f0a3,_0x2d2777)[_0x5111('0xb')](function(_0x3bbc8c){logger['info']('MemberReport,\x20%s,\x20%s',_0x400661,_0x5111('0xc'));logger['debug'](_0x5111('0xd'),_0x400661,'request\x20sent',JSON[_0x5111('0xe')](_0x3bbc8c));if(_0x3bbc8c[_0x5111('0xf')]){if(_0x3bbc8c[_0x5111('0xf')][_0x5111('0x10')]===0x1f4){logger[_0x5111('0xf')](_0x5111('0x11'),_0x400661,_0x3bbc8c[_0x5111('0xf')][_0x5111('0x12')]);return _0x42a3c5(_0x3bbc8c[_0x5111('0xf')][_0x5111('0x12')]);}logger[_0x5111('0xf')](_0x5111('0x11'),_0x400661,_0x3bbc8c[_0x5111('0xf')][_0x5111('0x12')]);return _0x54d5ae(_0x3bbc8c[_0x5111('0xf')][_0x5111('0x12')]);}else{logger[_0x5111('0x13')](_0x5111('0x11'),_0x400661,'request\x20sent');_0x54d5ae(_0x3bbc8c[_0x5111('0x14')]['message']);}})['catch'](function(_0x387e1e){logger[_0x5111('0xf')](_0x5111('0x11'),_0x400661,_0x387e1e);_0x42a3c5(_0x387e1e);});});}exports['GetMemberReport']=function(_0x367f8d){var _0xa3f4ba=this;return new Promise(function(_0x52c614,_0x204c4f){return db[_0x5111('0x15')][_0x5111('0x16')]({'raw':_0x367f8d[_0x5111('0x17')]?_0x367f8d['options'][_0x5111('0x18')]===undefined?!![]:![]:!![],'where':_0x367f8d[_0x5111('0x17')]?_0x367f8d[_0x5111('0x17')][_0x5111('0x19')]||null:null,'attributes':_0x367f8d[_0x5111('0x17')]?_0x367f8d[_0x5111('0x17')][_0x5111('0x1a')]||null:null,'limit':_0x367f8d[_0x5111('0x17')]?_0x367f8d[_0x5111('0x17')][_0x5111('0x1b')]||null:null,'include':_0x367f8d['options']?_0x367f8d[_0x5111('0x17')][_0x5111('0x1c')]?_[_0x5111('0x1d')](_0x367f8d['options'][_0x5111('0x1c')],function(_0x20a4f7){return{'model':db[_0x20a4f7[_0x5111('0x1e')]],'as':_0x20a4f7['as'],'attributes':_0x20a4f7[_0x5111('0x1a')],'include':_0x20a4f7[_0x5111('0x1c')]?_[_0x5111('0x1d')](_0x20a4f7[_0x5111('0x1c')],function(_0x316b39){return{'model':db[_0x316b39[_0x5111('0x1e')]],'as':_0x316b39['as'],'attributes':_0x316b39[_0x5111('0x1a')],'include':_0x316b39['include']?_[_0x5111('0x1d')](_0x316b39[_0x5111('0x1c')],function(_0x151b67){return{'model':db[_0x151b67[_0x5111('0x1e')]],'as':_0x151b67['as'],'attributes':_0x151b67[_0x5111('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x5111('0xb')](function(_0x2e24ed){logger['info'](_0x5111('0x1f'),_0x367f8d);logger[_0x5111('0x20')](_0x5111('0x1f'),_0x367f8d,JSON['stringify'](_0x2e24ed));_0x52c614(_0x2e24ed);})[_0x5111('0x21')](function(_0x28efc1){logger[_0x5111('0xf')]('GetMemberReport',_0x28efc1['message'],_0x367f8d);_0x204c4f(_0xa3f4ba[_0x5111('0xf')](0x1f4,_0x28efc1['message']));});});};exports[_0x5111('0x22')]=function(_0x5b5a6d){var _0x35ed41=this;return new Promise(function(_0x5a433c,_0x4bb7e2){return db['MemberReport'][_0x5111('0x23')](_0x5b5a6d[_0x5111('0x24')],{'raw':_0x5b5a6d[_0x5111('0x17')]?_0x5b5a6d[_0x5111('0x17')][_0x5111('0x18')]===undefined?!![]:![]:!![]})[_0x5111('0xb')](function(_0x2aceaa){logger['info'](_0x5111('0x22'),_0x5b5a6d);logger[_0x5111('0x20')](_0x5111('0x22'),_0x5b5a6d,JSON[_0x5111('0xe')](_0x2aceaa));_0x5a433c(_0x2aceaa);})['catch'](function(_0x5ce8c7){logger[_0x5111('0xf')](_0x5111('0x22'),_0x5ce8c7[_0x5111('0x12')],_0x5b5a6d);_0x4bb7e2(_0x35ed41[_0x5111('0xf')](0x1f4,_0x5ce8c7[_0x5111('0x12')]));});});};exports[_0x5111('0x25')]=function(_0x1d8f81){var _0x21f248=this;return new Promise(function(_0x4d4bf5,_0x159cb5){return db[_0x5111('0x15')][_0x5111('0x26')](_0x1d8f81['body'],{'raw':_0x1d8f81[_0x5111('0x17')]?_0x1d8f81[_0x5111('0x17')][_0x5111('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1d8f81['options']?_0x1d8f81['options']['where']||null:null,'attributes':_0x1d8f81[_0x5111('0x17')]?_0x1d8f81[_0x5111('0x17')][_0x5111('0x1a')]||null:null,'limit':_0x1d8f81[_0x5111('0x17')]?_0x1d8f81[_0x5111('0x17')]['limit']||null:null})[_0x5111('0xb')](function(_0x222c73){logger[_0x5111('0x13')](_0x5111('0x25'),_0x1d8f81);logger['debug'](_0x5111('0x25'),_0x1d8f81,JSON[_0x5111('0xe')](_0x222c73));_0x4d4bf5(_0x222c73);})[_0x5111('0x21')](function(_0x33bc16){logger[_0x5111('0xf')](_0x5111('0x25'),_0x33bc16[_0x5111('0x12')],_0x1d8f81);_0x159cb5(_0x21f248[_0x5111('0xf')](0x1f4,_0x33bc16[_0x5111('0x12')]));});});};