Built motion from commit (unavailable).|2.2.6
[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 _0x7cc5=['SugarcrmAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','info','catch','GetSugarcrmAccount','SugarcrmAccount','findAll','options','where','attributes','limit','include','model','map','then','find','raw','ShowSugarcrmAccount','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','request'];(function(_0x5c406b,_0x4af222){var _0x52c130=function(_0x3552ab){while(--_0x3552ab){_0x5c406b['push'](_0x5c406b['shift']());}};_0x52c130(++_0x4af222);}(_0x7cc5,0xc6));var _0x57cc=function(_0x4c6542,_0x22a548){_0x4c6542=_0x4c6542-0x0;var _0x273ee4=_0x7cc5[_0x4c6542];return _0x273ee4;};'use strict';var _=require(_0x57cc('0x0'));var util=require(_0x57cc('0x1'));var moment=require(_0x57cc('0x2'));var BPromise=require(_0x57cc('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x57cc('0x4'));var db=require(_0x57cc('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x57cc('0x6'))(_0x57cc('0x7'));var config=require(_0x57cc('0x8'));var jayson=require(_0x57cc('0x9'));var client=jayson[_0x57cc('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2f4aae,_0xf832bd,_0x27a059){return new BPromise(function(_0x52dfca,_0x304566){return client[_0x57cc('0xb')](_0x2f4aae,_0x27a059)['then'](function(_0xf8857){logger['info'](_0x57cc('0xc'),_0xf832bd,_0x57cc('0xd'));logger[_0x57cc('0xe')]('SugarcrmAccount,\x20%s,\x20%s,\x20%s',_0xf832bd,_0x57cc('0xd'),JSON[_0x57cc('0xf')](_0xf8857));if(_0xf8857[_0x57cc('0x10')]){if(_0xf8857[_0x57cc('0x10')][_0x57cc('0x11')]===0x1f4){logger['error'](_0x57cc('0xc'),_0xf832bd,_0xf8857[_0x57cc('0x10')][_0x57cc('0x12')]);return _0x304566(_0xf8857[_0x57cc('0x10')][_0x57cc('0x12')]);}logger[_0x57cc('0x10')](_0x57cc('0xc'),_0xf832bd,_0xf8857['error'][_0x57cc('0x12')]);return _0x52dfca(_0xf8857[_0x57cc('0x10')]['message']);}else{logger[_0x57cc('0x13')](_0x57cc('0xc'),_0xf832bd,'request\x20sent');_0x52dfca(_0xf8857['result'][_0x57cc('0x12')]);}})[_0x57cc('0x14')](function(_0xbf8c7f){logger[_0x57cc('0x10')](_0x57cc('0xc'),_0xf832bd,_0xbf8c7f);_0x304566(_0xbf8c7f);});});}exports[_0x57cc('0x15')]=function(_0x3de945){var _0x333bcf=this;return new Promise(function(_0x3ce998,_0x287cc0){return db[_0x57cc('0x16')][_0x57cc('0x17')]({'raw':_0x3de945['options']?_0x3de945[_0x57cc('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x3de945['options']?_0x3de945['options'][_0x57cc('0x19')]||null:null,'attributes':_0x3de945[_0x57cc('0x18')]?_0x3de945[_0x57cc('0x18')][_0x57cc('0x1a')]||null:null,'limit':_0x3de945['options']?_0x3de945[_0x57cc('0x18')][_0x57cc('0x1b')]||null:null,'include':_0x3de945[_0x57cc('0x18')]?_0x3de945[_0x57cc('0x18')][_0x57cc('0x1c')]?_['map'](_0x3de945['options'][_0x57cc('0x1c')],function(_0x3a117b){return{'model':db[_0x3a117b[_0x57cc('0x1d')]],'as':_0x3a117b['as'],'attributes':_0x3a117b[_0x57cc('0x1a')],'include':_0x3a117b['include']?_[_0x57cc('0x1e')](_0x3a117b[_0x57cc('0x1c')],function(_0x505cf5){return{'model':db[_0x505cf5['model']],'as':_0x505cf5['as'],'attributes':_0x505cf5[_0x57cc('0x1a')],'include':_0x505cf5[_0x57cc('0x1c')]?_[_0x57cc('0x1e')](_0x505cf5[_0x57cc('0x1c')],function(_0x1dd3c2){return{'model':db[_0x1dd3c2[_0x57cc('0x1d')]],'as':_0x1dd3c2['as'],'attributes':_0x1dd3c2[_0x57cc('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x57cc('0x1f')](function(_0x47ff59){logger[_0x57cc('0x13')](_0x57cc('0x15'),_0x3de945);logger[_0x57cc('0xe')](_0x57cc('0x15'),_0x3de945,JSON[_0x57cc('0xf')](_0x47ff59));_0x3ce998(_0x47ff59);})[_0x57cc('0x14')](function(_0x117614){logger[_0x57cc('0x10')](_0x57cc('0x15'),_0x117614[_0x57cc('0x12')],_0x3de945);_0x287cc0(_0x333bcf[_0x57cc('0x10')](0x1f4,_0x117614[_0x57cc('0x12')]));});});};exports['ShowSugarcrmAccount']=function(_0x25e83e){var _0x47ca3c=this;return new Promise(function(_0x45af07,_0x265a62){return db[_0x57cc('0x16')][_0x57cc('0x20')]({'raw':_0x25e83e['options']?_0x25e83e['options'][_0x57cc('0x21')]===undefined?!![]:![]:!![],'where':_0x25e83e[_0x57cc('0x18')]?_0x25e83e[_0x57cc('0x18')][_0x57cc('0x19')]||null:null,'attributes':_0x25e83e[_0x57cc('0x18')]?_0x25e83e[_0x57cc('0x18')][_0x57cc('0x1a')]||null:null,'include':_0x25e83e[_0x57cc('0x18')]?_0x25e83e[_0x57cc('0x18')][_0x57cc('0x1c')]?_['map'](_0x25e83e[_0x57cc('0x18')]['include'],function(_0xa65864){return{'model':db[_0xa65864[_0x57cc('0x1d')]],'as':_0xa65864['as'],'attributes':_0xa65864['attributes'],'include':_0xa65864['include']?_[_0x57cc('0x1e')](_0xa65864[_0x57cc('0x1c')],function(_0xbf7f02){return{'model':db[_0xbf7f02['model']],'as':_0xbf7f02['as'],'attributes':_0xbf7f02[_0x57cc('0x1a')],'include':_0xbf7f02[_0x57cc('0x1c')]?_[_0x57cc('0x1e')](_0xbf7f02[_0x57cc('0x1c')],function(_0x68a707){return{'model':db[_0x68a707[_0x57cc('0x1d')]],'as':_0x68a707['as'],'attributes':_0x68a707[_0x57cc('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xe8cd4){logger['info'](_0x57cc('0x22'),_0x25e83e);logger['debug'](_0x57cc('0x22'),_0x25e83e,JSON[_0x57cc('0xf')](_0xe8cd4));_0x45af07(_0xe8cd4);})[_0x57cc('0x14')](function(_0x539613){logger[_0x57cc('0x10')]('ShowSugarcrmAccount',_0x539613[_0x57cc('0x12')],_0x25e83e);_0x265a62(_0x47ca3c[_0x57cc('0x10')](0x1f4,_0x539613[_0x57cc('0x12')]));});});};