a5011010cb3a9215a64f85a1a28c5ae918ca28be
[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 _0xcc24=['moment','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','SugarcrmAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','code','SugarcrmAccount,\x20%s,\x20%s','error','message','info','result','GetSugarcrmAccount','SugarcrmAccount','options','raw','where','limit','include','model','attributes','map','then','catch','find','debug','ShowSugarcrmAccount','lodash','util'];(function(_0x51fe86,_0x422b66){var _0x3557d4=function(_0x524a6a){while(--_0x524a6a){_0x51fe86['push'](_0x51fe86['shift']());}};_0x3557d4(++_0x422b66);}(_0xcc24,0x18a));var _0x4cc2=function(_0x1a094b,_0x2da8fa){_0x1a094b=_0x1a094b-0x0;var _0x417bab=_0xcc24[_0x1a094b];return _0x417bab;};'use strict';var _=require(_0x4cc2('0x0'));var util=require(_0x4cc2('0x1'));var moment=require(_0x4cc2('0x2'));var BPromise=require('bluebird');var rs=require(_0x4cc2('0x3'));var fs=require('fs');var Redis=require(_0x4cc2('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x4cc2('0x5'));var logger=require(_0x4cc2('0x6'))(_0x4cc2('0x7'));var config=require(_0x4cc2('0x8'));var jayson=require(_0x4cc2('0x9'));var client=jayson[_0x4cc2('0xa')][_0x4cc2('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x4d6950,_0x2dcc3b,_0x5641af){return new BPromise(function(_0x36cad,_0x1e43f3){return client['request'](_0x4d6950,_0x5641af)['then'](function(_0x1ebbef){logger['info']('SugarcrmAccount,\x20%s,\x20%s',_0x2dcc3b,'request\x20sent');logger['debug'](_0x4cc2('0xc'),_0x2dcc3b,_0x4cc2('0xd'),JSON[_0x4cc2('0xe')](_0x1ebbef));if(_0x1ebbef['error']){if(_0x1ebbef['error'][_0x4cc2('0xf')]===0x1f4){logger['error'](_0x4cc2('0x10'),_0x2dcc3b,_0x1ebbef[_0x4cc2('0x11')][_0x4cc2('0x12')]);return _0x1e43f3(_0x1ebbef['error']['message']);}logger['error']('SugarcrmAccount,\x20%s,\x20%s',_0x2dcc3b,_0x1ebbef[_0x4cc2('0x11')][_0x4cc2('0x12')]);return _0x36cad(_0x1ebbef['error']['message']);}else{logger[_0x4cc2('0x13')](_0x4cc2('0x10'),_0x2dcc3b,'request\x20sent');_0x36cad(_0x1ebbef[_0x4cc2('0x14')][_0x4cc2('0x12')]);}})['catch'](function(_0x25e0d6){logger[_0x4cc2('0x11')](_0x4cc2('0x10'),_0x2dcc3b,_0x25e0d6);_0x1e43f3(_0x25e0d6);});});}exports[_0x4cc2('0x15')]=function(_0x4fb045){var _0x36c5ba=this;return new Promise(function(_0x214e84,_0x5c9896){return db[_0x4cc2('0x16')]['findAll']({'raw':_0x4fb045[_0x4cc2('0x17')]?_0x4fb045[_0x4cc2('0x17')][_0x4cc2('0x18')]===undefined?!![]:![]:!![],'where':_0x4fb045[_0x4cc2('0x17')]?_0x4fb045[_0x4cc2('0x17')][_0x4cc2('0x19')]||null:null,'attributes':_0x4fb045['options']?_0x4fb045[_0x4cc2('0x17')]['attributes']||null:null,'limit':_0x4fb045['options']?_0x4fb045[_0x4cc2('0x17')][_0x4cc2('0x1a')]||null:null,'include':_0x4fb045['options']?_0x4fb045['options'][_0x4cc2('0x1b')]?_['map'](_0x4fb045[_0x4cc2('0x17')][_0x4cc2('0x1b')],function(_0x3d7cc0){return{'model':db[_0x3d7cc0[_0x4cc2('0x1c')]],'as':_0x3d7cc0['as'],'attributes':_0x3d7cc0[_0x4cc2('0x1d')],'include':_0x3d7cc0[_0x4cc2('0x1b')]?_[_0x4cc2('0x1e')](_0x3d7cc0['include'],function(_0x5bcf18){return{'model':db[_0x5bcf18[_0x4cc2('0x1c')]],'as':_0x5bcf18['as'],'attributes':_0x5bcf18[_0x4cc2('0x1d')],'include':_0x5bcf18[_0x4cc2('0x1b')]?_['map'](_0x5bcf18['include'],function(_0x33d5df){return{'model':db[_0x33d5df[_0x4cc2('0x1c')]],'as':_0x33d5df['as'],'attributes':_0x33d5df['attributes']};}):[]};}):[]};}):[]:[]})[_0x4cc2('0x1f')](function(_0x516e9a){logger['info'](_0x4cc2('0x15'),_0x4fb045);logger['debug'](_0x4cc2('0x15'),_0x4fb045,JSON[_0x4cc2('0xe')](_0x516e9a));_0x214e84(_0x516e9a);})[_0x4cc2('0x20')](function(_0x2490f1){logger[_0x4cc2('0x11')](_0x4cc2('0x15'),_0x2490f1[_0x4cc2('0x12')],_0x4fb045);_0x5c9896(_0x36c5ba[_0x4cc2('0x11')](0x1f4,_0x2490f1[_0x4cc2('0x12')]));});});};exports['ShowSugarcrmAccount']=function(_0x25128a){var _0x51635b=this;return new Promise(function(_0x38a4d6,_0x55a404){return db[_0x4cc2('0x16')][_0x4cc2('0x21')]({'raw':_0x25128a[_0x4cc2('0x17')]?_0x25128a['options'][_0x4cc2('0x18')]===undefined?!![]:![]:!![],'where':_0x25128a[_0x4cc2('0x17')]?_0x25128a[_0x4cc2('0x17')][_0x4cc2('0x19')]||null:null,'attributes':_0x25128a[_0x4cc2('0x17')]?_0x25128a[_0x4cc2('0x17')][_0x4cc2('0x1d')]||null:null,'include':_0x25128a[_0x4cc2('0x17')]?_0x25128a[_0x4cc2('0x17')]['include']?_[_0x4cc2('0x1e')](_0x25128a[_0x4cc2('0x17')]['include'],function(_0x3d27f5){return{'model':db[_0x3d27f5[_0x4cc2('0x1c')]],'as':_0x3d27f5['as'],'attributes':_0x3d27f5[_0x4cc2('0x1d')],'include':_0x3d27f5['include']?_[_0x4cc2('0x1e')](_0x3d27f5[_0x4cc2('0x1b')],function(_0x13d091){return{'model':db[_0x13d091[_0x4cc2('0x1c')]],'as':_0x13d091['as'],'attributes':_0x13d091[_0x4cc2('0x1d')],'include':_0x13d091[_0x4cc2('0x1b')]?_[_0x4cc2('0x1e')](_0x13d091[_0x4cc2('0x1b')],function(_0x1fdd66){return{'model':db[_0x1fdd66[_0x4cc2('0x1c')]],'as':_0x1fdd66['as'],'attributes':_0x1fdd66['attributes']};}):[]};}):[]};}):[]:[]})[_0x4cc2('0x1f')](function(_0x309d2f){logger[_0x4cc2('0x13')]('ShowSugarcrmAccount',_0x25128a);logger[_0x4cc2('0x22')](_0x4cc2('0x23'),_0x25128a,JSON['stringify'](_0x309d2f));_0x38a4d6(_0x309d2f);})[_0x4cc2('0x20')](function(_0x22f9c4){logger[_0x4cc2('0x11')]('ShowSugarcrmAccount',_0x22f9c4['message'],_0x25128a);_0x55a404(_0x51635b['error'](0x1f4,_0x22f9c4[_0x4cc2('0x12')]));});});};