Built motion from commit e0fa946e.|2.6.5
[motion2.git] / server / api / intServicenowAccount / intServicenowAccount.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 _0xf6b3=['GetServicenowAccount','raw','options','where','attributes','include','map','model','ServicenowAccount','find','ShowServicenowAccount','moment','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','then','ServicenowAccount,\x20%s,\x20%s','request\x20sent','debug','ServicenowAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch'];(function(_0x934425,_0x5af72f){var _0x31d596=function(_0x219869){while(--_0x219869){_0x934425['push'](_0x934425['shift']());}};_0x31d596(++_0x5af72f);}(_0xf6b3,0x103));var _0x3f6b=function(_0x1318f8,_0x3a4626){_0x1318f8=_0x1318f8-0x0;var _0x284b66=_0xf6b3[_0x1318f8];return _0x284b66;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x3f6b('0x0'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x3f6b('0x1'));var db=require('../../mysqldb')['db'];var utils=require(_0x3f6b('0x2'));var logger=require(_0x3f6b('0x3'))(_0x3f6b('0x4'));var config=require(_0x3f6b('0x5'));var jayson=require(_0x3f6b('0x6'));var client=jayson[_0x3f6b('0x7')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2a458c,_0x445e0d,_0x5c3050){return new BPromise(function(_0x251a14,_0x2216db){return client['request'](_0x2a458c,_0x5c3050)[_0x3f6b('0x8')](function(_0x3e544f){logger['info'](_0x3f6b('0x9'),_0x445e0d,_0x3f6b('0xa'));logger[_0x3f6b('0xb')](_0x3f6b('0xc'),_0x445e0d,_0x3f6b('0xa'),JSON[_0x3f6b('0xd')](_0x3e544f));if(_0x3e544f[_0x3f6b('0xe')]){if(_0x3e544f[_0x3f6b('0xe')][_0x3f6b('0xf')]===0x1f4){logger['error'](_0x3f6b('0x9'),_0x445e0d,_0x3e544f[_0x3f6b('0xe')][_0x3f6b('0x10')]);return _0x2216db(_0x3e544f['error']['message']);}logger['error'](_0x3f6b('0x9'),_0x445e0d,_0x3e544f[_0x3f6b('0xe')][_0x3f6b('0x10')]);return _0x251a14(_0x3e544f[_0x3f6b('0xe')][_0x3f6b('0x10')]);}else{logger[_0x3f6b('0x11')](_0x3f6b('0x9'),_0x445e0d,_0x3f6b('0xa'));_0x251a14(_0x3e544f[_0x3f6b('0x12')][_0x3f6b('0x10')]);}})[_0x3f6b('0x13')](function(_0xb9758c){logger[_0x3f6b('0xe')](_0x3f6b('0x9'),_0x445e0d,_0xb9758c);_0x2216db(_0xb9758c);});});}exports[_0x3f6b('0x14')]=function(_0x195b06){var _0x226e7a=this;return new Promise(function(_0x32dabf,_0x533850){return db['ServicenowAccount']['findAll']({'raw':_0x195b06['options']?_0x195b06['options'][_0x3f6b('0x15')]===undefined?!![]:![]:!![],'where':_0x195b06[_0x3f6b('0x16')]?_0x195b06[_0x3f6b('0x16')][_0x3f6b('0x17')]||null:null,'attributes':_0x195b06[_0x3f6b('0x16')]?_0x195b06['options'][_0x3f6b('0x18')]||null:null,'limit':_0x195b06[_0x3f6b('0x16')]?_0x195b06[_0x3f6b('0x16')]['limit']||null:null,'include':_0x195b06[_0x3f6b('0x16')]?_0x195b06['options'][_0x3f6b('0x19')]?_['map'](_0x195b06[_0x3f6b('0x16')][_0x3f6b('0x19')],function(_0x538953){return{'model':db[_0x538953['model']],'as':_0x538953['as'],'attributes':_0x538953['attributes'],'include':_0x538953[_0x3f6b('0x19')]?_[_0x3f6b('0x1a')](_0x538953[_0x3f6b('0x19')],function(_0x492349){return{'model':db[_0x492349[_0x3f6b('0x1b')]],'as':_0x492349['as'],'attributes':_0x492349[_0x3f6b('0x18')],'include':_0x492349[_0x3f6b('0x19')]?_['map'](_0x492349[_0x3f6b('0x19')],function(_0x568062){return{'model':db[_0x568062[_0x3f6b('0x1b')]],'as':_0x568062['as'],'attributes':_0x568062['attributes']};}):[]};}):[]};}):[]:[]})[_0x3f6b('0x8')](function(_0x4d8370){logger[_0x3f6b('0x11')](_0x3f6b('0x14'),_0x195b06);logger[_0x3f6b('0xb')](_0x3f6b('0x14'),_0x195b06,JSON[_0x3f6b('0xd')](_0x4d8370));_0x32dabf(_0x4d8370);})['catch'](function(_0x5b18d6){logger[_0x3f6b('0xe')](_0x3f6b('0x14'),_0x5b18d6[_0x3f6b('0x10')],_0x195b06);_0x533850(_0x226e7a[_0x3f6b('0xe')](0x1f4,_0x5b18d6[_0x3f6b('0x10')]));});});};exports['ShowServicenowAccount']=function(_0x5437ec){var _0x5c157f=this;return new Promise(function(_0x324e24,_0x9cd6d1){return db[_0x3f6b('0x1c')][_0x3f6b('0x1d')]({'raw':_0x5437ec[_0x3f6b('0x16')]?_0x5437ec[_0x3f6b('0x16')][_0x3f6b('0x15')]===undefined?!![]:![]:!![],'where':_0x5437ec[_0x3f6b('0x16')]?_0x5437ec[_0x3f6b('0x16')][_0x3f6b('0x17')]||null:null,'attributes':_0x5437ec['options']?_0x5437ec[_0x3f6b('0x16')][_0x3f6b('0x18')]||null:null,'include':_0x5437ec[_0x3f6b('0x16')]?_0x5437ec[_0x3f6b('0x16')]['include']?_['map'](_0x5437ec['options'][_0x3f6b('0x19')],function(_0x5abcc3){return{'model':db[_0x5abcc3[_0x3f6b('0x1b')]],'as':_0x5abcc3['as'],'attributes':_0x5abcc3[_0x3f6b('0x18')],'include':_0x5abcc3[_0x3f6b('0x19')]?_['map'](_0x5abcc3[_0x3f6b('0x19')],function(_0x24386e){return{'model':db[_0x24386e[_0x3f6b('0x1b')]],'as':_0x24386e['as'],'attributes':_0x24386e['attributes'],'include':_0x24386e[_0x3f6b('0x19')]?_[_0x3f6b('0x1a')](_0x24386e[_0x3f6b('0x19')],function(_0x146a3a){return{'model':db[_0x146a3a[_0x3f6b('0x1b')]],'as':_0x146a3a['as'],'attributes':_0x146a3a['attributes']};}):[]};}):[]};}):[]:[]})[_0x3f6b('0x8')](function(_0x39db0c){logger[_0x3f6b('0x11')](_0x3f6b('0x1e'),_0x5437ec);logger[_0x3f6b('0xb')]('ShowServicenowAccount',_0x5437ec,JSON['stringify'](_0x39db0c));_0x324e24(_0x39db0c);})['catch'](function(_0x5e41ee){logger['error'](_0x3f6b('0x1e'),_0x5e41ee['message'],_0x5437ec);_0x9cd6d1(_0x5c157f[_0x3f6b('0xe')](0x1f4,_0x5e41ee['message']));});});};