Built motion from commit da617fac.|2.6.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 _0x072b=['map','stringify','ShowSugarcrmAccount','raw','where','then','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','info','SugarcrmAccount,\x20%s,\x20%s','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','request\x20sent','error','message','result','catch','SugarcrmAccount','findAll','options','attributes','limit','include','model'];(function(_0x2c24de,_0x1ce122){var _0x4d32f3=function(_0x288c4a){while(--_0x288c4a){_0x2c24de['push'](_0x2c24de['shift']());}};_0x4d32f3(++_0x1ce122);}(_0x072b,0x116));var _0xb072=function(_0xaa0309,_0x1c8008){_0xaa0309=_0xaa0309-0x0;var _0x5de7ce=_0x072b[_0xaa0309];return _0x5de7ce;};'use strict';var _=require(_0xb072('0x0'));var util=require(_0xb072('0x1'));var moment=require(_0xb072('0x2'));var BPromise=require(_0xb072('0x3'));var rs=require(_0xb072('0x4'));var fs=require('fs');var Redis=require(_0xb072('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xb072('0x6'));var logger=require(_0xb072('0x7'))(_0xb072('0x8'));var config=require(_0xb072('0x9'));var jayson=require(_0xb072('0xa'));var client=jayson[_0xb072('0xb')]['http']({'port':0x232a});function respondWithRpcPromise(_0x32b637,_0x30b0c4,_0x2efa74){return new BPromise(function(_0x59ca88,_0x28c0d3){return client['request'](_0x32b637,_0x2efa74)['then'](function(_0x3812f6){logger[_0xb072('0xc')](_0xb072('0xd'),_0x30b0c4,'request\x20sent');logger[_0xb072('0xe')](_0xb072('0xf'),_0x30b0c4,_0xb072('0x10'),JSON['stringify'](_0x3812f6));if(_0x3812f6[_0xb072('0x11')]){if(_0x3812f6[_0xb072('0x11')]['code']===0x1f4){logger[_0xb072('0x11')]('SugarcrmAccount,\x20%s,\x20%s',_0x30b0c4,_0x3812f6[_0xb072('0x11')]['message']);return _0x28c0d3(_0x3812f6['error'][_0xb072('0x12')]);}logger[_0xb072('0x11')](_0xb072('0xd'),_0x30b0c4,_0x3812f6[_0xb072('0x11')]['message']);return _0x59ca88(_0x3812f6[_0xb072('0x11')][_0xb072('0x12')]);}else{logger[_0xb072('0xc')](_0xb072('0xd'),_0x30b0c4,_0xb072('0x10'));_0x59ca88(_0x3812f6[_0xb072('0x13')][_0xb072('0x12')]);}})[_0xb072('0x14')](function(_0x4b8c1a){logger[_0xb072('0x11')](_0xb072('0xd'),_0x30b0c4,_0x4b8c1a);_0x28c0d3(_0x4b8c1a);});});}exports['GetSugarcrmAccount']=function(_0x2db23f){var _0x40a1b4=this;return new Promise(function(_0x398ee3,_0x32f2be){return db[_0xb072('0x15')][_0xb072('0x16')]({'raw':_0x2db23f['options']?_0x2db23f[_0xb072('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x2db23f[_0xb072('0x17')]?_0x2db23f[_0xb072('0x17')]['where']||null:null,'attributes':_0x2db23f[_0xb072('0x17')]?_0x2db23f[_0xb072('0x17')][_0xb072('0x18')]||null:null,'limit':_0x2db23f[_0xb072('0x17')]?_0x2db23f[_0xb072('0x17')][_0xb072('0x19')]||null:null,'include':_0x2db23f[_0xb072('0x17')]?_0x2db23f[_0xb072('0x17')][_0xb072('0x1a')]?_['map'](_0x2db23f[_0xb072('0x17')][_0xb072('0x1a')],function(_0x1bbe06){return{'model':db[_0x1bbe06[_0xb072('0x1b')]],'as':_0x1bbe06['as'],'attributes':_0x1bbe06[_0xb072('0x18')],'include':_0x1bbe06[_0xb072('0x1a')]?_[_0xb072('0x1c')](_0x1bbe06[_0xb072('0x1a')],function(_0x34d4fa){return{'model':db[_0x34d4fa[_0xb072('0x1b')]],'as':_0x34d4fa['as'],'attributes':_0x34d4fa[_0xb072('0x18')],'include':_0x34d4fa[_0xb072('0x1a')]?_[_0xb072('0x1c')](_0x34d4fa[_0xb072('0x1a')],function(_0x51ec57){return{'model':db[_0x51ec57[_0xb072('0x1b')]],'as':_0x51ec57['as'],'attributes':_0x51ec57[_0xb072('0x18')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x21bc4e){logger[_0xb072('0xc')]('GetSugarcrmAccount',_0x2db23f);logger[_0xb072('0xe')]('GetSugarcrmAccount',_0x2db23f,JSON[_0xb072('0x1d')](_0x21bc4e));_0x398ee3(_0x21bc4e);})['catch'](function(_0x3fd621){logger[_0xb072('0x11')]('GetSugarcrmAccount',_0x3fd621['message'],_0x2db23f);_0x32f2be(_0x40a1b4[_0xb072('0x11')](0x1f4,_0x3fd621[_0xb072('0x12')]));});});};exports[_0xb072('0x1e')]=function(_0x311e36){var _0x5ccea5=this;return new Promise(function(_0x19b318,_0x2c22d3){return db[_0xb072('0x15')]['find']({'raw':_0x311e36[_0xb072('0x17')]?_0x311e36[_0xb072('0x17')][_0xb072('0x1f')]===undefined?!![]:![]:!![],'where':_0x311e36[_0xb072('0x17')]?_0x311e36[_0xb072('0x17')][_0xb072('0x20')]||null:null,'attributes':_0x311e36[_0xb072('0x17')]?_0x311e36[_0xb072('0x17')][_0xb072('0x18')]||null:null,'include':_0x311e36[_0xb072('0x17')]?_0x311e36['options'][_0xb072('0x1a')]?_['map'](_0x311e36[_0xb072('0x17')][_0xb072('0x1a')],function(_0xc38bba){return{'model':db[_0xc38bba['model']],'as':_0xc38bba['as'],'attributes':_0xc38bba[_0xb072('0x18')],'include':_0xc38bba[_0xb072('0x1a')]?_['map'](_0xc38bba['include'],function(_0x5f58eb){return{'model':db[_0x5f58eb['model']],'as':_0x5f58eb['as'],'attributes':_0x5f58eb[_0xb072('0x18')],'include':_0x5f58eb[_0xb072('0x1a')]?_[_0xb072('0x1c')](_0x5f58eb[_0xb072('0x1a')],function(_0x2e5813){return{'model':db[_0x2e5813[_0xb072('0x1b')]],'as':_0x2e5813['as'],'attributes':_0x2e5813[_0xb072('0x18')]};}):[]};}):[]};}):[]:[]})[_0xb072('0x21')](function(_0x56e13c){logger[_0xb072('0xc')](_0xb072('0x1e'),_0x311e36);logger[_0xb072('0xe')](_0xb072('0x1e'),_0x311e36,JSON[_0xb072('0x1d')](_0x56e13c));_0x19b318(_0x56e13c);})[_0xb072('0x14')](function(_0x595738){logger[_0xb072('0x11')](_0xb072('0x1e'),_0x595738[_0xb072('0x12')],_0x311e36);_0x2c22d3(_0x5ccea5['error'](0x1f4,_0x595738[_0xb072('0x12')]));});});};