Built motion from commit (unavailable).|2.5.0
[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 _0xf15f=['rpc','../../config/environment','jayson/promise','client','http','request','info','request\x20sent','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','stringify','error','SugarcrmAccount,\x20%s,\x20%s','message','result','catch','options','where','attributes','limit','include','model','then','GetSugarcrmAccount','ShowSugarcrmAccount','SugarcrmAccount','find','map','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x1c9cfb,_0x4efc3b){var _0x32436a=function(_0x6836da){while(--_0x6836da){_0x1c9cfb['push'](_0x1c9cfb['shift']());}};_0x32436a(++_0x4efc3b);}(_0xf15f,0x160));var _0xff15=function(_0x17d9e3,_0x1f969c){_0x17d9e3=_0x17d9e3-0x0;var _0x14192d=_0xf15f[_0x17d9e3];return _0x14192d;};'use strict';var _=require(_0xff15('0x0'));var util=require(_0xff15('0x1'));var moment=require('moment');var BPromise=require(_0xff15('0x2'));var rs=require(_0xff15('0x3'));var fs=require('fs');var Redis=require(_0xff15('0x4'));var db=require(_0xff15('0x5'))['db'];var utils=require(_0xff15('0x6'));var logger=require(_0xff15('0x7'))(_0xff15('0x8'));var config=require(_0xff15('0x9'));var jayson=require(_0xff15('0xa'));var client=jayson[_0xff15('0xb')][_0xff15('0xc')]({'port':0x232a});function respondWithRpcPromise(_0xfd2c09,_0x17b9af,_0x733af3){return new BPromise(function(_0x46a491,_0x4db6eb){return client[_0xff15('0xd')](_0xfd2c09,_0x733af3)['then'](function(_0x333ef8){logger[_0xff15('0xe')]('SugarcrmAccount,\x20%s,\x20%s',_0x17b9af,_0xff15('0xf'));logger[_0xff15('0x10')](_0xff15('0x11'),_0x17b9af,'request\x20sent',JSON[_0xff15('0x12')](_0x333ef8));if(_0x333ef8['error']){if(_0x333ef8[_0xff15('0x13')]['code']===0x1f4){logger['error'](_0xff15('0x14'),_0x17b9af,_0x333ef8[_0xff15('0x13')][_0xff15('0x15')]);return _0x4db6eb(_0x333ef8[_0xff15('0x13')][_0xff15('0x15')]);}logger[_0xff15('0x13')](_0xff15('0x14'),_0x17b9af,_0x333ef8[_0xff15('0x13')][_0xff15('0x15')]);return _0x46a491(_0x333ef8[_0xff15('0x13')][_0xff15('0x15')]);}else{logger['info'](_0xff15('0x14'),_0x17b9af,_0xff15('0xf'));_0x46a491(_0x333ef8[_0xff15('0x16')][_0xff15('0x15')]);}})[_0xff15('0x17')](function(_0x384114){logger[_0xff15('0x13')](_0xff15('0x14'),_0x17b9af,_0x384114);_0x4db6eb(_0x384114);});});}exports['GetSugarcrmAccount']=function(_0x5e9996){var _0xd5bbe3=this;return new Promise(function(_0x1c15e0,_0x287b22){return db['SugarcrmAccount']['findAll']({'raw':_0x5e9996[_0xff15('0x18')]?_0x5e9996['options']['raw']===undefined?!![]:![]:!![],'where':_0x5e9996[_0xff15('0x18')]?_0x5e9996[_0xff15('0x18')][_0xff15('0x19')]||null:null,'attributes':_0x5e9996['options']?_0x5e9996[_0xff15('0x18')][_0xff15('0x1a')]||null:null,'limit':_0x5e9996[_0xff15('0x18')]?_0x5e9996[_0xff15('0x18')][_0xff15('0x1b')]||null:null,'include':_0x5e9996[_0xff15('0x18')]?_0x5e9996[_0xff15('0x18')]['include']?_['map'](_0x5e9996[_0xff15('0x18')][_0xff15('0x1c')],function(_0xdb0817){return{'model':db[_0xdb0817[_0xff15('0x1d')]],'as':_0xdb0817['as'],'attributes':_0xdb0817[_0xff15('0x1a')],'include':_0xdb0817[_0xff15('0x1c')]?_['map'](_0xdb0817[_0xff15('0x1c')],function(_0x4b4aa6){return{'model':db[_0x4b4aa6[_0xff15('0x1d')]],'as':_0x4b4aa6['as'],'attributes':_0x4b4aa6[_0xff15('0x1a')],'include':_0x4b4aa6['include']?_['map'](_0x4b4aa6[_0xff15('0x1c')],function(_0x164976){return{'model':db[_0x164976[_0xff15('0x1d')]],'as':_0x164976['as'],'attributes':_0x164976['attributes']};}):[]};}):[]};}):[]:[]})[_0xff15('0x1e')](function(_0x5880ff){logger[_0xff15('0xe')](_0xff15('0x1f'),_0x5e9996);logger['debug'](_0xff15('0x1f'),_0x5e9996,JSON[_0xff15('0x12')](_0x5880ff));_0x1c15e0(_0x5880ff);})['catch'](function(_0x4ea52e){logger[_0xff15('0x13')](_0xff15('0x1f'),_0x4ea52e[_0xff15('0x15')],_0x5e9996);_0x287b22(_0xd5bbe3[_0xff15('0x13')](0x1f4,_0x4ea52e['message']));});});};exports[_0xff15('0x20')]=function(_0x2225e5){var _0x10f58a=this;return new Promise(function(_0x26b3bd,_0x52e08f){return db[_0xff15('0x21')][_0xff15('0x22')]({'raw':_0x2225e5[_0xff15('0x18')]?_0x2225e5[_0xff15('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x2225e5['options']?_0x2225e5[_0xff15('0x18')][_0xff15('0x19')]||null:null,'attributes':_0x2225e5[_0xff15('0x18')]?_0x2225e5[_0xff15('0x18')][_0xff15('0x1a')]||null:null,'include':_0x2225e5[_0xff15('0x18')]?_0x2225e5['options']['include']?_[_0xff15('0x23')](_0x2225e5[_0xff15('0x18')][_0xff15('0x1c')],function(_0x74585){return{'model':db[_0x74585[_0xff15('0x1d')]],'as':_0x74585['as'],'attributes':_0x74585[_0xff15('0x1a')],'include':_0x74585['include']?_['map'](_0x74585[_0xff15('0x1c')],function(_0x1fd752){return{'model':db[_0x1fd752['model']],'as':_0x1fd752['as'],'attributes':_0x1fd752[_0xff15('0x1a')],'include':_0x1fd752[_0xff15('0x1c')]?_[_0xff15('0x23')](_0x1fd752['include'],function(_0x3fcf4b){return{'model':db[_0x3fcf4b[_0xff15('0x1d')]],'as':_0x3fcf4b['as'],'attributes':_0x3fcf4b[_0xff15('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xff15('0x1e')](function(_0x4c8f59){logger['info'](_0xff15('0x20'),_0x2225e5);logger[_0xff15('0x10')](_0xff15('0x20'),_0x2225e5,JSON[_0xff15('0x12')](_0x4c8f59));_0x26b3bd(_0x4c8f59);})[_0xff15('0x17')](function(_0x3fca8d){logger[_0xff15('0x13')](_0xff15('0x20'),_0x3fca8d[_0xff15('0x15')],_0x2225e5);_0x52e08f(_0x10f58a[_0xff15('0x13')](0x1f4,_0x3fca8d[_0xff15('0x15')]));});});};