70992252c64c1dffa27c000030e64377730d1e9c
[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 _0x371f=['limit','include','map','model','attributes','GetSalesforceAccount','find','raw','ShowSalesforceAccount','lodash','util','bluebird','randomstring','../../config/utils','../../config/logger','jayson/promise','http','then','info','SalesforceAccount,\x20%s,\x20%s','request\x20sent','debug','SalesforceAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','SalesforceAccount','findAll','options','where'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0x371f,0x169));var _0xf371=function(_0x47310d,_0x5ca972){_0x47310d=_0x47310d-0x0;var _0x14d55d=_0x371f[_0x47310d];return _0x14d55d;};'use strict';var _=require(_0xf371('0x0'));var util=require(_0xf371('0x1'));var moment=require('moment');var BPromise=require(_0xf371('0x2'));var rs=require(_0xf371('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xf371('0x4'));var logger=require(_0xf371('0x5'))('rpc');var config=require('../../config/environment');var jayson=require(_0xf371('0x6'));var client=jayson['client'][_0xf371('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x4c1e4e,_0x524a10,_0x19aeb4){return new BPromise(function(_0x2ce251,_0x50a4aa){return client['request'](_0x4c1e4e,_0x19aeb4)[_0xf371('0x8')](function(_0x5022cb){logger[_0xf371('0x9')](_0xf371('0xa'),_0x524a10,_0xf371('0xb'));logger[_0xf371('0xc')](_0xf371('0xd'),_0x524a10,_0xf371('0xb'),JSON[_0xf371('0xe')](_0x5022cb));if(_0x5022cb['error']){if(_0x5022cb[_0xf371('0xf')]['code']===0x1f4){logger[_0xf371('0xf')](_0xf371('0xa'),_0x524a10,_0x5022cb['error'][_0xf371('0x10')]);return _0x50a4aa(_0x5022cb['error']['message']);}logger['error'](_0xf371('0xa'),_0x524a10,_0x5022cb[_0xf371('0xf')][_0xf371('0x10')]);return _0x2ce251(_0x5022cb['error'][_0xf371('0x10')]);}else{logger[_0xf371('0x9')](_0xf371('0xa'),_0x524a10,_0xf371('0xb'));_0x2ce251(_0x5022cb[_0xf371('0x11')][_0xf371('0x10')]);}})[_0xf371('0x12')](function(_0x24c51d){logger[_0xf371('0xf')](_0xf371('0xa'),_0x524a10,_0x24c51d);_0x50a4aa(_0x24c51d);});});}exports['GetSalesforceAccount']=function(_0x35794b){var _0x2d6ea0=this;return new Promise(function(_0x2f6efb,_0x8c1fa8){return db[_0xf371('0x13')][_0xf371('0x14')]({'raw':_0x35794b[_0xf371('0x15')]?_0x35794b[_0xf371('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x35794b['options']?_0x35794b['options'][_0xf371('0x16')]||null:null,'attributes':_0x35794b[_0xf371('0x15')]?_0x35794b[_0xf371('0x15')]['attributes']||null:null,'limit':_0x35794b['options']?_0x35794b[_0xf371('0x15')][_0xf371('0x17')]||null:null,'include':_0x35794b['options']?_0x35794b[_0xf371('0x15')][_0xf371('0x18')]?_[_0xf371('0x19')](_0x35794b['options']['include'],function(_0x12f396){return{'model':db[_0x12f396[_0xf371('0x1a')]],'as':_0x12f396['as'],'attributes':_0x12f396[_0xf371('0x1b')],'include':_0x12f396[_0xf371('0x18')]?_[_0xf371('0x19')](_0x12f396['include'],function(_0x1db469){return{'model':db[_0x1db469[_0xf371('0x1a')]],'as':_0x1db469['as'],'attributes':_0x1db469[_0xf371('0x1b')],'include':_0x1db469[_0xf371('0x18')]?_['map'](_0x1db469[_0xf371('0x18')],function(_0xf2cffa){return{'model':db[_0xf2cffa[_0xf371('0x1a')]],'as':_0xf2cffa['as'],'attributes':_0xf2cffa[_0xf371('0x1b')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x36e7f4){logger['info'](_0xf371('0x1c'),_0x35794b);logger['debug'](_0xf371('0x1c'),_0x35794b,JSON['stringify'](_0x36e7f4));_0x2f6efb(_0x36e7f4);})['catch'](function(_0x192d8d){logger[_0xf371('0xf')](_0xf371('0x1c'),_0x192d8d[_0xf371('0x10')],_0x35794b);_0x8c1fa8(_0x2d6ea0[_0xf371('0xf')](0x1f4,_0x192d8d[_0xf371('0x10')]));});});};exports['ShowSalesforceAccount']=function(_0x35315c){var _0xb3688a=this;return new Promise(function(_0x12406a,_0x4a86e5){return db[_0xf371('0x13')][_0xf371('0x1d')]({'raw':_0x35315c[_0xf371('0x15')]?_0x35315c[_0xf371('0x15')][_0xf371('0x1e')]===undefined?!![]:![]:!![],'where':_0x35315c[_0xf371('0x15')]?_0x35315c[_0xf371('0x15')][_0xf371('0x16')]||null:null,'attributes':_0x35315c[_0xf371('0x15')]?_0x35315c[_0xf371('0x15')]['attributes']||null:null,'include':_0x35315c[_0xf371('0x15')]?_0x35315c['options'][_0xf371('0x18')]?_[_0xf371('0x19')](_0x35315c[_0xf371('0x15')][_0xf371('0x18')],function(_0xf1d593){return{'model':db[_0xf1d593[_0xf371('0x1a')]],'as':_0xf1d593['as'],'attributes':_0xf1d593[_0xf371('0x1b')],'include':_0xf1d593[_0xf371('0x18')]?_['map'](_0xf1d593[_0xf371('0x18')],function(_0x26a611){return{'model':db[_0x26a611[_0xf371('0x1a')]],'as':_0x26a611['as'],'attributes':_0x26a611[_0xf371('0x1b')],'include':_0x26a611[_0xf371('0x18')]?_[_0xf371('0x19')](_0x26a611[_0xf371('0x18')],function(_0x4dbc94){return{'model':db[_0x4dbc94[_0xf371('0x1a')]],'as':_0x4dbc94['as'],'attributes':_0x4dbc94[_0xf371('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xf371('0x8')](function(_0x24e9dc){logger['info'](_0xf371('0x1f'),_0x35315c);logger['debug'](_0xf371('0x1f'),_0x35315c,JSON['stringify'](_0x24e9dc));_0x12406a(_0x24e9dc);})['catch'](function(_0x48027b){logger[_0xf371('0xf')](_0xf371('0x1f'),_0x48027b[_0xf371('0x10')],_0x35315c);_0x4a86e5(_0xb3688a[_0xf371('0xf')](0x1f4,_0x48027b['message']));});});};