Built motion from commit 9d1906d1.|2.5.40
[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 _0xc9dd=['request\x20sent','SalesforceAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','SalesforceAccount,\x20%s,\x20%s','message','result','catch','SalesforceAccount','findAll','options','where','attributes','include','map','model','debug','GetSalesforceAccount','ShowSalesforceAccount','find','raw','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','info'];(function(_0x4f9b18,_0x2cb5ca){var _0x29f20c=function(_0x268b3d){while(--_0x268b3d){_0x4f9b18['push'](_0x4f9b18['shift']());}};_0x29f20c(++_0x2cb5ca);}(_0xc9dd,0x1a2));var _0xdc9d=function(_0x2563f6,_0x474c60){_0x2563f6=_0x2563f6-0x0;var _0x233392=_0xc9dd[_0x2563f6];return _0x233392;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xdc9d('0x0'));var BPromise=require(_0xdc9d('0x1'));var rs=require(_0xdc9d('0x2'));var fs=require('fs');var Redis=require(_0xdc9d('0x3'));var db=require(_0xdc9d('0x4'))['db'];var utils=require(_0xdc9d('0x5'));var logger=require(_0xdc9d('0x6'))(_0xdc9d('0x7'));var config=require(_0xdc9d('0x8'));var jayson=require(_0xdc9d('0x9'));var client=jayson[_0xdc9d('0xa')][_0xdc9d('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x1d42ca,_0x28df5b,_0x23bd61){return new BPromise(function(_0x1d1f33,_0x107271){return client['request'](_0x1d42ca,_0x23bd61)[_0xdc9d('0xc')](function(_0x2987b6){logger[_0xdc9d('0xd')]('SalesforceAccount,\x20%s,\x20%s',_0x28df5b,_0xdc9d('0xe'));logger['debug'](_0xdc9d('0xf'),_0x28df5b,_0xdc9d('0xe'),JSON[_0xdc9d('0x10')](_0x2987b6));if(_0x2987b6['error']){if(_0x2987b6[_0xdc9d('0x11')][_0xdc9d('0x12')]===0x1f4){logger[_0xdc9d('0x11')](_0xdc9d('0x13'),_0x28df5b,_0x2987b6['error']['message']);return _0x107271(_0x2987b6[_0xdc9d('0x11')][_0xdc9d('0x14')]);}logger[_0xdc9d('0x11')](_0xdc9d('0x13'),_0x28df5b,_0x2987b6[_0xdc9d('0x11')][_0xdc9d('0x14')]);return _0x1d1f33(_0x2987b6[_0xdc9d('0x11')][_0xdc9d('0x14')]);}else{logger[_0xdc9d('0xd')](_0xdc9d('0x13'),_0x28df5b,_0xdc9d('0xe'));_0x1d1f33(_0x2987b6[_0xdc9d('0x15')][_0xdc9d('0x14')]);}})[_0xdc9d('0x16')](function(_0x24753d){logger['error']('SalesforceAccount,\x20%s,\x20%s',_0x28df5b,_0x24753d);_0x107271(_0x24753d);});});}exports['GetSalesforceAccount']=function(_0x55c8bd){var _0x38ffd8=this;return new Promise(function(_0x4ee01d,_0x43ca29){return db[_0xdc9d('0x17')][_0xdc9d('0x18')]({'raw':_0x55c8bd['options']?_0x55c8bd[_0xdc9d('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x55c8bd[_0xdc9d('0x19')]?_0x55c8bd[_0xdc9d('0x19')][_0xdc9d('0x1a')]||null:null,'attributes':_0x55c8bd[_0xdc9d('0x19')]?_0x55c8bd[_0xdc9d('0x19')][_0xdc9d('0x1b')]||null:null,'limit':_0x55c8bd[_0xdc9d('0x19')]?_0x55c8bd[_0xdc9d('0x19')]['limit']||null:null,'include':_0x55c8bd[_0xdc9d('0x19')]?_0x55c8bd['options'][_0xdc9d('0x1c')]?_[_0xdc9d('0x1d')](_0x55c8bd[_0xdc9d('0x19')]['include'],function(_0x27b69e){return{'model':db[_0x27b69e[_0xdc9d('0x1e')]],'as':_0x27b69e['as'],'attributes':_0x27b69e['attributes'],'include':_0x27b69e[_0xdc9d('0x1c')]?_[_0xdc9d('0x1d')](_0x27b69e[_0xdc9d('0x1c')],function(_0x3e8775){return{'model':db[_0x3e8775[_0xdc9d('0x1e')]],'as':_0x3e8775['as'],'attributes':_0x3e8775[_0xdc9d('0x1b')],'include':_0x3e8775[_0xdc9d('0x1c')]?_[_0xdc9d('0x1d')](_0x3e8775[_0xdc9d('0x1c')],function(_0xf2475d){return{'model':db[_0xf2475d[_0xdc9d('0x1e')]],'as':_0xf2475d['as'],'attributes':_0xf2475d['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x1aee1d){logger[_0xdc9d('0xd')]('GetSalesforceAccount',_0x55c8bd);logger[_0xdc9d('0x1f')](_0xdc9d('0x20'),_0x55c8bd,JSON[_0xdc9d('0x10')](_0x1aee1d));_0x4ee01d(_0x1aee1d);})[_0xdc9d('0x16')](function(_0x2f8bf0){logger[_0xdc9d('0x11')](_0xdc9d('0x20'),_0x2f8bf0[_0xdc9d('0x14')],_0x55c8bd);_0x43ca29(_0x38ffd8[_0xdc9d('0x11')](0x1f4,_0x2f8bf0[_0xdc9d('0x14')]));});});};exports[_0xdc9d('0x21')]=function(_0x2e82a6){var _0x1d4852=this;return new Promise(function(_0x8b2316,_0x300be3){return db['SalesforceAccount'][_0xdc9d('0x22')]({'raw':_0x2e82a6['options']?_0x2e82a6[_0xdc9d('0x19')][_0xdc9d('0x23')]===undefined?!![]:![]:!![],'where':_0x2e82a6[_0xdc9d('0x19')]?_0x2e82a6[_0xdc9d('0x19')][_0xdc9d('0x1a')]||null:null,'attributes':_0x2e82a6[_0xdc9d('0x19')]?_0x2e82a6['options'][_0xdc9d('0x1b')]||null:null,'include':_0x2e82a6[_0xdc9d('0x19')]?_0x2e82a6[_0xdc9d('0x19')]['include']?_[_0xdc9d('0x1d')](_0x2e82a6['options']['include'],function(_0x3ed737){return{'model':db[_0x3ed737[_0xdc9d('0x1e')]],'as':_0x3ed737['as'],'attributes':_0x3ed737[_0xdc9d('0x1b')],'include':_0x3ed737['include']?_['map'](_0x3ed737[_0xdc9d('0x1c')],function(_0xaa1918){return{'model':db[_0xaa1918['model']],'as':_0xaa1918['as'],'attributes':_0xaa1918[_0xdc9d('0x1b')],'include':_0xaa1918[_0xdc9d('0x1c')]?_['map'](_0xaa1918[_0xdc9d('0x1c')],function(_0x30861b){return{'model':db[_0x30861b[_0xdc9d('0x1e')]],'as':_0x30861b['as'],'attributes':_0x30861b['attributes']};}):[]};}):[]};}):[]:[]})[_0xdc9d('0xc')](function(_0x1cd95a){logger['info'](_0xdc9d('0x21'),_0x2e82a6);logger[_0xdc9d('0x1f')]('ShowSalesforceAccount',_0x2e82a6,JSON['stringify'](_0x1cd95a));_0x8b2316(_0x1cd95a);})[_0xdc9d('0x16')](function(_0x50c17c){logger[_0xdc9d('0x11')]('ShowSalesforceAccount',_0x50c17c[_0xdc9d('0x14')],_0x2e82a6);_0x300be3(_0x1d4852[_0xdc9d('0x11')](0x1f4,_0x50c17c[_0xdc9d('0x14')]));});});};