Built motion from commit 953226e6.|2.6.32
[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 _0x2555=['find','where','ShowSalesforceAccount','lodash','util','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','request','then','info','request\x20sent','debug','SalesforceAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','SalesforceAccount,\x20%s,\x20%s','message','result','catch','GetSalesforceAccount','SalesforceAccount','options','raw','attributes','limit','include','map','model'];(function(_0x221b8c,_0x2c7afc){var _0x3fab9f=function(_0x28bab0){while(--_0x28bab0){_0x221b8c['push'](_0x221b8c['shift']());}};_0x3fab9f(++_0x2c7afc);}(_0x2555,0x11b));var _0x5255=function(_0x132e70,_0x99809f){_0x132e70=_0x132e70-0x0;var _0x3a4dad=_0x2555[_0x132e70];return _0x3a4dad;};'use strict';var _=require(_0x5255('0x0'));var util=require(_0x5255('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x5255('0x2'));var fs=require('fs');var Redis=require(_0x5255('0x3'));var db=require(_0x5255('0x4'))['db'];var utils=require(_0x5255('0x5'));var logger=require(_0x5255('0x6'))(_0x5255('0x7'));var config=require(_0x5255('0x8'));var jayson=require(_0x5255('0x9'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x32bc44,_0x37d12b,_0x2e857f){return new BPromise(function(_0x6fabc8,_0x418df4){return client[_0x5255('0xa')](_0x32bc44,_0x2e857f)[_0x5255('0xb')](function(_0x447dbc){logger[_0x5255('0xc')]('SalesforceAccount,\x20%s,\x20%s',_0x37d12b,_0x5255('0xd'));logger[_0x5255('0xe')](_0x5255('0xf'),_0x37d12b,_0x5255('0xd'),JSON[_0x5255('0x10')](_0x447dbc));if(_0x447dbc['error']){if(_0x447dbc[_0x5255('0x11')][_0x5255('0x12')]===0x1f4){logger[_0x5255('0x11')](_0x5255('0x13'),_0x37d12b,_0x447dbc['error']['message']);return _0x418df4(_0x447dbc[_0x5255('0x11')]['message']);}logger[_0x5255('0x11')](_0x5255('0x13'),_0x37d12b,_0x447dbc[_0x5255('0x11')][_0x5255('0x14')]);return _0x6fabc8(_0x447dbc[_0x5255('0x11')][_0x5255('0x14')]);}else{logger[_0x5255('0xc')](_0x5255('0x13'),_0x37d12b,_0x5255('0xd'));_0x6fabc8(_0x447dbc[_0x5255('0x15')][_0x5255('0x14')]);}})[_0x5255('0x16')](function(_0x36a5e2){logger['error'](_0x5255('0x13'),_0x37d12b,_0x36a5e2);_0x418df4(_0x36a5e2);});});}exports[_0x5255('0x17')]=function(_0x45caad){var _0x2892a4=this;return new Promise(function(_0x1984e9,_0x5d6ce6){return db[_0x5255('0x18')]['findAll']({'raw':_0x45caad[_0x5255('0x19')]?_0x45caad[_0x5255('0x19')][_0x5255('0x1a')]===undefined?!![]:![]:!![],'where':_0x45caad['options']?_0x45caad[_0x5255('0x19')]['where']||null:null,'attributes':_0x45caad[_0x5255('0x19')]?_0x45caad['options'][_0x5255('0x1b')]||null:null,'limit':_0x45caad[_0x5255('0x19')]?_0x45caad[_0x5255('0x19')][_0x5255('0x1c')]||null:null,'include':_0x45caad[_0x5255('0x19')]?_0x45caad['options'][_0x5255('0x1d')]?_[_0x5255('0x1e')](_0x45caad[_0x5255('0x19')][_0x5255('0x1d')],function(_0x5e65ff){return{'model':db[_0x5e65ff[_0x5255('0x1f')]],'as':_0x5e65ff['as'],'attributes':_0x5e65ff[_0x5255('0x1b')],'include':_0x5e65ff[_0x5255('0x1d')]?_[_0x5255('0x1e')](_0x5e65ff[_0x5255('0x1d')],function(_0x38dd02){return{'model':db[_0x38dd02[_0x5255('0x1f')]],'as':_0x38dd02['as'],'attributes':_0x38dd02[_0x5255('0x1b')],'include':_0x38dd02[_0x5255('0x1d')]?_[_0x5255('0x1e')](_0x38dd02[_0x5255('0x1d')],function(_0x6446c7){return{'model':db[_0x6446c7['model']],'as':_0x6446c7['as'],'attributes':_0x6446c7['attributes']};}):[]};}):[]};}):[]:[]})[_0x5255('0xb')](function(_0x567533){logger[_0x5255('0xc')](_0x5255('0x17'),_0x45caad);logger[_0x5255('0xe')](_0x5255('0x17'),_0x45caad,JSON['stringify'](_0x567533));_0x1984e9(_0x567533);})['catch'](function(_0x240f10){logger[_0x5255('0x11')](_0x5255('0x17'),_0x240f10[_0x5255('0x14')],_0x45caad);_0x5d6ce6(_0x2892a4[_0x5255('0x11')](0x1f4,_0x240f10[_0x5255('0x14')]));});});};exports['ShowSalesforceAccount']=function(_0x104733){var _0x5e19aa=this;return new Promise(function(_0x226514,_0x476056){return db['SalesforceAccount'][_0x5255('0x20')]({'raw':_0x104733[_0x5255('0x19')]?_0x104733['options'][_0x5255('0x1a')]===undefined?!![]:![]:!![],'where':_0x104733['options']?_0x104733['options'][_0x5255('0x21')]||null:null,'attributes':_0x104733[_0x5255('0x19')]?_0x104733[_0x5255('0x19')][_0x5255('0x1b')]||null:null,'include':_0x104733[_0x5255('0x19')]?_0x104733[_0x5255('0x19')][_0x5255('0x1d')]?_[_0x5255('0x1e')](_0x104733[_0x5255('0x19')]['include'],function(_0x525a1d){return{'model':db[_0x525a1d[_0x5255('0x1f')]],'as':_0x525a1d['as'],'attributes':_0x525a1d[_0x5255('0x1b')],'include':_0x525a1d[_0x5255('0x1d')]?_[_0x5255('0x1e')](_0x525a1d[_0x5255('0x1d')],function(_0x541631){return{'model':db[_0x541631[_0x5255('0x1f')]],'as':_0x541631['as'],'attributes':_0x541631[_0x5255('0x1b')],'include':_0x541631[_0x5255('0x1d')]?_['map'](_0x541631[_0x5255('0x1d')],function(_0xa8bc57){return{'model':db[_0xa8bc57[_0x5255('0x1f')]],'as':_0xa8bc57['as'],'attributes':_0xa8bc57[_0x5255('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x5255('0xb')](function(_0x3c378c){logger[_0x5255('0xc')](_0x5255('0x22'),_0x104733);logger[_0x5255('0xe')]('ShowSalesforceAccount',_0x104733,JSON[_0x5255('0x10')](_0x3c378c));_0x226514(_0x3c378c);})['catch'](function(_0x501faf){logger['error'](_0x5255('0x22'),_0x501faf[_0x5255('0x14')],_0x104733);_0x476056(_0x5e19aa['error'](0x1f4,_0x501faf['message']));});});};