e524b3ae352eeed9138627b5af94b35fceea7ce8
[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 _0xfd28=['randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','request','SalesforceAccount,\x20%s,\x20%s','debug','request\x20sent','error','code','message','info','result','GetSalesforceAccount','SalesforceAccount','findAll','options','where','attributes','map','include','model','stringify','catch','ShowSalesforceAccount','raw','then','util','moment'];(function(_0x1b3bca,_0x4b9094){var _0x6ca813=function(_0x5b0a8d){while(--_0x5b0a8d){_0x1b3bca['push'](_0x1b3bca['shift']());}};_0x6ca813(++_0x4b9094);}(_0xfd28,0x148));var _0x8fd2=function(_0xcfeff4,_0x3f2e19){_0xcfeff4=_0xcfeff4-0x0;var _0xb2fadc=_0xfd28[_0xcfeff4];return _0xb2fadc;};'use strict';var _=require('lodash');var util=require(_0x8fd2('0x0'));var moment=require(_0x8fd2('0x1'));var BPromise=require('bluebird');var rs=require(_0x8fd2('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x8fd2('0x3'))['db'];var utils=require(_0x8fd2('0x4'));var logger=require(_0x8fd2('0x5'))('rpc');var config=require(_0x8fd2('0x6'));var jayson=require(_0x8fd2('0x7'));var client=jayson[_0x8fd2('0x8')][_0x8fd2('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x2f0afc,_0x4bdc1a,_0x53d938){return new BPromise(function(_0x10fccf,_0x466c3d){return client[_0x8fd2('0xa')](_0x2f0afc,_0x53d938)['then'](function(_0x13cc69){logger['info'](_0x8fd2('0xb'),_0x4bdc1a,'request\x20sent');logger[_0x8fd2('0xc')]('SalesforceAccount,\x20%s,\x20%s,\x20%s',_0x4bdc1a,_0x8fd2('0xd'),JSON['stringify'](_0x13cc69));if(_0x13cc69[_0x8fd2('0xe')]){if(_0x13cc69['error'][_0x8fd2('0xf')]===0x1f4){logger[_0x8fd2('0xe')](_0x8fd2('0xb'),_0x4bdc1a,_0x13cc69[_0x8fd2('0xe')][_0x8fd2('0x10')]);return _0x466c3d(_0x13cc69[_0x8fd2('0xe')][_0x8fd2('0x10')]);}logger[_0x8fd2('0xe')](_0x8fd2('0xb'),_0x4bdc1a,_0x13cc69[_0x8fd2('0xe')][_0x8fd2('0x10')]);return _0x10fccf(_0x13cc69[_0x8fd2('0xe')][_0x8fd2('0x10')]);}else{logger[_0x8fd2('0x11')](_0x8fd2('0xb'),_0x4bdc1a,'request\x20sent');_0x10fccf(_0x13cc69[_0x8fd2('0x12')]['message']);}})['catch'](function(_0x56f75d){logger[_0x8fd2('0xe')](_0x8fd2('0xb'),_0x4bdc1a,_0x56f75d);_0x466c3d(_0x56f75d);});});}exports[_0x8fd2('0x13')]=function(_0x12e8a3){var _0x5c8b3c=this;return new Promise(function(_0xabbeb4,_0x708421){return db[_0x8fd2('0x14')][_0x8fd2('0x15')]({'raw':_0x12e8a3[_0x8fd2('0x16')]?_0x12e8a3['options']['raw']===undefined?!![]:![]:!![],'where':_0x12e8a3[_0x8fd2('0x16')]?_0x12e8a3['options'][_0x8fd2('0x17')]||null:null,'attributes':_0x12e8a3['options']?_0x12e8a3[_0x8fd2('0x16')][_0x8fd2('0x18')]||null:null,'limit':_0x12e8a3['options']?_0x12e8a3[_0x8fd2('0x16')]['limit']||null:null,'include':_0x12e8a3[_0x8fd2('0x16')]?_0x12e8a3[_0x8fd2('0x16')]['include']?_[_0x8fd2('0x19')](_0x12e8a3[_0x8fd2('0x16')][_0x8fd2('0x1a')],function(_0x490ea5){return{'model':db[_0x490ea5[_0x8fd2('0x1b')]],'as':_0x490ea5['as'],'attributes':_0x490ea5[_0x8fd2('0x18')],'include':_0x490ea5[_0x8fd2('0x1a')]?_[_0x8fd2('0x19')](_0x490ea5[_0x8fd2('0x1a')],function(_0x25db4e){return{'model':db[_0x25db4e[_0x8fd2('0x1b')]],'as':_0x25db4e['as'],'attributes':_0x25db4e[_0x8fd2('0x18')],'include':_0x25db4e[_0x8fd2('0x1a')]?_[_0x8fd2('0x19')](_0x25db4e[_0x8fd2('0x1a')],function(_0x1f3237){return{'model':db[_0x1f3237[_0x8fd2('0x1b')]],'as':_0x1f3237['as'],'attributes':_0x1f3237['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x345bc3){logger[_0x8fd2('0x11')](_0x8fd2('0x13'),_0x12e8a3);logger['debug'](_0x8fd2('0x13'),_0x12e8a3,JSON[_0x8fd2('0x1c')](_0x345bc3));_0xabbeb4(_0x345bc3);})[_0x8fd2('0x1d')](function(_0x960869){logger[_0x8fd2('0xe')](_0x8fd2('0x13'),_0x960869[_0x8fd2('0x10')],_0x12e8a3);_0x708421(_0x5c8b3c['error'](0x1f4,_0x960869[_0x8fd2('0x10')]));});});};exports[_0x8fd2('0x1e')]=function(_0x818f61){var _0x446c7a=this;return new Promise(function(_0x313902,_0x3ea575){return db[_0x8fd2('0x14')]['find']({'raw':_0x818f61['options']?_0x818f61['options'][_0x8fd2('0x1f')]===undefined?!![]:![]:!![],'where':_0x818f61[_0x8fd2('0x16')]?_0x818f61[_0x8fd2('0x16')][_0x8fd2('0x17')]||null:null,'attributes':_0x818f61['options']?_0x818f61['options'][_0x8fd2('0x18')]||null:null,'include':_0x818f61[_0x8fd2('0x16')]?_0x818f61[_0x8fd2('0x16')][_0x8fd2('0x1a')]?_[_0x8fd2('0x19')](_0x818f61['options'][_0x8fd2('0x1a')],function(_0x50fe44){return{'model':db[_0x50fe44[_0x8fd2('0x1b')]],'as':_0x50fe44['as'],'attributes':_0x50fe44['attributes'],'include':_0x50fe44[_0x8fd2('0x1a')]?_['map'](_0x50fe44[_0x8fd2('0x1a')],function(_0x3449b1){return{'model':db[_0x3449b1[_0x8fd2('0x1b')]],'as':_0x3449b1['as'],'attributes':_0x3449b1['attributes'],'include':_0x3449b1[_0x8fd2('0x1a')]?_['map'](_0x3449b1[_0x8fd2('0x1a')],function(_0x17c1f3){return{'model':db[_0x17c1f3[_0x8fd2('0x1b')]],'as':_0x17c1f3['as'],'attributes':_0x17c1f3['attributes']};}):[]};}):[]};}):[]:[]})[_0x8fd2('0x20')](function(_0x199a85){logger[_0x8fd2('0x11')]('ShowSalesforceAccount',_0x818f61);logger[_0x8fd2('0xc')](_0x8fd2('0x1e'),_0x818f61,JSON[_0x8fd2('0x1c')](_0x199a85));_0x313902(_0x199a85);})['catch'](function(_0x37a24b){logger[_0x8fd2('0xe')]('ShowSalesforceAccount',_0x37a24b[_0x8fd2('0x10')],_0x818f61);_0x3ea575(_0x446c7a[_0x8fd2('0xe')](0x1f4,_0x37a24b[_0x8fd2('0x10')]));});});};