f9ad8a07f2e735ce23b76b8898d3bfa6d7502c41
[motion2.git] / server / api / intSalesforceAccount / intSalesforceAccount.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 _0xd64b=['include','map','model','then','ShowSalesforceAccount','find','debug','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','http','request','info','SalesforceAccount,\x20%s,\x20%s','request\x20sent','SalesforceAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetSalesforceAccount','SalesforceAccount','options','where','attributes'];(function(_0x4ecbba,_0x3c366f){var _0x569384=function(_0x38a8a5){while(--_0x38a8a5){_0x4ecbba['push'](_0x4ecbba['shift']());}};_0x569384(++_0x3c366f);}(_0xd64b,0xc1));var _0xbd64=function(_0x574e54,_0x2c5784){_0x574e54=_0x574e54-0x0;var _0x581fc5=_0xd64b[_0x574e54];return _0x581fc5;};'use strict';var _=require(_0xbd64('0x0'));var util=require('util');var moment=require(_0xbd64('0x1'));var BPromise=require('bluebird');var rs=require(_0xbd64('0x2'));var fs=require('fs');var Redis=require(_0xbd64('0x3'));var db=require(_0xbd64('0x4'))['db'];var utils=require(_0xbd64('0x5'));var logger=require(_0xbd64('0x6'))('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0xbd64('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x32995f,_0x3e700e,_0x38204e){return new BPromise(function(_0x3f1f17,_0x2b8543){return client[_0xbd64('0x8')](_0x32995f,_0x38204e)['then'](function(_0x5ae70c){logger[_0xbd64('0x9')](_0xbd64('0xa'),_0x3e700e,_0xbd64('0xb'));logger['debug'](_0xbd64('0xc'),_0x3e700e,_0xbd64('0xb'),JSON[_0xbd64('0xd')](_0x5ae70c));if(_0x5ae70c[_0xbd64('0xe')]){if(_0x5ae70c['error'][_0xbd64('0xf')]===0x1f4){logger['error'](_0xbd64('0xa'),_0x3e700e,_0x5ae70c[_0xbd64('0xe')][_0xbd64('0x10')]);return _0x2b8543(_0x5ae70c[_0xbd64('0xe')][_0xbd64('0x10')]);}logger[_0xbd64('0xe')](_0xbd64('0xa'),_0x3e700e,_0x5ae70c[_0xbd64('0xe')][_0xbd64('0x10')]);return _0x3f1f17(_0x5ae70c['error'][_0xbd64('0x10')]);}else{logger[_0xbd64('0x9')](_0xbd64('0xa'),_0x3e700e,_0xbd64('0xb'));_0x3f1f17(_0x5ae70c[_0xbd64('0x11')]['message']);}})[_0xbd64('0x12')](function(_0x5332e0){logger[_0xbd64('0xe')](_0xbd64('0xa'),_0x3e700e,_0x5332e0);_0x2b8543(_0x5332e0);});});}exports[_0xbd64('0x13')]=function(_0x1d7a14){var _0x17d015=this;return new Promise(function(_0x2f4554,_0xa5491d){return db[_0xbd64('0x14')]['findAll']({'raw':_0x1d7a14[_0xbd64('0x15')]?_0x1d7a14[_0xbd64('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x1d7a14['options']?_0x1d7a14[_0xbd64('0x15')][_0xbd64('0x16')]||null:null,'attributes':_0x1d7a14[_0xbd64('0x15')]?_0x1d7a14[_0xbd64('0x15')][_0xbd64('0x17')]||null:null,'limit':_0x1d7a14[_0xbd64('0x15')]?_0x1d7a14['options']['limit']||null:null,'include':_0x1d7a14[_0xbd64('0x15')]?_0x1d7a14[_0xbd64('0x15')][_0xbd64('0x18')]?_[_0xbd64('0x19')](_0x1d7a14['options']['include'],function(_0x28497c){return{'model':db[_0x28497c['model']],'as':_0x28497c['as'],'attributes':_0x28497c[_0xbd64('0x17')],'include':_0x28497c['include']?_[_0xbd64('0x19')](_0x28497c[_0xbd64('0x18')],function(_0x3d12a0){return{'model':db[_0x3d12a0[_0xbd64('0x1a')]],'as':_0x3d12a0['as'],'attributes':_0x3d12a0['attributes'],'include':_0x3d12a0[_0xbd64('0x18')]?_[_0xbd64('0x19')](_0x3d12a0[_0xbd64('0x18')],function(_0x2a44d0){return{'model':db[_0x2a44d0['model']],'as':_0x2a44d0['as'],'attributes':_0x2a44d0['attributes']};}):[]};}):[]};}):[]:[]})[_0xbd64('0x1b')](function(_0x49eac5){logger['info'](_0xbd64('0x13'),_0x1d7a14);logger['debug'](_0xbd64('0x13'),_0x1d7a14,JSON['stringify'](_0x49eac5));_0x2f4554(_0x49eac5);})[_0xbd64('0x12')](function(_0x5d8c35){logger[_0xbd64('0xe')](_0xbd64('0x13'),_0x5d8c35[_0xbd64('0x10')],_0x1d7a14);_0xa5491d(_0x17d015[_0xbd64('0xe')](0x1f4,_0x5d8c35[_0xbd64('0x10')]));});});};exports[_0xbd64('0x1c')]=function(_0x4ed44a){var _0x35bdd5=this;return new Promise(function(_0xe876c9,_0xc44280){return db[_0xbd64('0x14')][_0xbd64('0x1d')]({'raw':_0x4ed44a[_0xbd64('0x15')]?_0x4ed44a['options']['raw']===undefined?!![]:![]:!![],'where':_0x4ed44a[_0xbd64('0x15')]?_0x4ed44a['options'][_0xbd64('0x16')]||null:null,'attributes':_0x4ed44a[_0xbd64('0x15')]?_0x4ed44a['options']['attributes']||null:null,'include':_0x4ed44a[_0xbd64('0x15')]?_0x4ed44a['options']['include']?_[_0xbd64('0x19')](_0x4ed44a[_0xbd64('0x15')][_0xbd64('0x18')],function(_0x50c58e){return{'model':db[_0x50c58e[_0xbd64('0x1a')]],'as':_0x50c58e['as'],'attributes':_0x50c58e['attributes'],'include':_0x50c58e[_0xbd64('0x18')]?_[_0xbd64('0x19')](_0x50c58e[_0xbd64('0x18')],function(_0x243588){return{'model':db[_0x243588[_0xbd64('0x1a')]],'as':_0x243588['as'],'attributes':_0x243588[_0xbd64('0x17')],'include':_0x243588['include']?_['map'](_0x243588[_0xbd64('0x18')],function(_0x2be110){return{'model':db[_0x2be110[_0xbd64('0x1a')]],'as':_0x2be110['as'],'attributes':_0x2be110[_0xbd64('0x17')]};}):[]};}):[]};}):[]:[]})[_0xbd64('0x1b')](function(_0x3b245e){logger['info']('ShowSalesforceAccount',_0x4ed44a);logger[_0xbd64('0x1e')](_0xbd64('0x1c'),_0x4ed44a,JSON[_0xbd64('0xd')](_0x3b245e));_0xe876c9(_0x3b245e);})['catch'](function(_0x5afe9b){logger[_0xbd64('0xe')]('ShowSalesforceAccount',_0x5afe9b[_0xbd64('0x10')],_0x4ed44a);_0xc44280(_0x35bdd5['error'](0x1f4,_0x5afe9b[_0xbd64('0x10')]));});});};