69179672a5c6eed78d9bb4b09c2a70e009f09d81
[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 _0x8c9d=['GetSugarcrmAccount','debug','find','ShowSugarcrmAccount','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','SugarcrmAccount,\x20%s,\x20%s','request\x20sent','error','code','message','info','result','catch','SugarcrmAccount','options','raw','where','attributes','limit','include','map','model','then'];(function(_0x2dafbe,_0x5d04de){var _0x58a45a=function(_0x50ac96){while(--_0x50ac96){_0x2dafbe['push'](_0x2dafbe['shift']());}};_0x58a45a(++_0x5d04de);}(_0x8c9d,0xe3));var _0xd8c9=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x8c9d[_0x20a584];return _0x4b41a8;};'use strict';var _=require(_0xd8c9('0x0'));var util=require(_0xd8c9('0x1'));var moment=require(_0xd8c9('0x2'));var BPromise=require(_0xd8c9('0x3'));var rs=require(_0xd8c9('0x4'));var fs=require('fs');var Redis=require(_0xd8c9('0x5'));var db=require(_0xd8c9('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0xd8c9('0x7'))(_0xd8c9('0x8'));var config=require(_0xd8c9('0x9'));var jayson=require(_0xd8c9('0xa'));var client=jayson[_0xd8c9('0xb')][_0xd8c9('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x3c5a05,_0x449ca4,_0x37f30d){return new BPromise(function(_0x13d006,_0x3d32fa){return client[_0xd8c9('0xd')](_0x3c5a05,_0x37f30d)['then'](function(_0x47cdbe){logger['info'](_0xd8c9('0xe'),_0x449ca4,_0xd8c9('0xf'));logger['debug']('SugarcrmAccount,\x20%s,\x20%s,\x20%s',_0x449ca4,_0xd8c9('0xf'),JSON['stringify'](_0x47cdbe));if(_0x47cdbe['error']){if(_0x47cdbe[_0xd8c9('0x10')][_0xd8c9('0x11')]===0x1f4){logger[_0xd8c9('0x10')]('SugarcrmAccount,\x20%s,\x20%s',_0x449ca4,_0x47cdbe['error'][_0xd8c9('0x12')]);return _0x3d32fa(_0x47cdbe['error'][_0xd8c9('0x12')]);}logger[_0xd8c9('0x10')]('SugarcrmAccount,\x20%s,\x20%s',_0x449ca4,_0x47cdbe[_0xd8c9('0x10')][_0xd8c9('0x12')]);return _0x13d006(_0x47cdbe[_0xd8c9('0x10')]['message']);}else{logger[_0xd8c9('0x13')]('SugarcrmAccount,\x20%s,\x20%s',_0x449ca4,_0xd8c9('0xf'));_0x13d006(_0x47cdbe[_0xd8c9('0x14')]['message']);}})[_0xd8c9('0x15')](function(_0xc24939){logger[_0xd8c9('0x10')](_0xd8c9('0xe'),_0x449ca4,_0xc24939);_0x3d32fa(_0xc24939);});});}exports['GetSugarcrmAccount']=function(_0x446305){var _0x583861=this;return new Promise(function(_0x1db8da,_0x2f968e){return db[_0xd8c9('0x16')]['findAll']({'raw':_0x446305[_0xd8c9('0x17')]?_0x446305[_0xd8c9('0x17')][_0xd8c9('0x18')]===undefined?!![]:![]:!![],'where':_0x446305[_0xd8c9('0x17')]?_0x446305[_0xd8c9('0x17')][_0xd8c9('0x19')]||null:null,'attributes':_0x446305[_0xd8c9('0x17')]?_0x446305[_0xd8c9('0x17')][_0xd8c9('0x1a')]||null:null,'limit':_0x446305['options']?_0x446305[_0xd8c9('0x17')][_0xd8c9('0x1b')]||null:null,'include':_0x446305[_0xd8c9('0x17')]?_0x446305['options'][_0xd8c9('0x1c')]?_[_0xd8c9('0x1d')](_0x446305['options'][_0xd8c9('0x1c')],function(_0x3009e5){return{'model':db[_0x3009e5[_0xd8c9('0x1e')]],'as':_0x3009e5['as'],'attributes':_0x3009e5[_0xd8c9('0x1a')],'include':_0x3009e5['include']?_['map'](_0x3009e5['include'],function(_0x46c73e){return{'model':db[_0x46c73e[_0xd8c9('0x1e')]],'as':_0x46c73e['as'],'attributes':_0x46c73e['attributes'],'include':_0x46c73e[_0xd8c9('0x1c')]?_[_0xd8c9('0x1d')](_0x46c73e[_0xd8c9('0x1c')],function(_0x4cdb10){return{'model':db[_0x4cdb10[_0xd8c9('0x1e')]],'as':_0x4cdb10['as'],'attributes':_0x4cdb10[_0xd8c9('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xd8c9('0x1f')](function(_0x4600be){logger[_0xd8c9('0x13')](_0xd8c9('0x20'),_0x446305);logger[_0xd8c9('0x21')]('GetSugarcrmAccount',_0x446305,JSON['stringify'](_0x4600be));_0x1db8da(_0x4600be);})[_0xd8c9('0x15')](function(_0x5bbcf2){logger[_0xd8c9('0x10')](_0xd8c9('0x20'),_0x5bbcf2['message'],_0x446305);_0x2f968e(_0x583861[_0xd8c9('0x10')](0x1f4,_0x5bbcf2[_0xd8c9('0x12')]));});});};exports['ShowSugarcrmAccount']=function(_0x59f8b6){var _0x4d406c=this;return new Promise(function(_0x276695,_0x5013e1){return db[_0xd8c9('0x16')][_0xd8c9('0x22')]({'raw':_0x59f8b6[_0xd8c9('0x17')]?_0x59f8b6[_0xd8c9('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x59f8b6[_0xd8c9('0x17')]?_0x59f8b6['options'][_0xd8c9('0x19')]||null:null,'attributes':_0x59f8b6['options']?_0x59f8b6[_0xd8c9('0x17')][_0xd8c9('0x1a')]||null:null,'include':_0x59f8b6[_0xd8c9('0x17')]?_0x59f8b6[_0xd8c9('0x17')]['include']?_[_0xd8c9('0x1d')](_0x59f8b6[_0xd8c9('0x17')][_0xd8c9('0x1c')],function(_0x3d355b){return{'model':db[_0x3d355b[_0xd8c9('0x1e')]],'as':_0x3d355b['as'],'attributes':_0x3d355b[_0xd8c9('0x1a')],'include':_0x3d355b['include']?_[_0xd8c9('0x1d')](_0x3d355b[_0xd8c9('0x1c')],function(_0x52addd){return{'model':db[_0x52addd[_0xd8c9('0x1e')]],'as':_0x52addd['as'],'attributes':_0x52addd[_0xd8c9('0x1a')],'include':_0x52addd['include']?_['map'](_0x52addd[_0xd8c9('0x1c')],function(_0x5e189f){return{'model':db[_0x5e189f[_0xd8c9('0x1e')]],'as':_0x5e189f['as'],'attributes':_0x5e189f[_0xd8c9('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xd8c9('0x1f')](function(_0x79a122){logger[_0xd8c9('0x13')](_0xd8c9('0x23'),_0x59f8b6);logger[_0xd8c9('0x21')](_0xd8c9('0x23'),_0x59f8b6,JSON[_0xd8c9('0x24')](_0x79a122));_0x276695(_0x79a122);})['catch'](function(_0x9d61bd){logger[_0xd8c9('0x10')]('ShowSugarcrmAccount',_0x9d61bd[_0xd8c9('0x12')],_0x59f8b6);_0x5013e1(_0x4d406c[_0xd8c9('0x10')](0x1f4,_0x9d61bd[_0xd8c9('0x12')]));});});};