Built motion from commit (unavailable).|2.6.0
[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 _0xf7ea=['map','model','attributes','ShowSugarcrmAccount','SugarcrmAccount','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http','request','then','info','SugarcrmAccount,\x20%s,\x20%s','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','GetSugarcrmAccount','findAll','raw','options','limit','include'];(function(_0x1e55d9,_0x5ce14a){var _0x6dc799=function(_0x383e7b){while(--_0x383e7b){_0x1e55d9['push'](_0x1e55d9['shift']());}};_0x6dc799(++_0x5ce14a);}(_0xf7ea,0x11d));var _0xaf7e=function(_0x51e2d0,_0x290e1a){_0x51e2d0=_0x51e2d0-0x0;var _0x8abbe7=_0xf7ea[_0x51e2d0];return _0x8abbe7;};'use strict';var _=require(_0xaf7e('0x0'));var util=require(_0xaf7e('0x1'));var moment=require(_0xaf7e('0x2'));var BPromise=require(_0xaf7e('0x3'));var rs=require(_0xaf7e('0x4'));var fs=require('fs');var Redis=require(_0xaf7e('0x5'));var db=require(_0xaf7e('0x6'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xaf7e('0x7'));var config=require(_0xaf7e('0x8'));var jayson=require(_0xaf7e('0x9'));var client=jayson[_0xaf7e('0xa')][_0xaf7e('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x593b20,_0x130f18,_0x2d35b2){return new BPromise(function(_0x3a06e2,_0x5ac9fc){return client[_0xaf7e('0xc')](_0x593b20,_0x2d35b2)[_0xaf7e('0xd')](function(_0xa83649){logger[_0xaf7e('0xe')](_0xaf7e('0xf'),_0x130f18,'request\x20sent');logger[_0xaf7e('0x10')](_0xaf7e('0x11'),_0x130f18,_0xaf7e('0x12'),JSON[_0xaf7e('0x13')](_0xa83649));if(_0xa83649[_0xaf7e('0x14')]){if(_0xa83649[_0xaf7e('0x14')]['code']===0x1f4){logger[_0xaf7e('0x14')](_0xaf7e('0xf'),_0x130f18,_0xa83649[_0xaf7e('0x14')][_0xaf7e('0x15')]);return _0x5ac9fc(_0xa83649['error'][_0xaf7e('0x15')]);}logger['error']('SugarcrmAccount,\x20%s,\x20%s',_0x130f18,_0xa83649[_0xaf7e('0x14')][_0xaf7e('0x15')]);return _0x3a06e2(_0xa83649[_0xaf7e('0x14')][_0xaf7e('0x15')]);}else{logger[_0xaf7e('0xe')](_0xaf7e('0xf'),_0x130f18,_0xaf7e('0x12'));_0x3a06e2(_0xa83649[_0xaf7e('0x16')][_0xaf7e('0x15')]);}})[_0xaf7e('0x17')](function(_0x2bbed3){logger[_0xaf7e('0x14')](_0xaf7e('0xf'),_0x130f18,_0x2bbed3);_0x5ac9fc(_0x2bbed3);});});}exports[_0xaf7e('0x18')]=function(_0x3f6d31){var _0xe96ac2=this;return new Promise(function(_0x36f219,_0x696f20){return db['SugarcrmAccount'][_0xaf7e('0x19')]({'raw':_0x3f6d31['options']?_0x3f6d31['options'][_0xaf7e('0x1a')]===undefined?!![]:![]:!![],'where':_0x3f6d31[_0xaf7e('0x1b')]?_0x3f6d31[_0xaf7e('0x1b')]['where']||null:null,'attributes':_0x3f6d31[_0xaf7e('0x1b')]?_0x3f6d31['options']['attributes']||null:null,'limit':_0x3f6d31[_0xaf7e('0x1b')]?_0x3f6d31[_0xaf7e('0x1b')][_0xaf7e('0x1c')]||null:null,'include':_0x3f6d31['options']?_0x3f6d31[_0xaf7e('0x1b')][_0xaf7e('0x1d')]?_[_0xaf7e('0x1e')](_0x3f6d31[_0xaf7e('0x1b')][_0xaf7e('0x1d')],function(_0x1d6aca){return{'model':db[_0x1d6aca[_0xaf7e('0x1f')]],'as':_0x1d6aca['as'],'attributes':_0x1d6aca[_0xaf7e('0x20')],'include':_0x1d6aca[_0xaf7e('0x1d')]?_[_0xaf7e('0x1e')](_0x1d6aca[_0xaf7e('0x1d')],function(_0x2f36eb){return{'model':db[_0x2f36eb[_0xaf7e('0x1f')]],'as':_0x2f36eb['as'],'attributes':_0x2f36eb['attributes'],'include':_0x2f36eb[_0xaf7e('0x1d')]?_[_0xaf7e('0x1e')](_0x2f36eb[_0xaf7e('0x1d')],function(_0x429393){return{'model':db[_0x429393[_0xaf7e('0x1f')]],'as':_0x429393['as'],'attributes':_0x429393[_0xaf7e('0x20')]};}):[]};}):[]};}):[]:[]})[_0xaf7e('0xd')](function(_0x58c582){logger[_0xaf7e('0xe')](_0xaf7e('0x18'),_0x3f6d31);logger[_0xaf7e('0x10')]('GetSugarcrmAccount',_0x3f6d31,JSON[_0xaf7e('0x13')](_0x58c582));_0x36f219(_0x58c582);})[_0xaf7e('0x17')](function(_0xa2b1b4){logger[_0xaf7e('0x14')](_0xaf7e('0x18'),_0xa2b1b4[_0xaf7e('0x15')],_0x3f6d31);_0x696f20(_0xe96ac2['error'](0x1f4,_0xa2b1b4[_0xaf7e('0x15')]));});});};exports[_0xaf7e('0x21')]=function(_0x4a5034){var _0x7a00a6=this;return new Promise(function(_0x4e8ae8,_0x1d6a2e){return db[_0xaf7e('0x22')]['find']({'raw':_0x4a5034[_0xaf7e('0x1b')]?_0x4a5034[_0xaf7e('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x4a5034[_0xaf7e('0x1b')]?_0x4a5034[_0xaf7e('0x1b')]['where']||null:null,'attributes':_0x4a5034[_0xaf7e('0x1b')]?_0x4a5034[_0xaf7e('0x1b')][_0xaf7e('0x20')]||null:null,'include':_0x4a5034['options']?_0x4a5034[_0xaf7e('0x1b')]['include']?_['map'](_0x4a5034['options'][_0xaf7e('0x1d')],function(_0xbe0855){return{'model':db[_0xbe0855[_0xaf7e('0x1f')]],'as':_0xbe0855['as'],'attributes':_0xbe0855[_0xaf7e('0x20')],'include':_0xbe0855[_0xaf7e('0x1d')]?_[_0xaf7e('0x1e')](_0xbe0855[_0xaf7e('0x1d')],function(_0x57c822){return{'model':db[_0x57c822[_0xaf7e('0x1f')]],'as':_0x57c822['as'],'attributes':_0x57c822[_0xaf7e('0x20')],'include':_0x57c822[_0xaf7e('0x1d')]?_[_0xaf7e('0x1e')](_0x57c822[_0xaf7e('0x1d')],function(_0x16fe17){return{'model':db[_0x16fe17[_0xaf7e('0x1f')]],'as':_0x16fe17['as'],'attributes':_0x16fe17[_0xaf7e('0x20')]};}):[]};}):[]};}):[]:[]})[_0xaf7e('0xd')](function(_0x19f2b0){logger[_0xaf7e('0xe')](_0xaf7e('0x21'),_0x4a5034);logger[_0xaf7e('0x10')]('ShowSugarcrmAccount',_0x4a5034,JSON['stringify'](_0x19f2b0));_0x4e8ae8(_0x19f2b0);})['catch'](function(_0x4c50c2){logger['error'](_0xaf7e('0x21'),_0x4c50c2[_0xaf7e('0x15')],_0x4a5034);_0x1d6a2e(_0x7a00a6[_0xaf7e('0x14')](0x1f4,_0x4c50c2[_0xaf7e('0x15')]));});});};