82cd181e35662fbcb9c0c65381e3dddc6d60d4d4
[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 _0xf1c6=['body','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','jayson/promise','client','http','request','MemberReport,\x20%s,\x20%s','request\x20sent','MemberReport,\x20%s,\x20%s,\x20%s','error','message','info','result','catch','GetMemberReport','MemberReport','findAll','options','where','limit','include','map','model','attributes','then','debug','stringify','CreateMemberReport','create','raw','UpdateMemberReport'];(function(_0x3fa65f,_0x15475f){var _0x246bf1=function(_0x469682){while(--_0x469682){_0x3fa65f['push'](_0x3fa65f['shift']());}};_0x246bf1(++_0x15475f);}(_0xf1c6,0x145));var _0x6f1c=function(_0x2c4978,_0x42d48f){_0x2c4978=_0x2c4978-0x0;var _0x26e6d7=_0xf1c6[_0x2c4978];return _0x26e6d7;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x6f1c('0x0'));var BPromise=require(_0x6f1c('0x1'));var rs=require(_0x6f1c('0x2'));var fs=require('fs');var Redis=require(_0x6f1c('0x3'));var db=require(_0x6f1c('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x6f1c('0x5'));var config=require('../../config/environment');var jayson=require(_0x6f1c('0x6'));var client=jayson[_0x6f1c('0x7')][_0x6f1c('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x537c4f,_0x1c1751,_0x564a8f){return new BPromise(function(_0x275f11,_0x2d8ce2){return client[_0x6f1c('0x9')](_0x537c4f,_0x564a8f)['then'](function(_0x2f5ff0){logger['info'](_0x6f1c('0xa'),_0x1c1751,_0x6f1c('0xb'));logger['debug'](_0x6f1c('0xc'),_0x1c1751,_0x6f1c('0xb'),JSON['stringify'](_0x2f5ff0));if(_0x2f5ff0['error']){if(_0x2f5ff0['error']['code']===0x1f4){logger[_0x6f1c('0xd')]('MemberReport,\x20%s,\x20%s',_0x1c1751,_0x2f5ff0['error']['message']);return _0x2d8ce2(_0x2f5ff0['error']['message']);}logger[_0x6f1c('0xd')](_0x6f1c('0xa'),_0x1c1751,_0x2f5ff0[_0x6f1c('0xd')]['message']);return _0x275f11(_0x2f5ff0[_0x6f1c('0xd')][_0x6f1c('0xe')]);}else{logger[_0x6f1c('0xf')]('MemberReport,\x20%s,\x20%s',_0x1c1751,_0x6f1c('0xb'));_0x275f11(_0x2f5ff0[_0x6f1c('0x10')]['message']);}})[_0x6f1c('0x11')](function(_0x11bc81){logger[_0x6f1c('0xd')](_0x6f1c('0xa'),_0x1c1751,_0x11bc81);_0x2d8ce2(_0x11bc81);});});}exports[_0x6f1c('0x12')]=function(_0x16d2bb){var _0x491151=this;return new Promise(function(_0x2f9949,_0x6035da){return db[_0x6f1c('0x13')][_0x6f1c('0x14')]({'raw':_0x16d2bb[_0x6f1c('0x15')]?_0x16d2bb[_0x6f1c('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x16d2bb['options']?_0x16d2bb['options'][_0x6f1c('0x16')]||null:null,'attributes':_0x16d2bb['options']?_0x16d2bb[_0x6f1c('0x15')]['attributes']||null:null,'limit':_0x16d2bb[_0x6f1c('0x15')]?_0x16d2bb[_0x6f1c('0x15')][_0x6f1c('0x17')]||null:null,'include':_0x16d2bb[_0x6f1c('0x15')]?_0x16d2bb[_0x6f1c('0x15')][_0x6f1c('0x18')]?_[_0x6f1c('0x19')](_0x16d2bb[_0x6f1c('0x15')][_0x6f1c('0x18')],function(_0x18ff09){return{'model':db[_0x18ff09[_0x6f1c('0x1a')]],'as':_0x18ff09['as'],'attributes':_0x18ff09[_0x6f1c('0x1b')],'include':_0x18ff09[_0x6f1c('0x18')]?_[_0x6f1c('0x19')](_0x18ff09['include'],function(_0x2a3b6a){return{'model':db[_0x2a3b6a[_0x6f1c('0x1a')]],'as':_0x2a3b6a['as'],'attributes':_0x2a3b6a['attributes'],'include':_0x2a3b6a[_0x6f1c('0x18')]?_[_0x6f1c('0x19')](_0x2a3b6a['include'],function(_0x59931c){return{'model':db[_0x59931c['model']],'as':_0x59931c['as'],'attributes':_0x59931c['attributes']};}):[]};}):[]};}):[]:[]})[_0x6f1c('0x1c')](function(_0x1ac9f5){logger[_0x6f1c('0xf')](_0x6f1c('0x12'),_0x16d2bb);logger[_0x6f1c('0x1d')](_0x6f1c('0x12'),_0x16d2bb,JSON[_0x6f1c('0x1e')](_0x1ac9f5));_0x2f9949(_0x1ac9f5);})[_0x6f1c('0x11')](function(_0x32c722){logger[_0x6f1c('0xd')](_0x6f1c('0x12'),_0x32c722[_0x6f1c('0xe')],_0x16d2bb);_0x6035da(_0x491151['error'](0x1f4,_0x32c722['message']));});});};exports[_0x6f1c('0x1f')]=function(_0x4084af){var _0x383802=this;return new Promise(function(_0x26de6c,_0xad1bce){return db['MemberReport'][_0x6f1c('0x20')](_0x4084af['body'],{'raw':_0x4084af[_0x6f1c('0x15')]?_0x4084af['options'][_0x6f1c('0x21')]===undefined?!![]:![]:!![]})[_0x6f1c('0x1c')](function(_0x3c8585){logger[_0x6f1c('0xf')](_0x6f1c('0x1f'),_0x4084af);logger[_0x6f1c('0x1d')](_0x6f1c('0x1f'),_0x4084af,JSON[_0x6f1c('0x1e')](_0x3c8585));_0x26de6c(_0x3c8585);})[_0x6f1c('0x11')](function(_0x46e256){logger['error'](_0x6f1c('0x1f'),_0x46e256[_0x6f1c('0xe')],_0x4084af);_0xad1bce(_0x383802[_0x6f1c('0xd')](0x1f4,_0x46e256[_0x6f1c('0xe')]));});});};exports[_0x6f1c('0x22')]=function(_0x1609e3){var _0x454507=this;return new Promise(function(_0x326f85,_0x2a41ef){return db['MemberReport']['update'](_0x1609e3[_0x6f1c('0x23')],{'raw':_0x1609e3[_0x6f1c('0x15')]?_0x1609e3[_0x6f1c('0x15')][_0x6f1c('0x21')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1609e3[_0x6f1c('0x15')]?_0x1609e3[_0x6f1c('0x15')][_0x6f1c('0x16')]||null:null,'attributes':_0x1609e3[_0x6f1c('0x15')]?_0x1609e3[_0x6f1c('0x15')][_0x6f1c('0x1b')]||null:null,'limit':_0x1609e3[_0x6f1c('0x15')]?_0x1609e3[_0x6f1c('0x15')][_0x6f1c('0x17')]||null:null})[_0x6f1c('0x1c')](function(_0x1731a4){logger[_0x6f1c('0xf')]('UpdateMemberReport',_0x1609e3);logger['debug'](_0x6f1c('0x22'),_0x1609e3,JSON[_0x6f1c('0x1e')](_0x1731a4));_0x326f85(_0x1731a4);})[_0x6f1c('0x11')](function(_0xa54c4){logger[_0x6f1c('0xd')](_0x6f1c('0x22'),_0xa54c4[_0x6f1c('0xe')],_0x1609e3);_0x2a41ef(_0x454507[_0x6f1c('0xd')](0x1f4,_0xa54c4[_0x6f1c('0xe')]));});});};