Built motion from commit ae138b72.|2.6.28
[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 _0xd97a=['jayson/promise','client','http','request','SalesforceAccount,\x20%s,\x20%s','request\x20sent','SalesforceAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','SalesforceAccount','options','raw','where','attributes','limit','include','model','map','then','GetSalesforceAccount','ShowSalesforceAccount','find','debug','lodash','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment'];(function(_0x311f44,_0x1d7f5b){var _0x46f1e6=function(_0x27342a){while(--_0x27342a){_0x311f44['push'](_0x311f44['shift']());}};_0x46f1e6(++_0x1d7f5b);}(_0xd97a,0x13c));var _0xad97=function(_0x310b48,_0x2fbe9c){_0x310b48=_0x310b48-0x0;var _0x570b36=_0xd97a[_0x310b48];return _0x570b36;};'use strict';var _=require(_0xad97('0x0'));var util=require('util');var moment=require(_0xad97('0x1'));var BPromise=require(_0xad97('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xad97('0x3'))['db'];var utils=require(_0xad97('0x4'));var logger=require(_0xad97('0x5'))(_0xad97('0x6'));var config=require(_0xad97('0x7'));var jayson=require(_0xad97('0x8'));var client=jayson[_0xad97('0x9')][_0xad97('0xa')]({'port':0x232a});function respondWithRpcPromise(_0xd0914a,_0x48c842,_0x4acd33){return new BPromise(function(_0x5a82ed,_0x1295ea){return client[_0xad97('0xb')](_0xd0914a,_0x4acd33)['then'](function(_0x4fa2a9){logger['info'](_0xad97('0xc'),_0x48c842,_0xad97('0xd'));logger['debug'](_0xad97('0xe'),_0x48c842,_0xad97('0xd'),JSON[_0xad97('0xf')](_0x4fa2a9));if(_0x4fa2a9[_0xad97('0x10')]){if(_0x4fa2a9['error'][_0xad97('0x11')]===0x1f4){logger['error'](_0xad97('0xc'),_0x48c842,_0x4fa2a9[_0xad97('0x10')][_0xad97('0x12')]);return _0x1295ea(_0x4fa2a9[_0xad97('0x10')][_0xad97('0x12')]);}logger[_0xad97('0x10')](_0xad97('0xc'),_0x48c842,_0x4fa2a9[_0xad97('0x10')][_0xad97('0x12')]);return _0x5a82ed(_0x4fa2a9[_0xad97('0x10')][_0xad97('0x12')]);}else{logger[_0xad97('0x13')](_0xad97('0xc'),_0x48c842,'request\x20sent');_0x5a82ed(_0x4fa2a9[_0xad97('0x14')][_0xad97('0x12')]);}})[_0xad97('0x15')](function(_0x182303){logger['error']('SalesforceAccount,\x20%s,\x20%s',_0x48c842,_0x182303);_0x1295ea(_0x182303);});});}exports['GetSalesforceAccount']=function(_0x342927){var _0x200d46=this;return new Promise(function(_0x19c7db,_0x151e07){return db[_0xad97('0x16')]['findAll']({'raw':_0x342927[_0xad97('0x17')]?_0x342927[_0xad97('0x17')][_0xad97('0x18')]===undefined?!![]:![]:!![],'where':_0x342927[_0xad97('0x17')]?_0x342927[_0xad97('0x17')][_0xad97('0x19')]||null:null,'attributes':_0x342927['options']?_0x342927[_0xad97('0x17')][_0xad97('0x1a')]||null:null,'limit':_0x342927[_0xad97('0x17')]?_0x342927['options'][_0xad97('0x1b')]||null:null,'include':_0x342927[_0xad97('0x17')]?_0x342927[_0xad97('0x17')][_0xad97('0x1c')]?_['map'](_0x342927[_0xad97('0x17')][_0xad97('0x1c')],function(_0x4be778){return{'model':db[_0x4be778[_0xad97('0x1d')]],'as':_0x4be778['as'],'attributes':_0x4be778[_0xad97('0x1a')],'include':_0x4be778['include']?_[_0xad97('0x1e')](_0x4be778[_0xad97('0x1c')],function(_0x132d6c){return{'model':db[_0x132d6c[_0xad97('0x1d')]],'as':_0x132d6c['as'],'attributes':_0x132d6c[_0xad97('0x1a')],'include':_0x132d6c['include']?_[_0xad97('0x1e')](_0x132d6c[_0xad97('0x1c')],function(_0x1b346b){return{'model':db[_0x1b346b[_0xad97('0x1d')]],'as':_0x1b346b['as'],'attributes':_0x1b346b[_0xad97('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xad97('0x1f')](function(_0x2a0dc6){logger[_0xad97('0x13')](_0xad97('0x20'),_0x342927);logger['debug'](_0xad97('0x20'),_0x342927,JSON[_0xad97('0xf')](_0x2a0dc6));_0x19c7db(_0x2a0dc6);})['catch'](function(_0x68770e){logger['error']('GetSalesforceAccount',_0x68770e['message'],_0x342927);_0x151e07(_0x200d46[_0xad97('0x10')](0x1f4,_0x68770e[_0xad97('0x12')]));});});};exports[_0xad97('0x21')]=function(_0x47d27b){var _0x4b6306=this;return new Promise(function(_0x4ebae4,_0x407bab){return db[_0xad97('0x16')][_0xad97('0x22')]({'raw':_0x47d27b[_0xad97('0x17')]?_0x47d27b[_0xad97('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x47d27b[_0xad97('0x17')]?_0x47d27b[_0xad97('0x17')][_0xad97('0x19')]||null:null,'attributes':_0x47d27b[_0xad97('0x17')]?_0x47d27b[_0xad97('0x17')]['attributes']||null:null,'include':_0x47d27b['options']?_0x47d27b[_0xad97('0x17')][_0xad97('0x1c')]?_[_0xad97('0x1e')](_0x47d27b[_0xad97('0x17')][_0xad97('0x1c')],function(_0x1cc581){return{'model':db[_0x1cc581[_0xad97('0x1d')]],'as':_0x1cc581['as'],'attributes':_0x1cc581[_0xad97('0x1a')],'include':_0x1cc581[_0xad97('0x1c')]?_[_0xad97('0x1e')](_0x1cc581[_0xad97('0x1c')],function(_0x2e5f71){return{'model':db[_0x2e5f71[_0xad97('0x1d')]],'as':_0x2e5f71['as'],'attributes':_0x2e5f71[_0xad97('0x1a')],'include':_0x2e5f71[_0xad97('0x1c')]?_[_0xad97('0x1e')](_0x2e5f71['include'],function(_0x12172f){return{'model':db[_0x12172f[_0xad97('0x1d')]],'as':_0x12172f['as'],'attributes':_0x12172f['attributes']};}):[]};}):[]};}):[]:[]})[_0xad97('0x1f')](function(_0x3589eb){logger[_0xad97('0x13')](_0xad97('0x21'),_0x47d27b);logger[_0xad97('0x23')](_0xad97('0x21'),_0x47d27b,JSON['stringify'](_0x3589eb));_0x4ebae4(_0x3589eb);})[_0xad97('0x15')](function(_0x4b8ce7){logger['error'](_0xad97('0x21'),_0x4b8ce7[_0xad97('0x12')],_0x47d27b);_0x407bab(_0x4b6306[_0xad97('0x10')](0x1f4,_0x4b8ce7[_0xad97('0x12')]));});});};