Built motion from commit 87cd5f02.|2.5.48
[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 _0x3ac6=['jayson/promise','client','http','request','then','SalesforceAccount,\x20%s,\x20%s','request\x20sent','SalesforceAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','GetSalesforceAccount','SalesforceAccount','findAll','options','raw','where','limit','include','map','model','attributes','debug','ShowSalesforceAccount','find','lodash','util','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment'];(function(_0x5b34c0,_0x3ad403){var _0x242bd3=function(_0x51d0ce){while(--_0x51d0ce){_0x5b34c0['push'](_0x5b34c0['shift']());}};_0x242bd3(++_0x3ad403);}(_0x3ac6,0x69));var _0x63ac=function(_0x3d278f,_0x2392fd){_0x3d278f=_0x3d278f-0x0;var _0x5ba38f=_0x3ac6[_0x3d278f];return _0x5ba38f;};'use strict';var _=require(_0x63ac('0x0'));var util=require(_0x63ac('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x63ac('0x2'));var fs=require('fs');var Redis=require(_0x63ac('0x3'));var db=require(_0x63ac('0x4'))['db'];var utils=require(_0x63ac('0x5'));var logger=require(_0x63ac('0x6'))(_0x63ac('0x7'));var config=require(_0x63ac('0x8'));var jayson=require(_0x63ac('0x9'));var client=jayson[_0x63ac('0xa')][_0x63ac('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x40177d,_0x39b7ea,_0x3b39aa){return new BPromise(function(_0x17f977,_0x710d27){return client[_0x63ac('0xc')](_0x40177d,_0x3b39aa)[_0x63ac('0xd')](function(_0x44f010){logger['info'](_0x63ac('0xe'),_0x39b7ea,_0x63ac('0xf'));logger['debug'](_0x63ac('0x10'),_0x39b7ea,_0x63ac('0xf'),JSON[_0x63ac('0x11')](_0x44f010));if(_0x44f010['error']){if(_0x44f010[_0x63ac('0x12')][_0x63ac('0x13')]===0x1f4){logger['error'](_0x63ac('0xe'),_0x39b7ea,_0x44f010[_0x63ac('0x12')][_0x63ac('0x14')]);return _0x710d27(_0x44f010['error'][_0x63ac('0x14')]);}logger[_0x63ac('0x12')](_0x63ac('0xe'),_0x39b7ea,_0x44f010[_0x63ac('0x12')][_0x63ac('0x14')]);return _0x17f977(_0x44f010[_0x63ac('0x12')]['message']);}else{logger[_0x63ac('0x15')](_0x63ac('0xe'),_0x39b7ea,_0x63ac('0xf'));_0x17f977(_0x44f010[_0x63ac('0x16')][_0x63ac('0x14')]);}})[_0x63ac('0x17')](function(_0x4445d0){logger['error'](_0x63ac('0xe'),_0x39b7ea,_0x4445d0);_0x710d27(_0x4445d0);});});}exports[_0x63ac('0x18')]=function(_0x787dc8){var _0x5246af=this;return new Promise(function(_0x454b20,_0x5ed93a){return db[_0x63ac('0x19')][_0x63ac('0x1a')]({'raw':_0x787dc8[_0x63ac('0x1b')]?_0x787dc8[_0x63ac('0x1b')][_0x63ac('0x1c')]===undefined?!![]:![]:!![],'where':_0x787dc8['options']?_0x787dc8[_0x63ac('0x1b')][_0x63ac('0x1d')]||null:null,'attributes':_0x787dc8[_0x63ac('0x1b')]?_0x787dc8[_0x63ac('0x1b')]['attributes']||null:null,'limit':_0x787dc8[_0x63ac('0x1b')]?_0x787dc8[_0x63ac('0x1b')][_0x63ac('0x1e')]||null:null,'include':_0x787dc8[_0x63ac('0x1b')]?_0x787dc8[_0x63ac('0x1b')][_0x63ac('0x1f')]?_[_0x63ac('0x20')](_0x787dc8[_0x63ac('0x1b')]['include'],function(_0x3f4127){return{'model':db[_0x3f4127[_0x63ac('0x21')]],'as':_0x3f4127['as'],'attributes':_0x3f4127[_0x63ac('0x22')],'include':_0x3f4127[_0x63ac('0x1f')]?_[_0x63ac('0x20')](_0x3f4127[_0x63ac('0x1f')],function(_0x10e83d){return{'model':db[_0x10e83d[_0x63ac('0x21')]],'as':_0x10e83d['as'],'attributes':_0x10e83d['attributes'],'include':_0x10e83d[_0x63ac('0x1f')]?_[_0x63ac('0x20')](_0x10e83d[_0x63ac('0x1f')],function(_0xb4de29){return{'model':db[_0xb4de29[_0x63ac('0x21')]],'as':_0xb4de29['as'],'attributes':_0xb4de29[_0x63ac('0x22')]};}):[]};}):[]};}):[]:[]})[_0x63ac('0xd')](function(_0x274753){logger[_0x63ac('0x15')](_0x63ac('0x18'),_0x787dc8);logger[_0x63ac('0x23')](_0x63ac('0x18'),_0x787dc8,JSON[_0x63ac('0x11')](_0x274753));_0x454b20(_0x274753);})['catch'](function(_0x45e421){logger['error']('GetSalesforceAccount',_0x45e421[_0x63ac('0x14')],_0x787dc8);_0x5ed93a(_0x5246af[_0x63ac('0x12')](0x1f4,_0x45e421[_0x63ac('0x14')]));});});};exports[_0x63ac('0x24')]=function(_0x18002b){var _0x5355a3=this;return new Promise(function(_0x10d156,_0x289672){return db[_0x63ac('0x19')][_0x63ac('0x25')]({'raw':_0x18002b[_0x63ac('0x1b')]?_0x18002b[_0x63ac('0x1b')][_0x63ac('0x1c')]===undefined?!![]:![]:!![],'where':_0x18002b['options']?_0x18002b[_0x63ac('0x1b')][_0x63ac('0x1d')]||null:null,'attributes':_0x18002b[_0x63ac('0x1b')]?_0x18002b['options'][_0x63ac('0x22')]||null:null,'include':_0x18002b[_0x63ac('0x1b')]?_0x18002b[_0x63ac('0x1b')][_0x63ac('0x1f')]?_[_0x63ac('0x20')](_0x18002b[_0x63ac('0x1b')]['include'],function(_0x4e3851){return{'model':db[_0x4e3851[_0x63ac('0x21')]],'as':_0x4e3851['as'],'attributes':_0x4e3851[_0x63ac('0x22')],'include':_0x4e3851[_0x63ac('0x1f')]?_[_0x63ac('0x20')](_0x4e3851[_0x63ac('0x1f')],function(_0x4bf159){return{'model':db[_0x4bf159['model']],'as':_0x4bf159['as'],'attributes':_0x4bf159[_0x63ac('0x22')],'include':_0x4bf159[_0x63ac('0x1f')]?_['map'](_0x4bf159[_0x63ac('0x1f')],function(_0x3830a0){return{'model':db[_0x3830a0[_0x63ac('0x21')]],'as':_0x3830a0['as'],'attributes':_0x3830a0[_0x63ac('0x22')]};}):[]};}):[]};}):[]:[]})[_0x63ac('0xd')](function(_0x4635b8){logger[_0x63ac('0x15')](_0x63ac('0x24'),_0x18002b);logger[_0x63ac('0x23')]('ShowSalesforceAccount',_0x18002b,JSON['stringify'](_0x4635b8));_0x10d156(_0x4635b8);})[_0x63ac('0x17')](function(_0xe843a){logger['error'](_0x63ac('0x24'),_0xe843a[_0x63ac('0x14')],_0x18002b);_0x289672(_0x5355a3[_0x63ac('0x12')](0x1f4,_0xe843a[_0x63ac('0x14')]));});});};