Built motion from commit b0a9a629.|2.6.33
[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 _0x5cc6=['randomstring','ioredis','rpc','../../config/environment','jayson/promise','http','request','then','info','SalesforceAccount,\x20%s,\x20%s','debug','SalesforceAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','catch','GetSalesforceAccount','SalesforceAccount','findAll','raw','options','where','attributes','limit','include','map','model','ShowSalesforceAccount','lodash','util','moment'];(function(_0x3401ce,_0x5d1579){var _0x1bb79d=function(_0x46985e){while(--_0x46985e){_0x3401ce['push'](_0x3401ce['shift']());}};_0x1bb79d(++_0x5d1579);}(_0x5cc6,0x13d));var _0x65cc=function(_0x199bc4,_0x338105){_0x199bc4=_0x199bc4-0x0;var _0x136ffb=_0x5cc6[_0x199bc4];return _0x136ffb;};'use strict';var _=require(_0x65cc('0x0'));var util=require(_0x65cc('0x1'));var moment=require(_0x65cc('0x2'));var BPromise=require('bluebird');var rs=require(_0x65cc('0x3'));var fs=require('fs');var Redis=require(_0x65cc('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x65cc('0x5'));var config=require(_0x65cc('0x6'));var jayson=require(_0x65cc('0x7'));var client=jayson['client'][_0x65cc('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x503655,_0x31aaed,_0x3601b0){return new BPromise(function(_0x397737,_0x1d494c){return client[_0x65cc('0x9')](_0x503655,_0x3601b0)[_0x65cc('0xa')](function(_0x31b3c4){logger[_0x65cc('0xb')](_0x65cc('0xc'),_0x31aaed,'request\x20sent');logger[_0x65cc('0xd')](_0x65cc('0xe'),_0x31aaed,_0x65cc('0xf'),JSON[_0x65cc('0x10')](_0x31b3c4));if(_0x31b3c4['error']){if(_0x31b3c4['error']['code']===0x1f4){logger['error'](_0x65cc('0xc'),_0x31aaed,_0x31b3c4[_0x65cc('0x11')][_0x65cc('0x12')]);return _0x1d494c(_0x31b3c4[_0x65cc('0x11')][_0x65cc('0x12')]);}logger['error'](_0x65cc('0xc'),_0x31aaed,_0x31b3c4['error'][_0x65cc('0x12')]);return _0x397737(_0x31b3c4[_0x65cc('0x11')][_0x65cc('0x12')]);}else{logger[_0x65cc('0xb')](_0x65cc('0xc'),_0x31aaed,'request\x20sent');_0x397737(_0x31b3c4['result']['message']);}})[_0x65cc('0x13')](function(_0x5a9c29){logger[_0x65cc('0x11')](_0x65cc('0xc'),_0x31aaed,_0x5a9c29);_0x1d494c(_0x5a9c29);});});}exports[_0x65cc('0x14')]=function(_0x5bfc0e){var _0x114560=this;return new Promise(function(_0x7d5685,_0x13e52e){return db[_0x65cc('0x15')][_0x65cc('0x16')]({'raw':_0x5bfc0e['options']?_0x5bfc0e['options'][_0x65cc('0x17')]===undefined?!![]:![]:!![],'where':_0x5bfc0e[_0x65cc('0x18')]?_0x5bfc0e[_0x65cc('0x18')][_0x65cc('0x19')]||null:null,'attributes':_0x5bfc0e['options']?_0x5bfc0e[_0x65cc('0x18')][_0x65cc('0x1a')]||null:null,'limit':_0x5bfc0e[_0x65cc('0x18')]?_0x5bfc0e[_0x65cc('0x18')][_0x65cc('0x1b')]||null:null,'include':_0x5bfc0e[_0x65cc('0x18')]?_0x5bfc0e[_0x65cc('0x18')][_0x65cc('0x1c')]?_[_0x65cc('0x1d')](_0x5bfc0e['options'][_0x65cc('0x1c')],function(_0xc2fcd8){return{'model':db[_0xc2fcd8[_0x65cc('0x1e')]],'as':_0xc2fcd8['as'],'attributes':_0xc2fcd8[_0x65cc('0x1a')],'include':_0xc2fcd8['include']?_[_0x65cc('0x1d')](_0xc2fcd8[_0x65cc('0x1c')],function(_0x1a014b){return{'model':db[_0x1a014b[_0x65cc('0x1e')]],'as':_0x1a014b['as'],'attributes':_0x1a014b[_0x65cc('0x1a')],'include':_0x1a014b['include']?_[_0x65cc('0x1d')](_0x1a014b['include'],function(_0x403a0f){return{'model':db[_0x403a0f[_0x65cc('0x1e')]],'as':_0x403a0f['as'],'attributes':_0x403a0f[_0x65cc('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x65cc('0xa')](function(_0x442a41){logger['info'](_0x65cc('0x14'),_0x5bfc0e);logger[_0x65cc('0xd')](_0x65cc('0x14'),_0x5bfc0e,JSON[_0x65cc('0x10')](_0x442a41));_0x7d5685(_0x442a41);})[_0x65cc('0x13')](function(_0x20c07f){logger[_0x65cc('0x11')](_0x65cc('0x14'),_0x20c07f[_0x65cc('0x12')],_0x5bfc0e);_0x13e52e(_0x114560[_0x65cc('0x11')](0x1f4,_0x20c07f[_0x65cc('0x12')]));});});};exports[_0x65cc('0x1f')]=function(_0x23ee54){var _0x23cfb5=this;return new Promise(function(_0x208c5a,_0x49bbd8){return db[_0x65cc('0x15')]['find']({'raw':_0x23ee54[_0x65cc('0x18')]?_0x23ee54[_0x65cc('0x18')][_0x65cc('0x17')]===undefined?!![]:![]:!![],'where':_0x23ee54[_0x65cc('0x18')]?_0x23ee54[_0x65cc('0x18')][_0x65cc('0x19')]||null:null,'attributes':_0x23ee54['options']?_0x23ee54[_0x65cc('0x18')]['attributes']||null:null,'include':_0x23ee54['options']?_0x23ee54[_0x65cc('0x18')][_0x65cc('0x1c')]?_[_0x65cc('0x1d')](_0x23ee54['options']['include'],function(_0x49ee9d){return{'model':db[_0x49ee9d[_0x65cc('0x1e')]],'as':_0x49ee9d['as'],'attributes':_0x49ee9d[_0x65cc('0x1a')],'include':_0x49ee9d[_0x65cc('0x1c')]?_[_0x65cc('0x1d')](_0x49ee9d[_0x65cc('0x1c')],function(_0x14755f){return{'model':db[_0x14755f[_0x65cc('0x1e')]],'as':_0x14755f['as'],'attributes':_0x14755f[_0x65cc('0x1a')],'include':_0x14755f[_0x65cc('0x1c')]?_[_0x65cc('0x1d')](_0x14755f[_0x65cc('0x1c')],function(_0x5ef8fd){return{'model':db[_0x5ef8fd[_0x65cc('0x1e')]],'as':_0x5ef8fd['as'],'attributes':_0x5ef8fd[_0x65cc('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5b3559){logger['info'](_0x65cc('0x1f'),_0x23ee54);logger[_0x65cc('0xd')](_0x65cc('0x1f'),_0x23ee54,JSON[_0x65cc('0x10')](_0x5b3559));_0x208c5a(_0x5b3559);})[_0x65cc('0x13')](function(_0x552144){logger['error'](_0x65cc('0x1f'),_0x552144[_0x65cc('0x12')],_0x23ee54);_0x49bbd8(_0x23cfb5[_0x65cc('0x11')](0x1f4,_0x552144[_0x65cc('0x12')]));});});};