Built motion from commit (unavailable).|2.5.4
[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 _0x38c8=['message','result','catch','GetSugarcrmAccount','findAll','options','where','attributes','limit','include','map','model','ShowSugarcrmAccount','raw','info','lodash','moment','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','client','request','then','SugarcrmAccount,\x20%s,\x20%s','request\x20sent','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','stringify','error','code'];(function(_0x5a9810,_0x1827f7){var _0x4ee4df=function(_0xbae215){while(--_0xbae215){_0x5a9810['push'](_0x5a9810['shift']());}};_0x4ee4df(++_0x1827f7);}(_0x38c8,0x16f));var _0x838c=function(_0x1facfa,_0x1acf7d){_0x1facfa=_0x1facfa-0x0;var _0x9ec701=_0x38c8[_0x1facfa];return _0x9ec701;};'use strict';var _=require(_0x838c('0x0'));var util=require('util');var moment=require(_0x838c('0x1'));var BPromise=require('bluebird');var rs=require(_0x838c('0x2'));var fs=require('fs');var Redis=require(_0x838c('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x838c('0x4'));var logger=require(_0x838c('0x5'))('rpc');var config=require(_0x838c('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x838c('0x7')]['http']({'port':0x232a});function respondWithRpcPromise(_0x16dd0a,_0x3f109b,_0x332f1c){return new BPromise(function(_0x58d235,_0x3dd148){return client[_0x838c('0x8')](_0x16dd0a,_0x332f1c)[_0x838c('0x9')](function(_0x35fb15){logger['info'](_0x838c('0xa'),_0x3f109b,_0x838c('0xb'));logger[_0x838c('0xc')](_0x838c('0xd'),_0x3f109b,_0x838c('0xb'),JSON[_0x838c('0xe')](_0x35fb15));if(_0x35fb15['error']){if(_0x35fb15[_0x838c('0xf')][_0x838c('0x10')]===0x1f4){logger[_0x838c('0xf')]('SugarcrmAccount,\x20%s,\x20%s',_0x3f109b,_0x35fb15[_0x838c('0xf')][_0x838c('0x11')]);return _0x3dd148(_0x35fb15[_0x838c('0xf')][_0x838c('0x11')]);}logger[_0x838c('0xf')](_0x838c('0xa'),_0x3f109b,_0x35fb15[_0x838c('0xf')][_0x838c('0x11')]);return _0x58d235(_0x35fb15[_0x838c('0xf')][_0x838c('0x11')]);}else{logger['info']('SugarcrmAccount,\x20%s,\x20%s',_0x3f109b,'request\x20sent');_0x58d235(_0x35fb15[_0x838c('0x12')][_0x838c('0x11')]);}})[_0x838c('0x13')](function(_0x4e275d){logger['error']('SugarcrmAccount,\x20%s,\x20%s',_0x3f109b,_0x4e275d);_0x3dd148(_0x4e275d);});});}exports[_0x838c('0x14')]=function(_0xe06b12){var _0x1f2a4f=this;return new Promise(function(_0x523843,_0x1015c5){return db['SugarcrmAccount'][_0x838c('0x15')]({'raw':_0xe06b12[_0x838c('0x16')]?_0xe06b12['options']['raw']===undefined?!![]:![]:!![],'where':_0xe06b12[_0x838c('0x16')]?_0xe06b12[_0x838c('0x16')][_0x838c('0x17')]||null:null,'attributes':_0xe06b12['options']?_0xe06b12[_0x838c('0x16')][_0x838c('0x18')]||null:null,'limit':_0xe06b12[_0x838c('0x16')]?_0xe06b12['options'][_0x838c('0x19')]||null:null,'include':_0xe06b12[_0x838c('0x16')]?_0xe06b12['options'][_0x838c('0x1a')]?_[_0x838c('0x1b')](_0xe06b12['options'][_0x838c('0x1a')],function(_0x5d5604){return{'model':db[_0x5d5604['model']],'as':_0x5d5604['as'],'attributes':_0x5d5604['attributes'],'include':_0x5d5604[_0x838c('0x1a')]?_['map'](_0x5d5604['include'],function(_0x45a6fb){return{'model':db[_0x45a6fb[_0x838c('0x1c')]],'as':_0x45a6fb['as'],'attributes':_0x45a6fb[_0x838c('0x18')],'include':_0x45a6fb['include']?_[_0x838c('0x1b')](_0x45a6fb['include'],function(_0x25256e){return{'model':db[_0x25256e[_0x838c('0x1c')]],'as':_0x25256e['as'],'attributes':_0x25256e[_0x838c('0x18')]};}):[]};}):[]};}):[]:[]})[_0x838c('0x9')](function(_0x548e71){logger['info'](_0x838c('0x14'),_0xe06b12);logger[_0x838c('0xc')](_0x838c('0x14'),_0xe06b12,JSON[_0x838c('0xe')](_0x548e71));_0x523843(_0x548e71);})['catch'](function(_0x449241){logger[_0x838c('0xf')](_0x838c('0x14'),_0x449241[_0x838c('0x11')],_0xe06b12);_0x1015c5(_0x1f2a4f[_0x838c('0xf')](0x1f4,_0x449241[_0x838c('0x11')]));});});};exports[_0x838c('0x1d')]=function(_0x326874){var _0x3d9918=this;return new Promise(function(_0x1e4bee,_0x5522e1){return db['SugarcrmAccount']['find']({'raw':_0x326874[_0x838c('0x16')]?_0x326874[_0x838c('0x16')][_0x838c('0x1e')]===undefined?!![]:![]:!![],'where':_0x326874['options']?_0x326874[_0x838c('0x16')]['where']||null:null,'attributes':_0x326874[_0x838c('0x16')]?_0x326874['options']['attributes']||null:null,'include':_0x326874[_0x838c('0x16')]?_0x326874[_0x838c('0x16')][_0x838c('0x1a')]?_['map'](_0x326874['options'][_0x838c('0x1a')],function(_0x2fa8f0){return{'model':db[_0x2fa8f0[_0x838c('0x1c')]],'as':_0x2fa8f0['as'],'attributes':_0x2fa8f0[_0x838c('0x18')],'include':_0x2fa8f0[_0x838c('0x1a')]?_[_0x838c('0x1b')](_0x2fa8f0['include'],function(_0xa9c44f){return{'model':db[_0xa9c44f['model']],'as':_0xa9c44f['as'],'attributes':_0xa9c44f[_0x838c('0x18')],'include':_0xa9c44f[_0x838c('0x1a')]?_[_0x838c('0x1b')](_0xa9c44f['include'],function(_0x166910){return{'model':db[_0x166910['model']],'as':_0x166910['as'],'attributes':_0x166910[_0x838c('0x18')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2bed4c){logger[_0x838c('0x1f')](_0x838c('0x1d'),_0x326874);logger[_0x838c('0xc')](_0x838c('0x1d'),_0x326874,JSON[_0x838c('0xe')](_0x2bed4c));_0x1e4bee(_0x2bed4c);})['catch'](function(_0x4e1a89){logger[_0x838c('0xf')](_0x838c('0x1d'),_0x4e1a89[_0x838c('0x11')],_0x326874);_0x5522e1(_0x3d9918[_0x838c('0xf')](0x1f4,_0x4e1a89['message']));});});};