97aa80722c7678ecddd1899637964937c4429ad4
[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 _0x7d8a=['../../config/environment','jayson/promise','client','http','request','SalesforceAccount,\x20%s,\x20%s','debug','request\x20sent','stringify','error','message','info','result','catch','GetSalesforceAccount','SalesforceAccount','findAll','options','where','attributes','limit','include','map','model','ShowSalesforceAccount','raw','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x59b229,_0x213d4e){var _0x217180=function(_0x16b29d){while(--_0x16b29d){_0x59b229['push'](_0x59b229['shift']());}};_0x217180(++_0x213d4e);}(_0x7d8a,0x1ca));var _0xa7d8=function(_0x313c96,_0x3cee6e){_0x313c96=_0x313c96-0x0;var _0x522f53=_0x7d8a[_0x313c96];return _0x522f53;};'use strict';var _=require(_0xa7d8('0x0'));var util=require(_0xa7d8('0x1'));var moment=require(_0xa7d8('0x2'));var BPromise=require(_0xa7d8('0x3'));var rs=require(_0xa7d8('0x4'));var fs=require('fs');var Redis=require(_0xa7d8('0x5'));var db=require(_0xa7d8('0x6'))['db'];var utils=require(_0xa7d8('0x7'));var logger=require(_0xa7d8('0x8'))(_0xa7d8('0x9'));var config=require(_0xa7d8('0xa'));var jayson=require(_0xa7d8('0xb'));var client=jayson[_0xa7d8('0xc')][_0xa7d8('0xd')]({'port':0x232a});function respondWithRpcPromise(_0x55bb66,_0x410b09,_0x2e1955){return new BPromise(function(_0x1807cc,_0x455082){return client[_0xa7d8('0xe')](_0x55bb66,_0x2e1955)['then'](function(_0x40f419){logger['info'](_0xa7d8('0xf'),_0x410b09,'request\x20sent');logger[_0xa7d8('0x10')]('SalesforceAccount,\x20%s,\x20%s,\x20%s',_0x410b09,_0xa7d8('0x11'),JSON[_0xa7d8('0x12')](_0x40f419));if(_0x40f419['error']){if(_0x40f419[_0xa7d8('0x13')]['code']===0x1f4){logger[_0xa7d8('0x13')](_0xa7d8('0xf'),_0x410b09,_0x40f419[_0xa7d8('0x13')]['message']);return _0x455082(_0x40f419[_0xa7d8('0x13')][_0xa7d8('0x14')]);}logger['error']('SalesforceAccount,\x20%s,\x20%s',_0x410b09,_0x40f419['error'][_0xa7d8('0x14')]);return _0x1807cc(_0x40f419[_0xa7d8('0x13')][_0xa7d8('0x14')]);}else{logger[_0xa7d8('0x15')](_0xa7d8('0xf'),_0x410b09,_0xa7d8('0x11'));_0x1807cc(_0x40f419[_0xa7d8('0x16')][_0xa7d8('0x14')]);}})[_0xa7d8('0x17')](function(_0xfc0284){logger[_0xa7d8('0x13')](_0xa7d8('0xf'),_0x410b09,_0xfc0284);_0x455082(_0xfc0284);});});}exports[_0xa7d8('0x18')]=function(_0x50d6a6){var _0x34eac8=this;return new Promise(function(_0x3af212,_0x50dd47){return db[_0xa7d8('0x19')][_0xa7d8('0x1a')]({'raw':_0x50d6a6[_0xa7d8('0x1b')]?_0x50d6a6[_0xa7d8('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x50d6a6[_0xa7d8('0x1b')]?_0x50d6a6['options'][_0xa7d8('0x1c')]||null:null,'attributes':_0x50d6a6[_0xa7d8('0x1b')]?_0x50d6a6['options'][_0xa7d8('0x1d')]||null:null,'limit':_0x50d6a6[_0xa7d8('0x1b')]?_0x50d6a6[_0xa7d8('0x1b')][_0xa7d8('0x1e')]||null:null,'include':_0x50d6a6[_0xa7d8('0x1b')]?_0x50d6a6['options'][_0xa7d8('0x1f')]?_[_0xa7d8('0x20')](_0x50d6a6['options'][_0xa7d8('0x1f')],function(_0x31afb8){return{'model':db[_0x31afb8['model']],'as':_0x31afb8['as'],'attributes':_0x31afb8[_0xa7d8('0x1d')],'include':_0x31afb8[_0xa7d8('0x1f')]?_[_0xa7d8('0x20')](_0x31afb8[_0xa7d8('0x1f')],function(_0x1f49f6){return{'model':db[_0x1f49f6[_0xa7d8('0x21')]],'as':_0x1f49f6['as'],'attributes':_0x1f49f6[_0xa7d8('0x1d')],'include':_0x1f49f6['include']?_[_0xa7d8('0x20')](_0x1f49f6['include'],function(_0x1dcb71){return{'model':db[_0x1dcb71['model']],'as':_0x1dcb71['as'],'attributes':_0x1dcb71['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x491fa0){logger[_0xa7d8('0x15')](_0xa7d8('0x18'),_0x50d6a6);logger['debug'](_0xa7d8('0x18'),_0x50d6a6,JSON[_0xa7d8('0x12')](_0x491fa0));_0x3af212(_0x491fa0);})[_0xa7d8('0x17')](function(_0x54676b){logger[_0xa7d8('0x13')](_0xa7d8('0x18'),_0x54676b[_0xa7d8('0x14')],_0x50d6a6);_0x50dd47(_0x34eac8['error'](0x1f4,_0x54676b[_0xa7d8('0x14')]));});});};exports[_0xa7d8('0x22')]=function(_0x541508){var _0x5f1b22=this;return new Promise(function(_0x1f56d2,_0x3d31fa){return db[_0xa7d8('0x19')]['find']({'raw':_0x541508['options']?_0x541508['options'][_0xa7d8('0x23')]===undefined?!![]:![]:!![],'where':_0x541508[_0xa7d8('0x1b')]?_0x541508['options'][_0xa7d8('0x1c')]||null:null,'attributes':_0x541508['options']?_0x541508[_0xa7d8('0x1b')]['attributes']||null:null,'include':_0x541508[_0xa7d8('0x1b')]?_0x541508[_0xa7d8('0x1b')][_0xa7d8('0x1f')]?_['map'](_0x541508[_0xa7d8('0x1b')][_0xa7d8('0x1f')],function(_0x3025b0){return{'model':db[_0x3025b0[_0xa7d8('0x21')]],'as':_0x3025b0['as'],'attributes':_0x3025b0[_0xa7d8('0x1d')],'include':_0x3025b0[_0xa7d8('0x1f')]?_[_0xa7d8('0x20')](_0x3025b0[_0xa7d8('0x1f')],function(_0xb3e677){return{'model':db[_0xb3e677[_0xa7d8('0x21')]],'as':_0xb3e677['as'],'attributes':_0xb3e677[_0xa7d8('0x1d')],'include':_0xb3e677['include']?_[_0xa7d8('0x20')](_0xb3e677[_0xa7d8('0x1f')],function(_0x2073bc){return{'model':db[_0x2073bc[_0xa7d8('0x21')]],'as':_0x2073bc['as'],'attributes':_0x2073bc[_0xa7d8('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x202be8){logger[_0xa7d8('0x15')](_0xa7d8('0x22'),_0x541508);logger[_0xa7d8('0x10')](_0xa7d8('0x22'),_0x541508,JSON[_0xa7d8('0x12')](_0x202be8));_0x1f56d2(_0x202be8);})[_0xa7d8('0x17')](function(_0x2e1357){logger[_0xa7d8('0x13')](_0xa7d8('0x22'),_0x2e1357[_0xa7d8('0x14')],_0x541508);_0x3d31fa(_0x5f1b22[_0xa7d8('0x13')](0x1f4,_0x2e1357['message']));});});};