1bd11346f38df165c4de802cbd1db56900d05a72
[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 _0x8991=['lodash','util','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','SalesforceAccount,\x20%s,\x20%s','request\x20sent','SalesforceAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','result','SalesforceAccount','findAll','options','raw','where','attributes','limit','include','map','model','GetSalesforceAccount','debug','catch','ShowSalesforceAccount'];(function(_0x2a573f,_0x3dad52){var _0x4134db=function(_0x51f516){while(--_0x51f516){_0x2a573f['push'](_0x2a573f['shift']());}};_0x4134db(++_0x3dad52);}(_0x8991,0x1b0));var _0x1899=function(_0x3e0991,_0x4f7df4){_0x3e0991=_0x3e0991-0x0;var _0xea4798=_0x8991[_0x3e0991];return _0xea4798;};'use strict';var _=require(_0x1899('0x0'));var util=require(_0x1899('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x1899('0x2'));var fs=require('fs');var Redis=require(_0x1899('0x3'));var db=require(_0x1899('0x4'))['db'];var utils=require(_0x1899('0x5'));var logger=require(_0x1899('0x6'))(_0x1899('0x7'));var config=require(_0x1899('0x8'));var jayson=require(_0x1899('0x9'));var client=jayson[_0x1899('0xa')][_0x1899('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x24ca9,_0x39c834,_0x3df4aa){return new BPromise(function(_0xb1fe51,_0x5ae1ca){return client[_0x1899('0xc')](_0x24ca9,_0x3df4aa)[_0x1899('0xd')](function(_0x52320a){logger[_0x1899('0xe')](_0x1899('0xf'),_0x39c834,_0x1899('0x10'));logger['debug'](_0x1899('0x11'),_0x39c834,_0x1899('0x10'),JSON[_0x1899('0x12')](_0x52320a));if(_0x52320a[_0x1899('0x13')]){if(_0x52320a['error']['code']===0x1f4){logger[_0x1899('0x13')]('SalesforceAccount,\x20%s,\x20%s',_0x39c834,_0x52320a[_0x1899('0x13')][_0x1899('0x14')]);return _0x5ae1ca(_0x52320a['error'][_0x1899('0x14')]);}logger[_0x1899('0x13')](_0x1899('0xf'),_0x39c834,_0x52320a[_0x1899('0x13')]['message']);return _0xb1fe51(_0x52320a[_0x1899('0x13')][_0x1899('0x14')]);}else{logger[_0x1899('0xe')](_0x1899('0xf'),_0x39c834,_0x1899('0x10'));_0xb1fe51(_0x52320a[_0x1899('0x15')][_0x1899('0x14')]);}})['catch'](function(_0x5ba31b){logger['error'](_0x1899('0xf'),_0x39c834,_0x5ba31b);_0x5ae1ca(_0x5ba31b);});});}exports['GetSalesforceAccount']=function(_0x2dfca0){var _0x5ee432=this;return new Promise(function(_0x426720,_0x269be3){return db[_0x1899('0x16')][_0x1899('0x17')]({'raw':_0x2dfca0[_0x1899('0x18')]?_0x2dfca0[_0x1899('0x18')][_0x1899('0x19')]===undefined?!![]:![]:!![],'where':_0x2dfca0[_0x1899('0x18')]?_0x2dfca0[_0x1899('0x18')][_0x1899('0x1a')]||null:null,'attributes':_0x2dfca0[_0x1899('0x18')]?_0x2dfca0['options'][_0x1899('0x1b')]||null:null,'limit':_0x2dfca0[_0x1899('0x18')]?_0x2dfca0['options'][_0x1899('0x1c')]||null:null,'include':_0x2dfca0[_0x1899('0x18')]?_0x2dfca0['options'][_0x1899('0x1d')]?_[_0x1899('0x1e')](_0x2dfca0[_0x1899('0x18')]['include'],function(_0x10c939){return{'model':db[_0x10c939[_0x1899('0x1f')]],'as':_0x10c939['as'],'attributes':_0x10c939[_0x1899('0x1b')],'include':_0x10c939[_0x1899('0x1d')]?_[_0x1899('0x1e')](_0x10c939['include'],function(_0x569c4b){return{'model':db[_0x569c4b[_0x1899('0x1f')]],'as':_0x569c4b['as'],'attributes':_0x569c4b[_0x1899('0x1b')],'include':_0x569c4b[_0x1899('0x1d')]?_[_0x1899('0x1e')](_0x569c4b[_0x1899('0x1d')],function(_0xeb41f6){return{'model':db[_0xeb41f6[_0x1899('0x1f')]],'as':_0xeb41f6['as'],'attributes':_0xeb41f6['attributes']};}):[]};}):[]};}):[]:[]})[_0x1899('0xd')](function(_0x109581){logger['info'](_0x1899('0x20'),_0x2dfca0);logger[_0x1899('0x21')]('GetSalesforceAccount',_0x2dfca0,JSON['stringify'](_0x109581));_0x426720(_0x109581);})[_0x1899('0x22')](function(_0x286dc8){logger['error'](_0x1899('0x20'),_0x286dc8[_0x1899('0x14')],_0x2dfca0);_0x269be3(_0x5ee432[_0x1899('0x13')](0x1f4,_0x286dc8[_0x1899('0x14')]));});});};exports[_0x1899('0x23')]=function(_0x4dc9fd){var _0x425f5c=this;return new Promise(function(_0x2e4adb,_0x61d466){return db[_0x1899('0x16')]['find']({'raw':_0x4dc9fd[_0x1899('0x18')]?_0x4dc9fd['options'][_0x1899('0x19')]===undefined?!![]:![]:!![],'where':_0x4dc9fd[_0x1899('0x18')]?_0x4dc9fd[_0x1899('0x18')][_0x1899('0x1a')]||null:null,'attributes':_0x4dc9fd[_0x1899('0x18')]?_0x4dc9fd[_0x1899('0x18')][_0x1899('0x1b')]||null:null,'include':_0x4dc9fd[_0x1899('0x18')]?_0x4dc9fd[_0x1899('0x18')][_0x1899('0x1d')]?_[_0x1899('0x1e')](_0x4dc9fd[_0x1899('0x18')][_0x1899('0x1d')],function(_0x8e9683){return{'model':db[_0x8e9683[_0x1899('0x1f')]],'as':_0x8e9683['as'],'attributes':_0x8e9683['attributes'],'include':_0x8e9683[_0x1899('0x1d')]?_['map'](_0x8e9683[_0x1899('0x1d')],function(_0x591857){return{'model':db[_0x591857['model']],'as':_0x591857['as'],'attributes':_0x591857[_0x1899('0x1b')],'include':_0x591857[_0x1899('0x1d')]?_[_0x1899('0x1e')](_0x591857['include'],function(_0x504b28){return{'model':db[_0x504b28['model']],'as':_0x504b28['as'],'attributes':_0x504b28['attributes']};}):[]};}):[]};}):[]:[]})[_0x1899('0xd')](function(_0x3eb953){logger[_0x1899('0xe')](_0x1899('0x23'),_0x4dc9fd);logger[_0x1899('0x21')]('ShowSalesforceAccount',_0x4dc9fd,JSON[_0x1899('0x12')](_0x3eb953));_0x2e4adb(_0x3eb953);})[_0x1899('0x22')](function(_0x2160a5){logger[_0x1899('0x13')](_0x1899('0x23'),_0x2160a5[_0x1899('0x14')],_0x4dc9fd);_0x61d466(_0x425f5c['error'](0x1f4,_0x2160a5['message']));});});};