Built motion from commit ce03bc3d.|2.5.39
[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 _0xb4d9=['result','catch','GetSalesforceAccount','SalesforceAccount','findAll','options','raw','where','attributes','limit','include','map','model','then','find','ShowSalesforceAccount','lodash','util','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','SalesforceAccount,\x20%s,\x20%s','request\x20sent','debug','SalesforceAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info'];(function(_0x4a5e2e,_0x13b74b){var _0x207cd4=function(_0x19dc5b){while(--_0x19dc5b){_0x4a5e2e['push'](_0x4a5e2e['shift']());}};_0x207cd4(++_0x13b74b);}(_0xb4d9,0xce));var _0x9b4d=function(_0x2ec461,_0x5f588a){_0x2ec461=_0x2ec461-0x0;var _0x28603d=_0xb4d9[_0x2ec461];return _0x28603d;};'use strict';var _=require(_0x9b4d('0x0'));var util=require(_0x9b4d('0x1'));var moment=require('moment');var BPromise=require(_0x9b4d('0x2'));var rs=require(_0x9b4d('0x3'));var fs=require('fs');var Redis=require(_0x9b4d('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x9b4d('0x5'));var logger=require(_0x9b4d('0x6'))(_0x9b4d('0x7'));var config=require(_0x9b4d('0x8'));var jayson=require(_0x9b4d('0x9'));var client=jayson[_0x9b4d('0xa')][_0x9b4d('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x429cc5,_0x461cb1,_0x14cb0b){return new BPromise(function(_0x156c68,_0x48832a){return client[_0x9b4d('0xc')](_0x429cc5,_0x14cb0b)['then'](function(_0x340b21){logger['info'](_0x9b4d('0xd'),_0x461cb1,_0x9b4d('0xe'));logger[_0x9b4d('0xf')](_0x9b4d('0x10'),_0x461cb1,_0x9b4d('0xe'),JSON[_0x9b4d('0x11')](_0x340b21));if(_0x340b21[_0x9b4d('0x12')]){if(_0x340b21[_0x9b4d('0x12')][_0x9b4d('0x13')]===0x1f4){logger[_0x9b4d('0x12')](_0x9b4d('0xd'),_0x461cb1,_0x340b21[_0x9b4d('0x12')]['message']);return _0x48832a(_0x340b21[_0x9b4d('0x12')][_0x9b4d('0x14')]);}logger[_0x9b4d('0x12')](_0x9b4d('0xd'),_0x461cb1,_0x340b21['error'][_0x9b4d('0x14')]);return _0x156c68(_0x340b21['error']['message']);}else{logger[_0x9b4d('0x15')](_0x9b4d('0xd'),_0x461cb1,_0x9b4d('0xe'));_0x156c68(_0x340b21[_0x9b4d('0x16')][_0x9b4d('0x14')]);}})[_0x9b4d('0x17')](function(_0x5d23f3){logger['error'](_0x9b4d('0xd'),_0x461cb1,_0x5d23f3);_0x48832a(_0x5d23f3);});});}exports[_0x9b4d('0x18')]=function(_0x15e808){var _0x25c32d=this;return new Promise(function(_0x1c52eb,_0x20e223){return db[_0x9b4d('0x19')][_0x9b4d('0x1a')]({'raw':_0x15e808[_0x9b4d('0x1b')]?_0x15e808[_0x9b4d('0x1b')][_0x9b4d('0x1c')]===undefined?!![]:![]:!![],'where':_0x15e808[_0x9b4d('0x1b')]?_0x15e808[_0x9b4d('0x1b')][_0x9b4d('0x1d')]||null:null,'attributes':_0x15e808[_0x9b4d('0x1b')]?_0x15e808[_0x9b4d('0x1b')][_0x9b4d('0x1e')]||null:null,'limit':_0x15e808[_0x9b4d('0x1b')]?_0x15e808[_0x9b4d('0x1b')][_0x9b4d('0x1f')]||null:null,'include':_0x15e808['options']?_0x15e808[_0x9b4d('0x1b')][_0x9b4d('0x20')]?_[_0x9b4d('0x21')](_0x15e808['options'][_0x9b4d('0x20')],function(_0x5daeda){return{'model':db[_0x5daeda['model']],'as':_0x5daeda['as'],'attributes':_0x5daeda[_0x9b4d('0x1e')],'include':_0x5daeda['include']?_[_0x9b4d('0x21')](_0x5daeda[_0x9b4d('0x20')],function(_0x5607b7){return{'model':db[_0x5607b7[_0x9b4d('0x22')]],'as':_0x5607b7['as'],'attributes':_0x5607b7[_0x9b4d('0x1e')],'include':_0x5607b7[_0x9b4d('0x20')]?_['map'](_0x5607b7['include'],function(_0x465013){return{'model':db[_0x465013[_0x9b4d('0x22')]],'as':_0x465013['as'],'attributes':_0x465013['attributes']};}):[]};}):[]};}):[]:[]})[_0x9b4d('0x23')](function(_0x5d639b){logger[_0x9b4d('0x15')]('GetSalesforceAccount',_0x15e808);logger[_0x9b4d('0xf')]('GetSalesforceAccount',_0x15e808,JSON[_0x9b4d('0x11')](_0x5d639b));_0x1c52eb(_0x5d639b);})[_0x9b4d('0x17')](function(_0x5e9d1b){logger[_0x9b4d('0x12')]('GetSalesforceAccount',_0x5e9d1b['message'],_0x15e808);_0x20e223(_0x25c32d[_0x9b4d('0x12')](0x1f4,_0x5e9d1b[_0x9b4d('0x14')]));});});};exports['ShowSalesforceAccount']=function(_0x51459b){var _0xe5980d=this;return new Promise(function(_0x3b1954,_0x1da4ab){return db[_0x9b4d('0x19')][_0x9b4d('0x24')]({'raw':_0x51459b[_0x9b4d('0x1b')]?_0x51459b[_0x9b4d('0x1b')][_0x9b4d('0x1c')]===undefined?!![]:![]:!![],'where':_0x51459b[_0x9b4d('0x1b')]?_0x51459b[_0x9b4d('0x1b')][_0x9b4d('0x1d')]||null:null,'attributes':_0x51459b[_0x9b4d('0x1b')]?_0x51459b[_0x9b4d('0x1b')][_0x9b4d('0x1e')]||null:null,'include':_0x51459b[_0x9b4d('0x1b')]?_0x51459b['options'][_0x9b4d('0x20')]?_['map'](_0x51459b[_0x9b4d('0x1b')][_0x9b4d('0x20')],function(_0x141989){return{'model':db[_0x141989[_0x9b4d('0x22')]],'as':_0x141989['as'],'attributes':_0x141989[_0x9b4d('0x1e')],'include':_0x141989[_0x9b4d('0x20')]?_[_0x9b4d('0x21')](_0x141989['include'],function(_0x1b99b7){return{'model':db[_0x1b99b7[_0x9b4d('0x22')]],'as':_0x1b99b7['as'],'attributes':_0x1b99b7[_0x9b4d('0x1e')],'include':_0x1b99b7['include']?_['map'](_0x1b99b7[_0x9b4d('0x20')],function(_0x47bff3){return{'model':db[_0x47bff3['model']],'as':_0x47bff3['as'],'attributes':_0x47bff3[_0x9b4d('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x9b4d('0x23')](function(_0xb588fe){logger[_0x9b4d('0x15')](_0x9b4d('0x25'),_0x51459b);logger['debug'](_0x9b4d('0x25'),_0x51459b,JSON[_0x9b4d('0x11')](_0xb588fe));_0x3b1954(_0xb588fe);})['catch'](function(_0xf5842){logger[_0x9b4d('0x12')](_0x9b4d('0x25'),_0xf5842[_0x9b4d('0x14')],_0x51459b);_0x1da4ab(_0xe5980d[_0x9b4d('0x12')](0x1f4,_0xf5842['message']));});});};