42392bf691ea79d0f50e27eeaca282a4a195e2d7
[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 _0x6b15=['where','attributes','limit','include','map','model','find','then','ShowSugarcrmAccount','stringify','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','info','request\x20sent','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','error','code','SugarcrmAccount,\x20%s,\x20%s','message','result','catch','GetSugarcrmAccount','SugarcrmAccount','findAll','options','raw'];(function(_0x5b78e8,_0x55096b){var _0xf2c321=function(_0x4e0cff){while(--_0x4e0cff){_0x5b78e8['push'](_0x5b78e8['shift']());}};_0xf2c321(++_0x55096b);}(_0x6b15,0x132));var _0x56b1=function(_0x155038,_0x91f83e){_0x155038=_0x155038-0x0;var _0x1a6685=_0x6b15[_0x155038];return _0x1a6685;};'use strict';var _=require('lodash');var util=require(_0x56b1('0x0'));var moment=require(_0x56b1('0x1'));var BPromise=require(_0x56b1('0x2'));var rs=require(_0x56b1('0x3'));var fs=require('fs');var Redis=require(_0x56b1('0x4'));var db=require(_0x56b1('0x5'))['db'];var utils=require(_0x56b1('0x6'));var logger=require(_0x56b1('0x7'))(_0x56b1('0x8'));var config=require(_0x56b1('0x9'));var jayson=require(_0x56b1('0xa'));var client=jayson[_0x56b1('0xb')]['http']({'port':0x232a});function respondWithRpcPromise(_0xae3304,_0x2a626c,_0x2b2cf7){return new BPromise(function(_0x5bf0ab,_0x52ecc6){return client['request'](_0xae3304,_0x2b2cf7)['then'](function(_0x5a5056){logger[_0x56b1('0xc')]('SugarcrmAccount,\x20%s,\x20%s',_0x2a626c,_0x56b1('0xd'));logger[_0x56b1('0xe')](_0x56b1('0xf'),_0x2a626c,_0x56b1('0xd'),JSON['stringify'](_0x5a5056));if(_0x5a5056[_0x56b1('0x10')]){if(_0x5a5056[_0x56b1('0x10')][_0x56b1('0x11')]===0x1f4){logger[_0x56b1('0x10')](_0x56b1('0x12'),_0x2a626c,_0x5a5056[_0x56b1('0x10')][_0x56b1('0x13')]);return _0x52ecc6(_0x5a5056[_0x56b1('0x10')][_0x56b1('0x13')]);}logger[_0x56b1('0x10')](_0x56b1('0x12'),_0x2a626c,_0x5a5056['error'][_0x56b1('0x13')]);return _0x5bf0ab(_0x5a5056['error'][_0x56b1('0x13')]);}else{logger[_0x56b1('0xc')]('SugarcrmAccount,\x20%s,\x20%s',_0x2a626c,_0x56b1('0xd'));_0x5bf0ab(_0x5a5056[_0x56b1('0x14')][_0x56b1('0x13')]);}})[_0x56b1('0x15')](function(_0x362e94){logger['error']('SugarcrmAccount,\x20%s,\x20%s',_0x2a626c,_0x362e94);_0x52ecc6(_0x362e94);});});}exports[_0x56b1('0x16')]=function(_0x869eeb){var _0x57c0dc=this;return new Promise(function(_0x1abc38,_0xea9c46){return db[_0x56b1('0x17')][_0x56b1('0x18')]({'raw':_0x869eeb[_0x56b1('0x19')]?_0x869eeb[_0x56b1('0x19')][_0x56b1('0x1a')]===undefined?!![]:![]:!![],'where':_0x869eeb['options']?_0x869eeb['options'][_0x56b1('0x1b')]||null:null,'attributes':_0x869eeb['options']?_0x869eeb['options'][_0x56b1('0x1c')]||null:null,'limit':_0x869eeb[_0x56b1('0x19')]?_0x869eeb[_0x56b1('0x19')][_0x56b1('0x1d')]||null:null,'include':_0x869eeb[_0x56b1('0x19')]?_0x869eeb[_0x56b1('0x19')][_0x56b1('0x1e')]?_[_0x56b1('0x1f')](_0x869eeb[_0x56b1('0x19')][_0x56b1('0x1e')],function(_0x3ffb95){return{'model':db[_0x3ffb95[_0x56b1('0x20')]],'as':_0x3ffb95['as'],'attributes':_0x3ffb95[_0x56b1('0x1c')],'include':_0x3ffb95[_0x56b1('0x1e')]?_[_0x56b1('0x1f')](_0x3ffb95[_0x56b1('0x1e')],function(_0x9630f8){return{'model':db[_0x9630f8['model']],'as':_0x9630f8['as'],'attributes':_0x9630f8[_0x56b1('0x1c')],'include':_0x9630f8['include']?_[_0x56b1('0x1f')](_0x9630f8[_0x56b1('0x1e')],function(_0x3f9d63){return{'model':db[_0x3f9d63[_0x56b1('0x20')]],'as':_0x3f9d63['as'],'attributes':_0x3f9d63[_0x56b1('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x16f7a1){logger[_0x56b1('0xc')](_0x56b1('0x16'),_0x869eeb);logger[_0x56b1('0xe')](_0x56b1('0x16'),_0x869eeb,JSON['stringify'](_0x16f7a1));_0x1abc38(_0x16f7a1);})[_0x56b1('0x15')](function(_0x3320a7){logger['error'](_0x56b1('0x16'),_0x3320a7['message'],_0x869eeb);_0xea9c46(_0x57c0dc[_0x56b1('0x10')](0x1f4,_0x3320a7[_0x56b1('0x13')]));});});};exports['ShowSugarcrmAccount']=function(_0x2aa468){var _0x961a2d=this;return new Promise(function(_0x282b33,_0x3f129c){return db[_0x56b1('0x17')][_0x56b1('0x21')]({'raw':_0x2aa468[_0x56b1('0x19')]?_0x2aa468[_0x56b1('0x19')][_0x56b1('0x1a')]===undefined?!![]:![]:!![],'where':_0x2aa468[_0x56b1('0x19')]?_0x2aa468['options'][_0x56b1('0x1b')]||null:null,'attributes':_0x2aa468['options']?_0x2aa468['options'][_0x56b1('0x1c')]||null:null,'include':_0x2aa468[_0x56b1('0x19')]?_0x2aa468['options']['include']?_[_0x56b1('0x1f')](_0x2aa468[_0x56b1('0x19')][_0x56b1('0x1e')],function(_0x55c629){return{'model':db[_0x55c629[_0x56b1('0x20')]],'as':_0x55c629['as'],'attributes':_0x55c629[_0x56b1('0x1c')],'include':_0x55c629[_0x56b1('0x1e')]?_[_0x56b1('0x1f')](_0x55c629[_0x56b1('0x1e')],function(_0x267e28){return{'model':db[_0x267e28[_0x56b1('0x20')]],'as':_0x267e28['as'],'attributes':_0x267e28['attributes'],'include':_0x267e28[_0x56b1('0x1e')]?_['map'](_0x267e28[_0x56b1('0x1e')],function(_0x3beea2){return{'model':db[_0x3beea2[_0x56b1('0x20')]],'as':_0x3beea2['as'],'attributes':_0x3beea2[_0x56b1('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x56b1('0x22')](function(_0x274b8b){logger[_0x56b1('0xc')]('ShowSugarcrmAccount',_0x2aa468);logger[_0x56b1('0xe')](_0x56b1('0x23'),_0x2aa468,JSON[_0x56b1('0x24')](_0x274b8b));_0x282b33(_0x274b8b);})['catch'](function(_0x3e0690){logger[_0x56b1('0x10')](_0x56b1('0x23'),_0x3e0690[_0x56b1('0x13')],_0x2aa468);_0x3f129c(_0x961a2d[_0x56b1('0x10')](0x1f4,_0x3e0690[_0x56b1('0x13')]));});});};