Built motion from commit (unavailable).|2.5.31
[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 _0xac4a=['findAll','options','raw','where','attributes','limit','include','map','model','ShowSugarcrmAccount','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','info','SugarcrmAccount,\x20%s,\x20%s','request\x20sent','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetSugarcrmAccount','SugarcrmAccount'];(function(_0x266618,_0x18f637){var _0x54dbf5=function(_0x1f7985){while(--_0x1f7985){_0x266618['push'](_0x266618['shift']());}};_0x54dbf5(++_0x18f637);}(_0xac4a,0xb4));var _0xaac4=function(_0x3ec0c4,_0x28b6f8){_0x3ec0c4=_0x3ec0c4-0x0;var _0x59395b=_0xac4a[_0x3ec0c4];return _0x59395b;};'use strict';var _=require('lodash');var util=require(_0xaac4('0x0'));var moment=require(_0xaac4('0x1'));var BPromise=require(_0xaac4('0x2'));var rs=require(_0xaac4('0x3'));var fs=require('fs');var Redis=require(_0xaac4('0x4'));var db=require(_0xaac4('0x5'))['db'];var utils=require(_0xaac4('0x6'));var logger=require(_0xaac4('0x7'))(_0xaac4('0x8'));var config=require(_0xaac4('0x9'));var jayson=require(_0xaac4('0xa'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x2483f6,_0x46fc95,_0x35ae66){return new BPromise(function(_0x226c39,_0x41709d){return client['request'](_0x2483f6,_0x35ae66)['then'](function(_0x251950){logger[_0xaac4('0xb')](_0xaac4('0xc'),_0x46fc95,_0xaac4('0xd'));logger[_0xaac4('0xe')](_0xaac4('0xf'),_0x46fc95,_0xaac4('0xd'),JSON[_0xaac4('0x10')](_0x251950));if(_0x251950[_0xaac4('0x11')]){if(_0x251950[_0xaac4('0x11')][_0xaac4('0x12')]===0x1f4){logger[_0xaac4('0x11')](_0xaac4('0xc'),_0x46fc95,_0x251950['error'][_0xaac4('0x13')]);return _0x41709d(_0x251950['error'][_0xaac4('0x13')]);}logger['error'](_0xaac4('0xc'),_0x46fc95,_0x251950['error'][_0xaac4('0x13')]);return _0x226c39(_0x251950[_0xaac4('0x11')][_0xaac4('0x13')]);}else{logger[_0xaac4('0xb')](_0xaac4('0xc'),_0x46fc95,_0xaac4('0xd'));_0x226c39(_0x251950[_0xaac4('0x14')][_0xaac4('0x13')]);}})[_0xaac4('0x15')](function(_0x12777b){logger['error']('SugarcrmAccount,\x20%s,\x20%s',_0x46fc95,_0x12777b);_0x41709d(_0x12777b);});});}exports[_0xaac4('0x16')]=function(_0x111f2c){var _0x5df02e=this;return new Promise(function(_0x3709ba,_0x5300a8){return db[_0xaac4('0x17')][_0xaac4('0x18')]({'raw':_0x111f2c[_0xaac4('0x19')]?_0x111f2c['options'][_0xaac4('0x1a')]===undefined?!![]:![]:!![],'where':_0x111f2c[_0xaac4('0x19')]?_0x111f2c[_0xaac4('0x19')][_0xaac4('0x1b')]||null:null,'attributes':_0x111f2c[_0xaac4('0x19')]?_0x111f2c[_0xaac4('0x19')][_0xaac4('0x1c')]||null:null,'limit':_0x111f2c[_0xaac4('0x19')]?_0x111f2c[_0xaac4('0x19')][_0xaac4('0x1d')]||null:null,'include':_0x111f2c['options']?_0x111f2c[_0xaac4('0x19')][_0xaac4('0x1e')]?_[_0xaac4('0x1f')](_0x111f2c[_0xaac4('0x19')]['include'],function(_0x43bcc1){return{'model':db[_0x43bcc1[_0xaac4('0x20')]],'as':_0x43bcc1['as'],'attributes':_0x43bcc1[_0xaac4('0x1c')],'include':_0x43bcc1['include']?_[_0xaac4('0x1f')](_0x43bcc1[_0xaac4('0x1e')],function(_0x5e38f4){return{'model':db[_0x5e38f4[_0xaac4('0x20')]],'as':_0x5e38f4['as'],'attributes':_0x5e38f4['attributes'],'include':_0x5e38f4[_0xaac4('0x1e')]?_[_0xaac4('0x1f')](_0x5e38f4['include'],function(_0x1ceed9){return{'model':db[_0x1ceed9[_0xaac4('0x20')]],'as':_0x1ceed9['as'],'attributes':_0x1ceed9[_0xaac4('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5229ba){logger['info'](_0xaac4('0x16'),_0x111f2c);logger[_0xaac4('0xe')]('GetSugarcrmAccount',_0x111f2c,JSON[_0xaac4('0x10')](_0x5229ba));_0x3709ba(_0x5229ba);})[_0xaac4('0x15')](function(_0x38e2dd){logger[_0xaac4('0x11')](_0xaac4('0x16'),_0x38e2dd[_0xaac4('0x13')],_0x111f2c);_0x5300a8(_0x5df02e['error'](0x1f4,_0x38e2dd[_0xaac4('0x13')]));});});};exports['ShowSugarcrmAccount']=function(_0x1d9888){var _0x293170=this;return new Promise(function(_0x5c6cff,_0x385c6d){return db[_0xaac4('0x17')]['find']({'raw':_0x1d9888[_0xaac4('0x19')]?_0x1d9888['options']['raw']===undefined?!![]:![]:!![],'where':_0x1d9888[_0xaac4('0x19')]?_0x1d9888['options'][_0xaac4('0x1b')]||null:null,'attributes':_0x1d9888[_0xaac4('0x19')]?_0x1d9888[_0xaac4('0x19')][_0xaac4('0x1c')]||null:null,'include':_0x1d9888[_0xaac4('0x19')]?_0x1d9888[_0xaac4('0x19')]['include']?_[_0xaac4('0x1f')](_0x1d9888[_0xaac4('0x19')][_0xaac4('0x1e')],function(_0x16efb7){return{'model':db[_0x16efb7['model']],'as':_0x16efb7['as'],'attributes':_0x16efb7[_0xaac4('0x1c')],'include':_0x16efb7[_0xaac4('0x1e')]?_['map'](_0x16efb7[_0xaac4('0x1e')],function(_0x32cee6){return{'model':db[_0x32cee6['model']],'as':_0x32cee6['as'],'attributes':_0x32cee6[_0xaac4('0x1c')],'include':_0x32cee6['include']?_[_0xaac4('0x1f')](_0x32cee6[_0xaac4('0x1e')],function(_0x241b25){return{'model':db[_0x241b25['model']],'as':_0x241b25['as'],'attributes':_0x241b25['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x320a1a){logger['info'](_0xaac4('0x21'),_0x1d9888);logger[_0xaac4('0xe')](_0xaac4('0x21'),_0x1d9888,JSON[_0xaac4('0x10')](_0x320a1a));_0x5c6cff(_0x320a1a);})['catch'](function(_0x3ee641){logger['error'](_0xaac4('0x21'),_0x3ee641[_0xaac4('0x13')],_0x1d9888);_0x385c6d(_0x293170[_0xaac4('0x11')](0x1f4,_0x3ee641[_0xaac4('0x13')]));});});};