51dd85f934f9dadd2cb3574792057e35b3f29f21
[motion2.git] / server / api / intSugarcrmAccount / intSugarcrmAccount.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 _0xe849=['map','model','catch','ShowSugarcrmAccount','find','debug','util','moment','randomstring','ioredis','../../config/logger','jayson/promise','http','request','then','info','SugarcrmAccount,\x20%s,\x20%s','request\x20sent','SugarcrmAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','GetSugarcrmAccount','SugarcrmAccount','findAll','options','raw','where','attributes','limit','include'];(function(_0x420571,_0x352071){var _0x48b8f7=function(_0x4033d5){while(--_0x4033d5){_0x420571['push'](_0x420571['shift']());}};_0x48b8f7(++_0x352071);}(_0xe849,0x150));var _0x9e84=function(_0x2e93a9,_0x3f1834){_0x2e93a9=_0x2e93a9-0x0;var _0x554eb6=_0xe849[_0x2e93a9];return _0x554eb6;};'use strict';var _=require('lodash');var util=require(_0x9e84('0x0'));var moment=require(_0x9e84('0x1'));var BPromise=require('bluebird');var rs=require(_0x9e84('0x2'));var fs=require('fs');var Redis=require(_0x9e84('0x3'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x9e84('0x4'))('rpc');var config=require('../../config/environment');var jayson=require(_0x9e84('0x5'));var client=jayson['client'][_0x9e84('0x6')]({'port':0x232a});function respondWithRpcPromise(_0x40185a,_0x55427e,_0x24c177){return new BPromise(function(_0x52b33e,_0x526c56){return client[_0x9e84('0x7')](_0x40185a,_0x24c177)[_0x9e84('0x8')](function(_0x33b1c2){logger[_0x9e84('0x9')](_0x9e84('0xa'),_0x55427e,_0x9e84('0xb'));logger['debug'](_0x9e84('0xc'),_0x55427e,_0x9e84('0xb'),JSON[_0x9e84('0xd')](_0x33b1c2));if(_0x33b1c2['error']){if(_0x33b1c2[_0x9e84('0xe')][_0x9e84('0xf')]===0x1f4){logger[_0x9e84('0xe')](_0x9e84('0xa'),_0x55427e,_0x33b1c2[_0x9e84('0xe')]['message']);return _0x526c56(_0x33b1c2[_0x9e84('0xe')][_0x9e84('0x10')]);}logger['error'](_0x9e84('0xa'),_0x55427e,_0x33b1c2[_0x9e84('0xe')][_0x9e84('0x10')]);return _0x52b33e(_0x33b1c2[_0x9e84('0xe')][_0x9e84('0x10')]);}else{logger[_0x9e84('0x9')](_0x9e84('0xa'),_0x55427e,_0x9e84('0xb'));_0x52b33e(_0x33b1c2[_0x9e84('0x11')][_0x9e84('0x10')]);}})['catch'](function(_0x4177fa){logger[_0x9e84('0xe')](_0x9e84('0xa'),_0x55427e,_0x4177fa);_0x526c56(_0x4177fa);});});}exports[_0x9e84('0x12')]=function(_0x53ccc8){var _0x117e6f=this;return new Promise(function(_0x5c0744,_0x4d75ee){return db[_0x9e84('0x13')][_0x9e84('0x14')]({'raw':_0x53ccc8[_0x9e84('0x15')]?_0x53ccc8[_0x9e84('0x15')][_0x9e84('0x16')]===undefined?!![]:![]:!![],'where':_0x53ccc8[_0x9e84('0x15')]?_0x53ccc8[_0x9e84('0x15')][_0x9e84('0x17')]||null:null,'attributes':_0x53ccc8['options']?_0x53ccc8[_0x9e84('0x15')][_0x9e84('0x18')]||null:null,'limit':_0x53ccc8[_0x9e84('0x15')]?_0x53ccc8[_0x9e84('0x15')][_0x9e84('0x19')]||null:null,'include':_0x53ccc8[_0x9e84('0x15')]?_0x53ccc8[_0x9e84('0x15')][_0x9e84('0x1a')]?_[_0x9e84('0x1b')](_0x53ccc8[_0x9e84('0x15')][_0x9e84('0x1a')],function(_0x412755){return{'model':db[_0x412755[_0x9e84('0x1c')]],'as':_0x412755['as'],'attributes':_0x412755[_0x9e84('0x18')],'include':_0x412755[_0x9e84('0x1a')]?_[_0x9e84('0x1b')](_0x412755[_0x9e84('0x1a')],function(_0x56ade8){return{'model':db[_0x56ade8[_0x9e84('0x1c')]],'as':_0x56ade8['as'],'attributes':_0x56ade8['attributes'],'include':_0x56ade8[_0x9e84('0x1a')]?_[_0x9e84('0x1b')](_0x56ade8[_0x9e84('0x1a')],function(_0x50427e){return{'model':db[_0x50427e['model']],'as':_0x50427e['as'],'attributes':_0x50427e[_0x9e84('0x18')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x347da0){logger[_0x9e84('0x9')]('GetSugarcrmAccount',_0x53ccc8);logger['debug'](_0x9e84('0x12'),_0x53ccc8,JSON[_0x9e84('0xd')](_0x347da0));_0x5c0744(_0x347da0);})[_0x9e84('0x1d')](function(_0x59b436){logger[_0x9e84('0xe')](_0x9e84('0x12'),_0x59b436[_0x9e84('0x10')],_0x53ccc8);_0x4d75ee(_0x117e6f[_0x9e84('0xe')](0x1f4,_0x59b436[_0x9e84('0x10')]));});});};exports[_0x9e84('0x1e')]=function(_0x18f4df){var _0x5a1610=this;return new Promise(function(_0x52f1fe,_0x57ea56){return db[_0x9e84('0x13')][_0x9e84('0x1f')]({'raw':_0x18f4df[_0x9e84('0x15')]?_0x18f4df['options']['raw']===undefined?!![]:![]:!![],'where':_0x18f4df['options']?_0x18f4df[_0x9e84('0x15')]['where']||null:null,'attributes':_0x18f4df[_0x9e84('0x15')]?_0x18f4df[_0x9e84('0x15')][_0x9e84('0x18')]||null:null,'include':_0x18f4df[_0x9e84('0x15')]?_0x18f4df['options']['include']?_[_0x9e84('0x1b')](_0x18f4df[_0x9e84('0x15')][_0x9e84('0x1a')],function(_0x5a23e8){return{'model':db[_0x5a23e8[_0x9e84('0x1c')]],'as':_0x5a23e8['as'],'attributes':_0x5a23e8[_0x9e84('0x18')],'include':_0x5a23e8[_0x9e84('0x1a')]?_['map'](_0x5a23e8[_0x9e84('0x1a')],function(_0x1f251f){return{'model':db[_0x1f251f[_0x9e84('0x1c')]],'as':_0x1f251f['as'],'attributes':_0x1f251f['attributes'],'include':_0x1f251f['include']?_[_0x9e84('0x1b')](_0x1f251f[_0x9e84('0x1a')],function(_0x3402fb){return{'model':db[_0x3402fb['model']],'as':_0x3402fb['as'],'attributes':_0x3402fb[_0x9e84('0x18')]};}):[]};}):[]};}):[]:[]})[_0x9e84('0x8')](function(_0x5f23b2){logger['info']('ShowSugarcrmAccount',_0x18f4df);logger[_0x9e84('0x20')](_0x9e84('0x1e'),_0x18f4df,JSON[_0x9e84('0xd')](_0x5f23b2));_0x52f1fe(_0x5f23b2);})[_0x9e84('0x1d')](function(_0x5c052e){logger[_0x9e84('0xe')]('ShowSugarcrmAccount',_0x5c052e[_0x9e84('0x10')],_0x18f4df);_0x57ea56(_0x5a1610['error'](0x1f4,_0x5c052e[_0x9e84('0x10')]));});});};