Built motion from commit (unavailable).|2.5.3
[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 _0x6224=['bluebird','randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','http','request','info','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','SugarcrmAccount,\x20%s,\x20%s','message','result','catch','findAll','options','raw','where','attributes','limit','include','map','model','GetSugarcrmAccount','ShowSugarcrmAccount','find','lodash','util'];(function(_0x59857d,_0x2cbb63){var _0x5c9e2d=function(_0x5aa617){while(--_0x5aa617){_0x59857d['push'](_0x59857d['shift']());}};_0x5c9e2d(++_0x2cbb63);}(_0x6224,0x17e));var _0x4622=function(_0x3c4f1f,_0x20d3ec){_0x3c4f1f=_0x3c4f1f-0x0;var _0x19cb69=_0x6224[_0x3c4f1f];return _0x19cb69;};'use strict';var _=require(_0x4622('0x0'));var util=require(_0x4622('0x1'));var moment=require('moment');var BPromise=require(_0x4622('0x2'));var rs=require(_0x4622('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x4622('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x4622('0x5'))(_0x4622('0x6'));var config=require(_0x4622('0x7'));var jayson=require('jayson/promise');var client=jayson['client'][_0x4622('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x2104df,_0x5e093d,_0x9189ef){return new BPromise(function(_0x3efacc,_0x1de557){return client[_0x4622('0x9')](_0x2104df,_0x9189ef)['then'](function(_0x3ea24e){logger[_0x4622('0xa')]('SugarcrmAccount,\x20%s,\x20%s',_0x5e093d,'request\x20sent');logger[_0x4622('0xb')](_0x4622('0xc'),_0x5e093d,_0x4622('0xd'),JSON[_0x4622('0xe')](_0x3ea24e));if(_0x3ea24e[_0x4622('0xf')]){if(_0x3ea24e[_0x4622('0xf')]['code']===0x1f4){logger['error'](_0x4622('0x10'),_0x5e093d,_0x3ea24e[_0x4622('0xf')][_0x4622('0x11')]);return _0x1de557(_0x3ea24e[_0x4622('0xf')][_0x4622('0x11')]);}logger[_0x4622('0xf')]('SugarcrmAccount,\x20%s,\x20%s',_0x5e093d,_0x3ea24e['error'][_0x4622('0x11')]);return _0x3efacc(_0x3ea24e[_0x4622('0xf')][_0x4622('0x11')]);}else{logger['info'](_0x4622('0x10'),_0x5e093d,_0x4622('0xd'));_0x3efacc(_0x3ea24e[_0x4622('0x12')][_0x4622('0x11')]);}})[_0x4622('0x13')](function(_0x4a6fa5){logger[_0x4622('0xf')](_0x4622('0x10'),_0x5e093d,_0x4a6fa5);_0x1de557(_0x4a6fa5);});});}exports['GetSugarcrmAccount']=function(_0x24a626){var _0x11018c=this;return new Promise(function(_0x3aa2a9,_0x1c3c00){return db['SugarcrmAccount'][_0x4622('0x14')]({'raw':_0x24a626[_0x4622('0x15')]?_0x24a626[_0x4622('0x15')][_0x4622('0x16')]===undefined?!![]:![]:!![],'where':_0x24a626[_0x4622('0x15')]?_0x24a626[_0x4622('0x15')][_0x4622('0x17')]||null:null,'attributes':_0x24a626[_0x4622('0x15')]?_0x24a626[_0x4622('0x15')][_0x4622('0x18')]||null:null,'limit':_0x24a626[_0x4622('0x15')]?_0x24a626[_0x4622('0x15')][_0x4622('0x19')]||null:null,'include':_0x24a626['options']?_0x24a626[_0x4622('0x15')][_0x4622('0x1a')]?_[_0x4622('0x1b')](_0x24a626[_0x4622('0x15')][_0x4622('0x1a')],function(_0x33efc0){return{'model':db[_0x33efc0[_0x4622('0x1c')]],'as':_0x33efc0['as'],'attributes':_0x33efc0['attributes'],'include':_0x33efc0[_0x4622('0x1a')]?_[_0x4622('0x1b')](_0x33efc0[_0x4622('0x1a')],function(_0x4c5acf){return{'model':db[_0x4c5acf[_0x4622('0x1c')]],'as':_0x4c5acf['as'],'attributes':_0x4c5acf[_0x4622('0x18')],'include':_0x4c5acf[_0x4622('0x1a')]?_[_0x4622('0x1b')](_0x4c5acf[_0x4622('0x1a')],function(_0x226bb4){return{'model':db[_0x226bb4[_0x4622('0x1c')]],'as':_0x226bb4['as'],'attributes':_0x226bb4[_0x4622('0x18')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x58af6e){logger['info'](_0x4622('0x1d'),_0x24a626);logger['debug']('GetSugarcrmAccount',_0x24a626,JSON[_0x4622('0xe')](_0x58af6e));_0x3aa2a9(_0x58af6e);})[_0x4622('0x13')](function(_0x2be366){logger['error'](_0x4622('0x1d'),_0x2be366['message'],_0x24a626);_0x1c3c00(_0x11018c[_0x4622('0xf')](0x1f4,_0x2be366['message']));});});};exports[_0x4622('0x1e')]=function(_0x5aa6c1){var _0x2fe190=this;return new Promise(function(_0x49231a,_0x3f5758){return db['SugarcrmAccount'][_0x4622('0x1f')]({'raw':_0x5aa6c1[_0x4622('0x15')]?_0x5aa6c1['options'][_0x4622('0x16')]===undefined?!![]:![]:!![],'where':_0x5aa6c1[_0x4622('0x15')]?_0x5aa6c1['options'][_0x4622('0x17')]||null:null,'attributes':_0x5aa6c1['options']?_0x5aa6c1[_0x4622('0x15')]['attributes']||null:null,'include':_0x5aa6c1['options']?_0x5aa6c1[_0x4622('0x15')][_0x4622('0x1a')]?_['map'](_0x5aa6c1[_0x4622('0x15')]['include'],function(_0x594bec){return{'model':db[_0x594bec[_0x4622('0x1c')]],'as':_0x594bec['as'],'attributes':_0x594bec[_0x4622('0x18')],'include':_0x594bec[_0x4622('0x1a')]?_['map'](_0x594bec[_0x4622('0x1a')],function(_0x1a28e4){return{'model':db[_0x1a28e4[_0x4622('0x1c')]],'as':_0x1a28e4['as'],'attributes':_0x1a28e4[_0x4622('0x18')],'include':_0x1a28e4[_0x4622('0x1a')]?_[_0x4622('0x1b')](_0x1a28e4[_0x4622('0x1a')],function(_0x4f99fe){return{'model':db[_0x4f99fe['model']],'as':_0x4f99fe['as'],'attributes':_0x4f99fe[_0x4622('0x18')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1ae1ed){logger[_0x4622('0xa')](_0x4622('0x1e'),_0x5aa6c1);logger[_0x4622('0xb')]('ShowSugarcrmAccount',_0x5aa6c1,JSON[_0x4622('0xe')](_0x1ae1ed));_0x49231a(_0x1ae1ed);})[_0x4622('0x13')](function(_0xeda96b){logger[_0x4622('0xf')](_0x4622('0x1e'),_0xeda96b[_0x4622('0x11')],_0x5aa6c1);_0x3f5758(_0x2fe190[_0x4622('0xf')](0x1f4,_0xeda96b['message']));});});};