3cf62058696c358f54eba9c61074f07377d7692f
[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 _0x9af9=['ioredis','../../mysqldb','rpc','../../config/environment','client','then','info','request\x20sent','debug','MemberReport,\x20%s,\x20%s,\x20%s','stringify','error','MemberReport,\x20%s,\x20%s','message','result','catch','GetMemberReport','MemberReport','options','attributes','include','map','model','CreateMemberReport','create','body','raw','UpdateMemberReport','where','lodash','util','bluebird'];(function(_0x3c5f8d,_0x39891f){var _0x3b7beb=function(_0x44d6c9){while(--_0x44d6c9){_0x3c5f8d['push'](_0x3c5f8d['shift']());}};_0x3b7beb(++_0x39891f);}(_0x9af9,0xbd));var _0x99af=function(_0x3a66e7,_0x5181de){_0x3a66e7=_0x3a66e7-0x0;var _0x24dfe1=_0x9af9[_0x3a66e7];return _0x24dfe1;};'use strict';var _=require(_0x99af('0x0'));var util=require(_0x99af('0x1'));var moment=require('moment');var BPromise=require(_0x99af('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x99af('0x3'));var db=require(_0x99af('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x99af('0x5'));var config=require(_0x99af('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x99af('0x7')]['http']({'port':0x232a});function respondWithRpcPromise(_0x5b7c47,_0x31ce7e,_0x1c5c78){return new BPromise(function(_0x16222e,_0x5790e7){return client['request'](_0x5b7c47,_0x1c5c78)[_0x99af('0x8')](function(_0x3a4bf2){logger[_0x99af('0x9')]('MemberReport,\x20%s,\x20%s',_0x31ce7e,_0x99af('0xa'));logger[_0x99af('0xb')](_0x99af('0xc'),_0x31ce7e,_0x99af('0xa'),JSON[_0x99af('0xd')](_0x3a4bf2));if(_0x3a4bf2[_0x99af('0xe')]){if(_0x3a4bf2['error']['code']===0x1f4){logger[_0x99af('0xe')](_0x99af('0xf'),_0x31ce7e,_0x3a4bf2[_0x99af('0xe')][_0x99af('0x10')]);return _0x5790e7(_0x3a4bf2['error'][_0x99af('0x10')]);}logger[_0x99af('0xe')]('MemberReport,\x20%s,\x20%s',_0x31ce7e,_0x3a4bf2[_0x99af('0xe')][_0x99af('0x10')]);return _0x16222e(_0x3a4bf2[_0x99af('0xe')][_0x99af('0x10')]);}else{logger['info']('MemberReport,\x20%s,\x20%s',_0x31ce7e,_0x99af('0xa'));_0x16222e(_0x3a4bf2[_0x99af('0x11')]['message']);}})[_0x99af('0x12')](function(_0x312029){logger[_0x99af('0xe')](_0x99af('0xf'),_0x31ce7e,_0x312029);_0x5790e7(_0x312029);});});}exports[_0x99af('0x13')]=function(_0x3b8d5e){var _0x28e3b5=this;return new Promise(function(_0x543a09,_0x27a694){return db[_0x99af('0x14')]['findAll']({'raw':_0x3b8d5e[_0x99af('0x15')]?_0x3b8d5e['options']['raw']===undefined?!![]:![]:!![],'where':_0x3b8d5e[_0x99af('0x15')]?_0x3b8d5e[_0x99af('0x15')]['where']||null:null,'attributes':_0x3b8d5e[_0x99af('0x15')]?_0x3b8d5e[_0x99af('0x15')][_0x99af('0x16')]||null:null,'limit':_0x3b8d5e['options']?_0x3b8d5e[_0x99af('0x15')]['limit']||null:null,'include':_0x3b8d5e[_0x99af('0x15')]?_0x3b8d5e[_0x99af('0x15')][_0x99af('0x17')]?_[_0x99af('0x18')](_0x3b8d5e[_0x99af('0x15')][_0x99af('0x17')],function(_0x350a13){return{'model':db[_0x350a13[_0x99af('0x19')]],'as':_0x350a13['as'],'attributes':_0x350a13['attributes'],'include':_0x350a13[_0x99af('0x17')]?_[_0x99af('0x18')](_0x350a13[_0x99af('0x17')],function(_0x4e71b5){return{'model':db[_0x4e71b5[_0x99af('0x19')]],'as':_0x4e71b5['as'],'attributes':_0x4e71b5[_0x99af('0x16')],'include':_0x4e71b5[_0x99af('0x17')]?_['map'](_0x4e71b5['include'],function(_0x34945d){return{'model':db[_0x34945d[_0x99af('0x19')]],'as':_0x34945d['as'],'attributes':_0x34945d[_0x99af('0x16')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x52c0c8){logger['info'](_0x99af('0x13'),_0x3b8d5e);logger[_0x99af('0xb')](_0x99af('0x13'),_0x3b8d5e,JSON[_0x99af('0xd')](_0x52c0c8));_0x543a09(_0x52c0c8);})['catch'](function(_0x5f6bde){logger['error']('GetMemberReport',_0x5f6bde['message'],_0x3b8d5e);_0x27a694(_0x28e3b5['error'](0x1f4,_0x5f6bde[_0x99af('0x10')]));});});};exports[_0x99af('0x1a')]=function(_0x13d09f){var _0x5155c4=this;return new Promise(function(_0x2eb1c1,_0x5a0dd5){return db['MemberReport'][_0x99af('0x1b')](_0x13d09f[_0x99af('0x1c')],{'raw':_0x13d09f[_0x99af('0x15')]?_0x13d09f[_0x99af('0x15')][_0x99af('0x1d')]===undefined?!![]:![]:!![]})[_0x99af('0x8')](function(_0x42e928){logger[_0x99af('0x9')](_0x99af('0x1a'),_0x13d09f);logger[_0x99af('0xb')](_0x99af('0x1a'),_0x13d09f,JSON['stringify'](_0x42e928));_0x2eb1c1(_0x42e928);})['catch'](function(_0x1d110b){logger['error'](_0x99af('0x1a'),_0x1d110b[_0x99af('0x10')],_0x13d09f);_0x5a0dd5(_0x5155c4['error'](0x1f4,_0x1d110b[_0x99af('0x10')]));});});};exports[_0x99af('0x1e')]=function(_0x1f6749){var _0x33f9be=this;return new Promise(function(_0x35c824,_0x469dc7){return db[_0x99af('0x14')]['update'](_0x1f6749[_0x99af('0x1c')],{'raw':_0x1f6749[_0x99af('0x15')]?_0x1f6749['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1f6749['options']?_0x1f6749[_0x99af('0x15')][_0x99af('0x1f')]||null:null,'attributes':_0x1f6749[_0x99af('0x15')]?_0x1f6749[_0x99af('0x15')][_0x99af('0x16')]||null:null,'limit':_0x1f6749['options']?_0x1f6749['options']['limit']||null:null})[_0x99af('0x8')](function(_0x895296){logger['info'](_0x99af('0x1e'),_0x1f6749);logger[_0x99af('0xb')](_0x99af('0x1e'),_0x1f6749,JSON['stringify'](_0x895296));_0x35c824(_0x895296);})['catch'](function(_0x553ff2){logger[_0x99af('0xe')](_0x99af('0x1e'),_0x553ff2[_0x99af('0x10')],_0x1f6749);_0x469dc7(_0x33f9be[_0x99af('0xe')](0x1f4,_0x553ff2['message']));});});};