Built motion from commit 10af8726.|2.6.34
[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 _0xd85e=['limit','include','map','model','attributes','ShowSalesforceAccount','lodash','util','moment','bluebird','../../config/logger','rpc','http','then','SalesforceAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','info','result','catch','GetSalesforceAccount','options','raw','where'];(function(_0x3be9da,_0x4113e8){var _0x392bf6=function(_0x573aa7){while(--_0x573aa7){_0x3be9da['push'](_0x3be9da['shift']());}};_0x392bf6(++_0x4113e8);}(_0xd85e,0x72));var _0xed85=function(_0x1b9ee2,_0x5cbd3e){_0x1b9ee2=_0x1b9ee2-0x0;var _0xdc1b94=_0xd85e[_0x1b9ee2];return _0xdc1b94;};'use strict';var _=require(_0xed85('0x0'));var util=require(_0xed85('0x1'));var moment=require(_0xed85('0x2'));var BPromise=require(_0xed85('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xed85('0x4'))(_0xed85('0x5'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0xed85('0x6')]({'port':0x232a});function respondWithRpcPromise(_0x1147e3,_0x50ca4b,_0x801c9c){return new BPromise(function(_0x1c1543,_0x25fe72){return client['request'](_0x1147e3,_0x801c9c)[_0xed85('0x7')](function(_0x4c1f31){logger['info'](_0xed85('0x8'),_0x50ca4b,_0xed85('0x9'));logger[_0xed85('0xa')]('SalesforceAccount,\x20%s,\x20%s,\x20%s',_0x50ca4b,'request\x20sent',JSON[_0xed85('0xb')](_0x4c1f31));if(_0x4c1f31['error']){if(_0x4c1f31[_0xed85('0xc')]['code']===0x1f4){logger[_0xed85('0xc')](_0xed85('0x8'),_0x50ca4b,_0x4c1f31[_0xed85('0xc')][_0xed85('0xd')]);return _0x25fe72(_0x4c1f31[_0xed85('0xc')][_0xed85('0xd')]);}logger[_0xed85('0xc')](_0xed85('0x8'),_0x50ca4b,_0x4c1f31[_0xed85('0xc')][_0xed85('0xd')]);return _0x1c1543(_0x4c1f31[_0xed85('0xc')][_0xed85('0xd')]);}else{logger[_0xed85('0xe')]('SalesforceAccount,\x20%s,\x20%s',_0x50ca4b,_0xed85('0x9'));_0x1c1543(_0x4c1f31[_0xed85('0xf')]['message']);}})[_0xed85('0x10')](function(_0x1816d3){logger[_0xed85('0xc')](_0xed85('0x8'),_0x50ca4b,_0x1816d3);_0x25fe72(_0x1816d3);});});}exports[_0xed85('0x11')]=function(_0x339707){var _0x234c55=this;return new Promise(function(_0x1dd1f2,_0x45208c){return db['SalesforceAccount']['findAll']({'raw':_0x339707[_0xed85('0x12')]?_0x339707['options'][_0xed85('0x13')]===undefined?!![]:![]:!![],'where':_0x339707[_0xed85('0x12')]?_0x339707['options'][_0xed85('0x14')]||null:null,'attributes':_0x339707[_0xed85('0x12')]?_0x339707['options']['attributes']||null:null,'limit':_0x339707[_0xed85('0x12')]?_0x339707[_0xed85('0x12')][_0xed85('0x15')]||null:null,'include':_0x339707[_0xed85('0x12')]?_0x339707[_0xed85('0x12')][_0xed85('0x16')]?_[_0xed85('0x17')](_0x339707[_0xed85('0x12')][_0xed85('0x16')],function(_0x165b14){return{'model':db[_0x165b14[_0xed85('0x18')]],'as':_0x165b14['as'],'attributes':_0x165b14['attributes'],'include':_0x165b14[_0xed85('0x16')]?_[_0xed85('0x17')](_0x165b14[_0xed85('0x16')],function(_0x1eb69e){return{'model':db[_0x1eb69e[_0xed85('0x18')]],'as':_0x1eb69e['as'],'attributes':_0x1eb69e[_0xed85('0x19')],'include':_0x1eb69e['include']?_[_0xed85('0x17')](_0x1eb69e[_0xed85('0x16')],function(_0xa15599){return{'model':db[_0xa15599[_0xed85('0x18')]],'as':_0xa15599['as'],'attributes':_0xa15599['attributes']};}):[]};}):[]};}):[]:[]})[_0xed85('0x7')](function(_0x2e4e7e){logger[_0xed85('0xe')]('GetSalesforceAccount',_0x339707);logger[_0xed85('0xa')](_0xed85('0x11'),_0x339707,JSON[_0xed85('0xb')](_0x2e4e7e));_0x1dd1f2(_0x2e4e7e);})['catch'](function(_0x36093e){logger[_0xed85('0xc')](_0xed85('0x11'),_0x36093e[_0xed85('0xd')],_0x339707);_0x45208c(_0x234c55[_0xed85('0xc')](0x1f4,_0x36093e[_0xed85('0xd')]));});});};exports['ShowSalesforceAccount']=function(_0x1094b1){var _0x28be58=this;return new Promise(function(_0x5dfd78,_0x3f09a5){return db['SalesforceAccount']['find']({'raw':_0x1094b1[_0xed85('0x12')]?_0x1094b1[_0xed85('0x12')][_0xed85('0x13')]===undefined?!![]:![]:!![],'where':_0x1094b1[_0xed85('0x12')]?_0x1094b1[_0xed85('0x12')][_0xed85('0x14')]||null:null,'attributes':_0x1094b1[_0xed85('0x12')]?_0x1094b1[_0xed85('0x12')][_0xed85('0x19')]||null:null,'include':_0x1094b1[_0xed85('0x12')]?_0x1094b1[_0xed85('0x12')][_0xed85('0x16')]?_[_0xed85('0x17')](_0x1094b1[_0xed85('0x12')][_0xed85('0x16')],function(_0x1c2386){return{'model':db[_0x1c2386[_0xed85('0x18')]],'as':_0x1c2386['as'],'attributes':_0x1c2386['attributes'],'include':_0x1c2386[_0xed85('0x16')]?_[_0xed85('0x17')](_0x1c2386['include'],function(_0x3e4212){return{'model':db[_0x3e4212[_0xed85('0x18')]],'as':_0x3e4212['as'],'attributes':_0x3e4212[_0xed85('0x19')],'include':_0x3e4212['include']?_[_0xed85('0x17')](_0x3e4212[_0xed85('0x16')],function(_0x119fc7){return{'model':db[_0x119fc7[_0xed85('0x18')]],'as':_0x119fc7['as'],'attributes':_0x119fc7[_0xed85('0x19')]};}):[]};}):[]};}):[]:[]})[_0xed85('0x7')](function(_0x39a3e6){logger['info']('ShowSalesforceAccount',_0x1094b1);logger[_0xed85('0xa')](_0xed85('0x1a'),_0x1094b1,JSON[_0xed85('0xb')](_0x39a3e6));_0x5dfd78(_0x39a3e6);})[_0xed85('0x10')](function(_0x2cbed6){logger['error'](_0xed85('0x1a'),_0x2cbed6[_0xed85('0xd')],_0x1094b1);_0x3f09a5(_0x28be58[_0xed85('0xc')](0x1f4,_0x2cbed6[_0xed85('0xd')]));});});};