Built motion from commit 19a84241.|2.5.34
[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 _0x0b11=['SalesforceAccount,\x20%s,\x20%s','request\x20sent','debug','SalesforceAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','GetSalesforceAccount','findAll','options','raw','where','limit','include','model','attributes','map','SalesforceAccount','ShowSalesforceAccount','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','then','info'];(function(_0x5e525a,_0x431e34){var _0x9537a4=function(_0x59249c){while(--_0x59249c){_0x5e525a['push'](_0x5e525a['shift']());}};_0x9537a4(++_0x431e34);}(_0x0b11,0xb5));var _0x10b1=function(_0x262bd9,_0x3f671c){_0x262bd9=_0x262bd9-0x0;var _0x2e3e0c=_0x0b11[_0x262bd9];return _0x2e3e0c;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0x10b1('0x0'));var rs=require(_0x10b1('0x1'));var fs=require('fs');var Redis=require(_0x10b1('0x2'));var db=require(_0x10b1('0x3'))['db'];var utils=require(_0x10b1('0x4'));var logger=require('../../config/logger')(_0x10b1('0x5'));var config=require(_0x10b1('0x6'));var jayson=require(_0x10b1('0x7'));var client=jayson[_0x10b1('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x25b951,_0x5a2e6b,_0x23de7c){return new BPromise(function(_0x117df6,_0x7e8985){return client['request'](_0x25b951,_0x23de7c)[_0x10b1('0x9')](function(_0xf1f77f){logger[_0x10b1('0xa')](_0x10b1('0xb'),_0x5a2e6b,_0x10b1('0xc'));logger[_0x10b1('0xd')](_0x10b1('0xe'),_0x5a2e6b,_0x10b1('0xc'),JSON[_0x10b1('0xf')](_0xf1f77f));if(_0xf1f77f[_0x10b1('0x10')]){if(_0xf1f77f['error']['code']===0x1f4){logger['error'](_0x10b1('0xb'),_0x5a2e6b,_0xf1f77f[_0x10b1('0x10')][_0x10b1('0x11')]);return _0x7e8985(_0xf1f77f[_0x10b1('0x10')][_0x10b1('0x11')]);}logger[_0x10b1('0x10')](_0x10b1('0xb'),_0x5a2e6b,_0xf1f77f[_0x10b1('0x10')]['message']);return _0x117df6(_0xf1f77f[_0x10b1('0x10')][_0x10b1('0x11')]);}else{logger[_0x10b1('0xa')](_0x10b1('0xb'),_0x5a2e6b,_0x10b1('0xc'));_0x117df6(_0xf1f77f[_0x10b1('0x12')][_0x10b1('0x11')]);}})[_0x10b1('0x13')](function(_0x1e61ce){logger[_0x10b1('0x10')](_0x10b1('0xb'),_0x5a2e6b,_0x1e61ce);_0x7e8985(_0x1e61ce);});});}exports[_0x10b1('0x14')]=function(_0x5bd1af){var _0x5928e4=this;return new Promise(function(_0x3df301,_0x2769ea){return db['SalesforceAccount'][_0x10b1('0x15')]({'raw':_0x5bd1af[_0x10b1('0x16')]?_0x5bd1af[_0x10b1('0x16')][_0x10b1('0x17')]===undefined?!![]:![]:!![],'where':_0x5bd1af[_0x10b1('0x16')]?_0x5bd1af[_0x10b1('0x16')][_0x10b1('0x18')]||null:null,'attributes':_0x5bd1af[_0x10b1('0x16')]?_0x5bd1af['options']['attributes']||null:null,'limit':_0x5bd1af[_0x10b1('0x16')]?_0x5bd1af[_0x10b1('0x16')][_0x10b1('0x19')]||null:null,'include':_0x5bd1af[_0x10b1('0x16')]?_0x5bd1af[_0x10b1('0x16')]['include']?_['map'](_0x5bd1af['options'][_0x10b1('0x1a')],function(_0x5365aa){return{'model':db[_0x5365aa[_0x10b1('0x1b')]],'as':_0x5365aa['as'],'attributes':_0x5365aa[_0x10b1('0x1c')],'include':_0x5365aa['include']?_[_0x10b1('0x1d')](_0x5365aa['include'],function(_0x1e52e0){return{'model':db[_0x1e52e0[_0x10b1('0x1b')]],'as':_0x1e52e0['as'],'attributes':_0x1e52e0[_0x10b1('0x1c')],'include':_0x1e52e0[_0x10b1('0x1a')]?_[_0x10b1('0x1d')](_0x1e52e0[_0x10b1('0x1a')],function(_0x50b2f8){return{'model':db[_0x50b2f8['model']],'as':_0x50b2f8['as'],'attributes':_0x50b2f8[_0x10b1('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x10b1('0x9')](function(_0x44065a){logger[_0x10b1('0xa')](_0x10b1('0x14'),_0x5bd1af);logger[_0x10b1('0xd')](_0x10b1('0x14'),_0x5bd1af,JSON[_0x10b1('0xf')](_0x44065a));_0x3df301(_0x44065a);})['catch'](function(_0x784bf1){logger['error']('GetSalesforceAccount',_0x784bf1[_0x10b1('0x11')],_0x5bd1af);_0x2769ea(_0x5928e4[_0x10b1('0x10')](0x1f4,_0x784bf1[_0x10b1('0x11')]));});});};exports['ShowSalesforceAccount']=function(_0x411044){var _0x496d84=this;return new Promise(function(_0xe002ef,_0x22bbc9){return db[_0x10b1('0x1e')]['find']({'raw':_0x411044[_0x10b1('0x16')]?_0x411044[_0x10b1('0x16')][_0x10b1('0x17')]===undefined?!![]:![]:!![],'where':_0x411044[_0x10b1('0x16')]?_0x411044[_0x10b1('0x16')][_0x10b1('0x18')]||null:null,'attributes':_0x411044[_0x10b1('0x16')]?_0x411044[_0x10b1('0x16')][_0x10b1('0x1c')]||null:null,'include':_0x411044['options']?_0x411044[_0x10b1('0x16')][_0x10b1('0x1a')]?_[_0x10b1('0x1d')](_0x411044[_0x10b1('0x16')][_0x10b1('0x1a')],function(_0x43d61a){return{'model':db[_0x43d61a[_0x10b1('0x1b')]],'as':_0x43d61a['as'],'attributes':_0x43d61a['attributes'],'include':_0x43d61a['include']?_[_0x10b1('0x1d')](_0x43d61a[_0x10b1('0x1a')],function(_0x515ad0){return{'model':db[_0x515ad0[_0x10b1('0x1b')]],'as':_0x515ad0['as'],'attributes':_0x515ad0['attributes'],'include':_0x515ad0[_0x10b1('0x1a')]?_[_0x10b1('0x1d')](_0x515ad0[_0x10b1('0x1a')],function(_0x2006cf){return{'model':db[_0x2006cf['model']],'as':_0x2006cf['as'],'attributes':_0x2006cf['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x1726f0){logger['info'](_0x10b1('0x1f'),_0x411044);logger[_0x10b1('0xd')](_0x10b1('0x1f'),_0x411044,JSON[_0x10b1('0xf')](_0x1726f0));_0xe002ef(_0x1726f0);})['catch'](function(_0x256ae9){logger[_0x10b1('0x10')](_0x10b1('0x1f'),_0x256ae9[_0x10b1('0x11')],_0x411044);_0x22bbc9(_0x496d84[_0x10b1('0x10')](0x1f4,_0x256ae9[_0x10b1('0x11')]));});});};