Built motion from commit (unavailable).|2.3.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 _0xa937=['attributes','limit','include','model','map','stringify','ShowSugarcrmAccount','find','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','request','then','info','SugarcrmAccount,\x20%s,\x20%s','debug','error','code','message','request\x20sent','catch','GetSugarcrmAccount','SugarcrmAccount','findAll','options','raw','where'];(function(_0x3a07c1,_0x34d57f){var _0x2bbe15=function(_0x5a02fb){while(--_0x5a02fb){_0x3a07c1['push'](_0x3a07c1['shift']());}};_0x2bbe15(++_0x34d57f);}(_0xa937,0x194));var _0x7a93=function(_0x5b64e0,_0x2ffe64){_0x5b64e0=_0x5b64e0-0x0;var _0x5bc4fb=_0xa937[_0x5b64e0];return _0x5bc4fb;};'use strict';var _=require('lodash');var util=require(_0x7a93('0x0'));var moment=require(_0x7a93('0x1'));var BPromise=require(_0x7a93('0x2'));var rs=require(_0x7a93('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x7a93('0x4'))['db'];var utils=require(_0x7a93('0x5'));var logger=require(_0x7a93('0x6'))('rpc');var config=require(_0x7a93('0x7'));var jayson=require(_0x7a93('0x8'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x5c74ab,_0x7c1e97,_0x38b0ed){return new BPromise(function(_0x2a7a4f,_0x5a317e){return client[_0x7a93('0x9')](_0x5c74ab,_0x38b0ed)[_0x7a93('0xa')](function(_0x200c63){logger[_0x7a93('0xb')](_0x7a93('0xc'),_0x7c1e97,'request\x20sent');logger[_0x7a93('0xd')]('SugarcrmAccount,\x20%s,\x20%s,\x20%s',_0x7c1e97,'request\x20sent',JSON['stringify'](_0x200c63));if(_0x200c63[_0x7a93('0xe')]){if(_0x200c63['error'][_0x7a93('0xf')]===0x1f4){logger[_0x7a93('0xe')](_0x7a93('0xc'),_0x7c1e97,_0x200c63[_0x7a93('0xe')][_0x7a93('0x10')]);return _0x5a317e(_0x200c63[_0x7a93('0xe')][_0x7a93('0x10')]);}logger[_0x7a93('0xe')](_0x7a93('0xc'),_0x7c1e97,_0x200c63[_0x7a93('0xe')][_0x7a93('0x10')]);return _0x2a7a4f(_0x200c63[_0x7a93('0xe')][_0x7a93('0x10')]);}else{logger[_0x7a93('0xb')](_0x7a93('0xc'),_0x7c1e97,_0x7a93('0x11'));_0x2a7a4f(_0x200c63['result'][_0x7a93('0x10')]);}})[_0x7a93('0x12')](function(_0x5a9a82){logger[_0x7a93('0xe')]('SugarcrmAccount,\x20%s,\x20%s',_0x7c1e97,_0x5a9a82);_0x5a317e(_0x5a9a82);});});}exports[_0x7a93('0x13')]=function(_0x25ce83){var _0x3ad77a=this;return new Promise(function(_0x47c997,_0x20ba66){return db[_0x7a93('0x14')][_0x7a93('0x15')]({'raw':_0x25ce83[_0x7a93('0x16')]?_0x25ce83[_0x7a93('0x16')][_0x7a93('0x17')]===undefined?!![]:![]:!![],'where':_0x25ce83[_0x7a93('0x16')]?_0x25ce83[_0x7a93('0x16')][_0x7a93('0x18')]||null:null,'attributes':_0x25ce83[_0x7a93('0x16')]?_0x25ce83[_0x7a93('0x16')][_0x7a93('0x19')]||null:null,'limit':_0x25ce83[_0x7a93('0x16')]?_0x25ce83[_0x7a93('0x16')][_0x7a93('0x1a')]||null:null,'include':_0x25ce83[_0x7a93('0x16')]?_0x25ce83[_0x7a93('0x16')][_0x7a93('0x1b')]?_['map'](_0x25ce83[_0x7a93('0x16')][_0x7a93('0x1b')],function(_0x301395){return{'model':db[_0x301395[_0x7a93('0x1c')]],'as':_0x301395['as'],'attributes':_0x301395['attributes'],'include':_0x301395[_0x7a93('0x1b')]?_[_0x7a93('0x1d')](_0x301395[_0x7a93('0x1b')],function(_0x8e3345){return{'model':db[_0x8e3345['model']],'as':_0x8e3345['as'],'attributes':_0x8e3345[_0x7a93('0x19')],'include':_0x8e3345[_0x7a93('0x1b')]?_[_0x7a93('0x1d')](_0x8e3345['include'],function(_0x5af66c){return{'model':db[_0x5af66c[_0x7a93('0x1c')]],'as':_0x5af66c['as'],'attributes':_0x5af66c[_0x7a93('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5522b3){logger['info'](_0x7a93('0x13'),_0x25ce83);logger[_0x7a93('0xd')](_0x7a93('0x13'),_0x25ce83,JSON[_0x7a93('0x1e')](_0x5522b3));_0x47c997(_0x5522b3);})[_0x7a93('0x12')](function(_0x5f563f){logger[_0x7a93('0xe')](_0x7a93('0x13'),_0x5f563f[_0x7a93('0x10')],_0x25ce83);_0x20ba66(_0x3ad77a[_0x7a93('0xe')](0x1f4,_0x5f563f[_0x7a93('0x10')]));});});};exports[_0x7a93('0x1f')]=function(_0x35491e){var _0x43547c=this;return new Promise(function(_0x485a93,_0xc83778){return db[_0x7a93('0x14')][_0x7a93('0x20')]({'raw':_0x35491e['options']?_0x35491e[_0x7a93('0x16')][_0x7a93('0x17')]===undefined?!![]:![]:!![],'where':_0x35491e[_0x7a93('0x16')]?_0x35491e['options'][_0x7a93('0x18')]||null:null,'attributes':_0x35491e['options']?_0x35491e['options']['attributes']||null:null,'include':_0x35491e[_0x7a93('0x16')]?_0x35491e[_0x7a93('0x16')][_0x7a93('0x1b')]?_[_0x7a93('0x1d')](_0x35491e[_0x7a93('0x16')]['include'],function(_0x39c3bd){return{'model':db[_0x39c3bd[_0x7a93('0x1c')]],'as':_0x39c3bd['as'],'attributes':_0x39c3bd['attributes'],'include':_0x39c3bd['include']?_[_0x7a93('0x1d')](_0x39c3bd['include'],function(_0x2e77bd){return{'model':db[_0x2e77bd[_0x7a93('0x1c')]],'as':_0x2e77bd['as'],'attributes':_0x2e77bd[_0x7a93('0x19')],'include':_0x2e77bd[_0x7a93('0x1b')]?_[_0x7a93('0x1d')](_0x2e77bd[_0x7a93('0x1b')],function(_0x45e481){return{'model':db[_0x45e481[_0x7a93('0x1c')]],'as':_0x45e481['as'],'attributes':_0x45e481[_0x7a93('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5b0c52){logger[_0x7a93('0xb')](_0x7a93('0x1f'),_0x35491e);logger[_0x7a93('0xd')](_0x7a93('0x1f'),_0x35491e,JSON[_0x7a93('0x1e')](_0x5b0c52));_0x485a93(_0x5b0c52);})[_0x7a93('0x12')](function(_0x48c56d){logger[_0x7a93('0xe')](_0x7a93('0x1f'),_0x48c56d[_0x7a93('0x10')],_0x35491e);_0xc83778(_0x43547c['error'](0x1f4,_0x48c56d[_0x7a93('0x10')]));});});};