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 _0x2464=['result','catch','GetSugarcrmAccount','SugarcrmAccount','findAll','options','raw','attributes','include','model','map','then','message','ShowSugarcrmAccount','find','where','lodash','util','bluebird','randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','client','request','info','SugarcrmAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code'];(function(_0x800883,_0x397c5d){var _0x3e44e9=function(_0xa82521){while(--_0xa82521){_0x800883['push'](_0x800883['shift']());}};_0x3e44e9(++_0x397c5d);}(_0x2464,0x15a));var _0x4246=function(_0x29647c,_0x92be9e){_0x29647c=_0x29647c-0x0;var _0x276458=_0x2464[_0x29647c];return _0x276458;};'use strict';var _=require(_0x4246('0x0'));var util=require(_0x4246('0x1'));var moment=require('moment');var BPromise=require(_0x4246('0x2'));var rs=require(_0x4246('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x4246('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x4246('0x5'))(_0x4246('0x6'));var config=require(_0x4246('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x4246('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x43f904,_0x545bfd,_0x3b61c8){return new BPromise(function(_0x24ca34,_0x25389a){return client[_0x4246('0x9')](_0x43f904,_0x3b61c8)['then'](function(_0xc1ed68){logger[_0x4246('0xa')](_0x4246('0xb'),_0x545bfd,_0x4246('0xc'));logger[_0x4246('0xd')]('SugarcrmAccount,\x20%s,\x20%s,\x20%s',_0x545bfd,'request\x20sent',JSON[_0x4246('0xe')](_0xc1ed68));if(_0xc1ed68[_0x4246('0xf')]){if(_0xc1ed68[_0x4246('0xf')][_0x4246('0x10')]===0x1f4){logger['error'](_0x4246('0xb'),_0x545bfd,_0xc1ed68[_0x4246('0xf')]['message']);return _0x25389a(_0xc1ed68[_0x4246('0xf')]['message']);}logger[_0x4246('0xf')](_0x4246('0xb'),_0x545bfd,_0xc1ed68['error']['message']);return _0x24ca34(_0xc1ed68[_0x4246('0xf')]['message']);}else{logger['info'](_0x4246('0xb'),_0x545bfd,_0x4246('0xc'));_0x24ca34(_0xc1ed68[_0x4246('0x11')]['message']);}})[_0x4246('0x12')](function(_0x94b307){logger[_0x4246('0xf')](_0x4246('0xb'),_0x545bfd,_0x94b307);_0x25389a(_0x94b307);});});}exports[_0x4246('0x13')]=function(_0x122020){var _0x10bc7e=this;return new Promise(function(_0x333522,_0x1dd7bb){return db[_0x4246('0x14')][_0x4246('0x15')]({'raw':_0x122020[_0x4246('0x16')]?_0x122020['options'][_0x4246('0x17')]===undefined?!![]:![]:!![],'where':_0x122020[_0x4246('0x16')]?_0x122020['options']['where']||null:null,'attributes':_0x122020['options']?_0x122020[_0x4246('0x16')][_0x4246('0x18')]||null:null,'limit':_0x122020[_0x4246('0x16')]?_0x122020[_0x4246('0x16')]['limit']||null:null,'include':_0x122020['options']?_0x122020[_0x4246('0x16')][_0x4246('0x19')]?_['map'](_0x122020[_0x4246('0x16')][_0x4246('0x19')],function(_0x44ea86){return{'model':db[_0x44ea86[_0x4246('0x1a')]],'as':_0x44ea86['as'],'attributes':_0x44ea86['attributes'],'include':_0x44ea86[_0x4246('0x19')]?_[_0x4246('0x1b')](_0x44ea86[_0x4246('0x19')],function(_0x2049fc){return{'model':db[_0x2049fc['model']],'as':_0x2049fc['as'],'attributes':_0x2049fc[_0x4246('0x18')],'include':_0x2049fc[_0x4246('0x19')]?_[_0x4246('0x1b')](_0x2049fc[_0x4246('0x19')],function(_0x52a50b){return{'model':db[_0x52a50b[_0x4246('0x1a')]],'as':_0x52a50b['as'],'attributes':_0x52a50b[_0x4246('0x18')]};}):[]};}):[]};}):[]:[]})[_0x4246('0x1c')](function(_0x216989){logger[_0x4246('0xa')](_0x4246('0x13'),_0x122020);logger[_0x4246('0xd')](_0x4246('0x13'),_0x122020,JSON[_0x4246('0xe')](_0x216989));_0x333522(_0x216989);})[_0x4246('0x12')](function(_0x4d9f05){logger[_0x4246('0xf')](_0x4246('0x13'),_0x4d9f05[_0x4246('0x1d')],_0x122020);_0x1dd7bb(_0x10bc7e[_0x4246('0xf')](0x1f4,_0x4d9f05[_0x4246('0x1d')]));});});};exports[_0x4246('0x1e')]=function(_0x90eacd){var _0x4a9802=this;return new Promise(function(_0x4417af,_0x42ed94){return db[_0x4246('0x14')][_0x4246('0x1f')]({'raw':_0x90eacd[_0x4246('0x16')]?_0x90eacd[_0x4246('0x16')][_0x4246('0x17')]===undefined?!![]:![]:!![],'where':_0x90eacd['options']?_0x90eacd[_0x4246('0x16')][_0x4246('0x20')]||null:null,'attributes':_0x90eacd[_0x4246('0x16')]?_0x90eacd['options'][_0x4246('0x18')]||null:null,'include':_0x90eacd[_0x4246('0x16')]?_0x90eacd[_0x4246('0x16')]['include']?_[_0x4246('0x1b')](_0x90eacd['options']['include'],function(_0x5bd66c){return{'model':db[_0x5bd66c[_0x4246('0x1a')]],'as':_0x5bd66c['as'],'attributes':_0x5bd66c[_0x4246('0x18')],'include':_0x5bd66c['include']?_[_0x4246('0x1b')](_0x5bd66c[_0x4246('0x19')],function(_0x41752f){return{'model':db[_0x41752f[_0x4246('0x1a')]],'as':_0x41752f['as'],'attributes':_0x41752f['attributes'],'include':_0x41752f[_0x4246('0x19')]?_[_0x4246('0x1b')](_0x41752f[_0x4246('0x19')],function(_0x28c271){return{'model':db[_0x28c271[_0x4246('0x1a')]],'as':_0x28c271['as'],'attributes':_0x28c271[_0x4246('0x18')]};}):[]};}):[]};}):[]:[]})[_0x4246('0x1c')](function(_0x285f4d){logger['info'](_0x4246('0x1e'),_0x90eacd);logger[_0x4246('0xd')]('ShowSugarcrmAccount',_0x90eacd,JSON[_0x4246('0xe')](_0x285f4d));_0x4417af(_0x285f4d);})['catch'](function(_0x310caf){logger['error'](_0x4246('0x1e'),_0x310caf[_0x4246('0x1d')],_0x90eacd);_0x42ed94(_0x4a9802['error'](0x1f4,_0x310caf[_0x4246('0x1d')]));});});};