Built motion from commit 20b39a97.|2.6.29
[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 _0x3fd5=['moment','ioredis','../../mysqldb','../../config/utils','client','request','then','info','SalesforceAccount,\x20%s,\x20%s','debug','SalesforceAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','request\x20sent','result','catch','GetSalesforceAccount','SalesforceAccount','options','raw','where','include','map','model','attributes','ShowSalesforceAccount','find','lodash'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x3fd5,0x12b));var _0x53fd=function(_0x5e9ed3,_0x53f82e){_0x5e9ed3=_0x5e9ed3-0x0;var _0x2241c9=_0x3fd5[_0x5e9ed3];return _0x2241c9;};'use strict';var _=require(_0x53fd('0x0'));var util=require('util');var moment=require(_0x53fd('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x53fd('0x2'));var db=require(_0x53fd('0x3'))['db'];var utils=require(_0x53fd('0x4'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x53fd('0x5')]['http']({'port':0x232a});function respondWithRpcPromise(_0x57ce47,_0x16831c,_0x14db03){return new BPromise(function(_0x90bf3e,_0x162bdc){return client[_0x53fd('0x6')](_0x57ce47,_0x14db03)[_0x53fd('0x7')](function(_0x315b3c){logger[_0x53fd('0x8')](_0x53fd('0x9'),_0x16831c,'request\x20sent');logger[_0x53fd('0xa')](_0x53fd('0xb'),_0x16831c,'request\x20sent',JSON[_0x53fd('0xc')](_0x315b3c));if(_0x315b3c[_0x53fd('0xd')]){if(_0x315b3c['error'][_0x53fd('0xe')]===0x1f4){logger['error']('SalesforceAccount,\x20%s,\x20%s',_0x16831c,_0x315b3c['error']['message']);return _0x162bdc(_0x315b3c[_0x53fd('0xd')][_0x53fd('0xf')]);}logger[_0x53fd('0xd')](_0x53fd('0x9'),_0x16831c,_0x315b3c['error']['message']);return _0x90bf3e(_0x315b3c['error'][_0x53fd('0xf')]);}else{logger[_0x53fd('0x8')]('SalesforceAccount,\x20%s,\x20%s',_0x16831c,_0x53fd('0x10'));_0x90bf3e(_0x315b3c[_0x53fd('0x11')][_0x53fd('0xf')]);}})[_0x53fd('0x12')](function(_0x44683e){logger[_0x53fd('0xd')](_0x53fd('0x9'),_0x16831c,_0x44683e);_0x162bdc(_0x44683e);});});}exports[_0x53fd('0x13')]=function(_0x1b1f14){var _0x2c7938=this;return new Promise(function(_0x54dcf9,_0xa19df0){return db[_0x53fd('0x14')]['findAll']({'raw':_0x1b1f14['options']?_0x1b1f14[_0x53fd('0x15')][_0x53fd('0x16')]===undefined?!![]:![]:!![],'where':_0x1b1f14[_0x53fd('0x15')]?_0x1b1f14[_0x53fd('0x15')][_0x53fd('0x17')]||null:null,'attributes':_0x1b1f14[_0x53fd('0x15')]?_0x1b1f14[_0x53fd('0x15')]['attributes']||null:null,'limit':_0x1b1f14[_0x53fd('0x15')]?_0x1b1f14[_0x53fd('0x15')]['limit']||null:null,'include':_0x1b1f14[_0x53fd('0x15')]?_0x1b1f14[_0x53fd('0x15')][_0x53fd('0x18')]?_[_0x53fd('0x19')](_0x1b1f14[_0x53fd('0x15')][_0x53fd('0x18')],function(_0x55337d){return{'model':db[_0x55337d[_0x53fd('0x1a')]],'as':_0x55337d['as'],'attributes':_0x55337d[_0x53fd('0x1b')],'include':_0x55337d['include']?_[_0x53fd('0x19')](_0x55337d[_0x53fd('0x18')],function(_0x59663d){return{'model':db[_0x59663d['model']],'as':_0x59663d['as'],'attributes':_0x59663d[_0x53fd('0x1b')],'include':_0x59663d[_0x53fd('0x18')]?_[_0x53fd('0x19')](_0x59663d[_0x53fd('0x18')],function(_0xf0f02a){return{'model':db[_0xf0f02a[_0x53fd('0x1a')]],'as':_0xf0f02a['as'],'attributes':_0xf0f02a[_0x53fd('0x1b')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x3e2de6){logger[_0x53fd('0x8')]('GetSalesforceAccount',_0x1b1f14);logger[_0x53fd('0xa')](_0x53fd('0x13'),_0x1b1f14,JSON[_0x53fd('0xc')](_0x3e2de6));_0x54dcf9(_0x3e2de6);})[_0x53fd('0x12')](function(_0x5bd10f){logger['error'](_0x53fd('0x13'),_0x5bd10f['message'],_0x1b1f14);_0xa19df0(_0x2c7938[_0x53fd('0xd')](0x1f4,_0x5bd10f[_0x53fd('0xf')]));});});};exports[_0x53fd('0x1c')]=function(_0x2879c4){var _0x176ea3=this;return new Promise(function(_0x17df94,_0x18d2fe){return db[_0x53fd('0x14')][_0x53fd('0x1d')]({'raw':_0x2879c4[_0x53fd('0x15')]?_0x2879c4[_0x53fd('0x15')][_0x53fd('0x16')]===undefined?!![]:![]:!![],'where':_0x2879c4[_0x53fd('0x15')]?_0x2879c4[_0x53fd('0x15')][_0x53fd('0x17')]||null:null,'attributes':_0x2879c4[_0x53fd('0x15')]?_0x2879c4['options'][_0x53fd('0x1b')]||null:null,'include':_0x2879c4['options']?_0x2879c4['options']['include']?_[_0x53fd('0x19')](_0x2879c4[_0x53fd('0x15')][_0x53fd('0x18')],function(_0x519f20){return{'model':db[_0x519f20['model']],'as':_0x519f20['as'],'attributes':_0x519f20[_0x53fd('0x1b')],'include':_0x519f20[_0x53fd('0x18')]?_['map'](_0x519f20[_0x53fd('0x18')],function(_0x6ed9c3){return{'model':db[_0x6ed9c3[_0x53fd('0x1a')]],'as':_0x6ed9c3['as'],'attributes':_0x6ed9c3['attributes'],'include':_0x6ed9c3[_0x53fd('0x18')]?_[_0x53fd('0x19')](_0x6ed9c3[_0x53fd('0x18')],function(_0x19a651){return{'model':db[_0x19a651['model']],'as':_0x19a651['as'],'attributes':_0x19a651[_0x53fd('0x1b')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xfd34d7){logger[_0x53fd('0x8')](_0x53fd('0x1c'),_0x2879c4);logger[_0x53fd('0xa')]('ShowSalesforceAccount',_0x2879c4,JSON[_0x53fd('0xc')](_0xfd34d7));_0x17df94(_0xfd34d7);})['catch'](function(_0x3f8ec4){logger[_0x53fd('0xd')]('ShowSalesforceAccount',_0x3f8ec4[_0x53fd('0xf')],_0x2879c4);_0x18d2fe(_0x176ea3[_0x53fd('0xd')](0x1f4,_0x3f8ec4[_0x53fd('0xf')]));});});};