Built motion from commit 0900f080.|2.5.45
[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 _0x6637=['catch','GetSalesforceAccount','findAll','options','raw','where','attributes','limit','include','map','model','then','SalesforceAccount','find','ShowSalesforceAccount','stringify','util','moment','ioredis','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','request','info','SalesforceAccount,\x20%s,\x20%s','request\x20sent','debug','SalesforceAccount,\x20%s,\x20%s,\x20%s','error','code','message'];(function(_0x2b4629,_0x2cfe26){var _0x1d8fa9=function(_0x54de40){while(--_0x54de40){_0x2b4629['push'](_0x2b4629['shift']());}};_0x1d8fa9(++_0x2cfe26);}(_0x6637,0xfe));var _0x7663=function(_0x2465c6,_0x412a0a){_0x2465c6=_0x2465c6-0x0;var _0x28b33c=_0x6637[_0x2465c6];return _0x28b33c;};'use strict';var _=require('lodash');var util=require(_0x7663('0x0'));var moment=require(_0x7663('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x7663('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0x7663('0x3'));var logger=require('../../config/logger')(_0x7663('0x4'));var config=require(_0x7663('0x5'));var jayson=require(_0x7663('0x6'));var client=jayson[_0x7663('0x7')][_0x7663('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x2bca8c,_0x2bca5b,_0x6499ab){return new BPromise(function(_0x5f1def,_0x50bd49){return client[_0x7663('0x9')](_0x2bca8c,_0x6499ab)['then'](function(_0xfb2b07){logger[_0x7663('0xa')](_0x7663('0xb'),_0x2bca5b,_0x7663('0xc'));logger[_0x7663('0xd')](_0x7663('0xe'),_0x2bca5b,_0x7663('0xc'),JSON['stringify'](_0xfb2b07));if(_0xfb2b07[_0x7663('0xf')]){if(_0xfb2b07['error'][_0x7663('0x10')]===0x1f4){logger['error'](_0x7663('0xb'),_0x2bca5b,_0xfb2b07['error'][_0x7663('0x11')]);return _0x50bd49(_0xfb2b07['error'][_0x7663('0x11')]);}logger['error'](_0x7663('0xb'),_0x2bca5b,_0xfb2b07[_0x7663('0xf')][_0x7663('0x11')]);return _0x5f1def(_0xfb2b07[_0x7663('0xf')][_0x7663('0x11')]);}else{logger[_0x7663('0xa')](_0x7663('0xb'),_0x2bca5b,_0x7663('0xc'));_0x5f1def(_0xfb2b07['result'][_0x7663('0x11')]);}})[_0x7663('0x12')](function(_0x41db8f){logger[_0x7663('0xf')](_0x7663('0xb'),_0x2bca5b,_0x41db8f);_0x50bd49(_0x41db8f);});});}exports[_0x7663('0x13')]=function(_0x1ae687){var _0x344158=this;return new Promise(function(_0x5d755d,_0xb19aea){return db['SalesforceAccount'][_0x7663('0x14')]({'raw':_0x1ae687[_0x7663('0x15')]?_0x1ae687[_0x7663('0x15')][_0x7663('0x16')]===undefined?!![]:![]:!![],'where':_0x1ae687[_0x7663('0x15')]?_0x1ae687[_0x7663('0x15')][_0x7663('0x17')]||null:null,'attributes':_0x1ae687[_0x7663('0x15')]?_0x1ae687[_0x7663('0x15')][_0x7663('0x18')]||null:null,'limit':_0x1ae687[_0x7663('0x15')]?_0x1ae687[_0x7663('0x15')][_0x7663('0x19')]||null:null,'include':_0x1ae687[_0x7663('0x15')]?_0x1ae687['options'][_0x7663('0x1a')]?_[_0x7663('0x1b')](_0x1ae687[_0x7663('0x15')]['include'],function(_0x372197){return{'model':db[_0x372197[_0x7663('0x1c')]],'as':_0x372197['as'],'attributes':_0x372197[_0x7663('0x18')],'include':_0x372197[_0x7663('0x1a')]?_['map'](_0x372197[_0x7663('0x1a')],function(_0x378d1c){return{'model':db[_0x378d1c[_0x7663('0x1c')]],'as':_0x378d1c['as'],'attributes':_0x378d1c[_0x7663('0x18')],'include':_0x378d1c['include']?_[_0x7663('0x1b')](_0x378d1c[_0x7663('0x1a')],function(_0x34b5d4){return{'model':db[_0x34b5d4[_0x7663('0x1c')]],'as':_0x34b5d4['as'],'attributes':_0x34b5d4[_0x7663('0x18')]};}):[]};}):[]};}):[]:[]})[_0x7663('0x1d')](function(_0x2af5c7){logger[_0x7663('0xa')]('GetSalesforceAccount',_0x1ae687);logger['debug']('GetSalesforceAccount',_0x1ae687,JSON['stringify'](_0x2af5c7));_0x5d755d(_0x2af5c7);})[_0x7663('0x12')](function(_0x243ee0){logger[_0x7663('0xf')]('GetSalesforceAccount',_0x243ee0[_0x7663('0x11')],_0x1ae687);_0xb19aea(_0x344158[_0x7663('0xf')](0x1f4,_0x243ee0[_0x7663('0x11')]));});});};exports['ShowSalesforceAccount']=function(_0x53786b){var _0x3035f2=this;return new Promise(function(_0x3c2226,_0x469969){return db[_0x7663('0x1e')][_0x7663('0x1f')]({'raw':_0x53786b[_0x7663('0x15')]?_0x53786b['options']['raw']===undefined?!![]:![]:!![],'where':_0x53786b['options']?_0x53786b[_0x7663('0x15')]['where']||null:null,'attributes':_0x53786b[_0x7663('0x15')]?_0x53786b[_0x7663('0x15')][_0x7663('0x18')]||null:null,'include':_0x53786b['options']?_0x53786b['options'][_0x7663('0x1a')]?_[_0x7663('0x1b')](_0x53786b[_0x7663('0x15')][_0x7663('0x1a')],function(_0x8bb4b5){return{'model':db[_0x8bb4b5['model']],'as':_0x8bb4b5['as'],'attributes':_0x8bb4b5[_0x7663('0x18')],'include':_0x8bb4b5['include']?_['map'](_0x8bb4b5[_0x7663('0x1a')],function(_0x1cc70c){return{'model':db[_0x1cc70c[_0x7663('0x1c')]],'as':_0x1cc70c['as'],'attributes':_0x1cc70c[_0x7663('0x18')],'include':_0x1cc70c[_0x7663('0x1a')]?_[_0x7663('0x1b')](_0x1cc70c[_0x7663('0x1a')],function(_0x4f221d){return{'model':db[_0x4f221d[_0x7663('0x1c')]],'as':_0x4f221d['as'],'attributes':_0x4f221d['attributes']};}):[]};}):[]};}):[]:[]})[_0x7663('0x1d')](function(_0x20e2a5){logger[_0x7663('0xa')](_0x7663('0x20'),_0x53786b);logger[_0x7663('0xd')](_0x7663('0x20'),_0x53786b,JSON[_0x7663('0x21')](_0x20e2a5));_0x3c2226(_0x20e2a5);})[_0x7663('0x12')](function(_0x60bec5){logger[_0x7663('0xf')](_0x7663('0x20'),_0x60bec5[_0x7663('0x11')],_0x53786b);_0x469969(_0x3035f2[_0x7663('0xf')](0x1f4,_0x60bec5[_0x7663('0x11')]));});});};