Built motion from commit 994c64e1.|2.6.1
[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 _0x5aea=['raw','where','attributes','limit','include','map','model','GetServicenowAccount','ShowServicenowAccount','find','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/environment','client','http','then','info','ServicenowAccount,\x20%s,\x20%s','debug','ServicenowAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','ServicenowAccount','options'];(function(_0xa464c9,_0x7c86d8){var _0x3d73c4=function(_0x5c2056){while(--_0x5c2056){_0xa464c9['push'](_0xa464c9['shift']());}};_0x3d73c4(++_0x7c86d8);}(_0x5aea,0xd0));var _0xa5ae=function(_0x4caef0,_0x40cfa7){_0x4caef0=_0x4caef0-0x0;var _0x23cfa6=_0x5aea[_0x4caef0];return _0x23cfa6;};'use strict';var _=require(_0xa5ae('0x0'));var util=require(_0xa5ae('0x1'));var moment=require(_0xa5ae('0x2'));var BPromise=require(_0xa5ae('0x3'));var rs=require(_0xa5ae('0x4'));var fs=require('fs');var Redis=require(_0xa5ae('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xa5ae('0x6'));var logger=require('../../config/logger')('rpc');var config=require(_0xa5ae('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xa5ae('0x8')][_0xa5ae('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x1cd873,_0x242beb,_0x2cd5ca){return new BPromise(function(_0x4b1ec3,_0x245259){return client['request'](_0x1cd873,_0x2cd5ca)[_0xa5ae('0xa')](function(_0xafd980){logger[_0xa5ae('0xb')](_0xa5ae('0xc'),_0x242beb,'request\x20sent');logger[_0xa5ae('0xd')](_0xa5ae('0xe'),_0x242beb,_0xa5ae('0xf'),JSON[_0xa5ae('0x10')](_0xafd980));if(_0xafd980[_0xa5ae('0x11')]){if(_0xafd980[_0xa5ae('0x11')]['code']===0x1f4){logger[_0xa5ae('0x11')](_0xa5ae('0xc'),_0x242beb,_0xafd980[_0xa5ae('0x11')][_0xa5ae('0x12')]);return _0x245259(_0xafd980['error'][_0xa5ae('0x12')]);}logger[_0xa5ae('0x11')]('ServicenowAccount,\x20%s,\x20%s',_0x242beb,_0xafd980[_0xa5ae('0x11')][_0xa5ae('0x12')]);return _0x4b1ec3(_0xafd980[_0xa5ae('0x11')][_0xa5ae('0x12')]);}else{logger[_0xa5ae('0xb')](_0xa5ae('0xc'),_0x242beb,'request\x20sent');_0x4b1ec3(_0xafd980[_0xa5ae('0x13')]['message']);}})[_0xa5ae('0x14')](function(_0x2c199b){logger[_0xa5ae('0x11')]('ServicenowAccount,\x20%s,\x20%s',_0x242beb,_0x2c199b);_0x245259(_0x2c199b);});});}exports['GetServicenowAccount']=function(_0x6635ef){var _0x3b1a42=this;return new Promise(function(_0x47f2c0,_0x45b99f){return db[_0xa5ae('0x15')]['findAll']({'raw':_0x6635ef[_0xa5ae('0x16')]?_0x6635ef['options'][_0xa5ae('0x17')]===undefined?!![]:![]:!![],'where':_0x6635ef[_0xa5ae('0x16')]?_0x6635ef[_0xa5ae('0x16')][_0xa5ae('0x18')]||null:null,'attributes':_0x6635ef[_0xa5ae('0x16')]?_0x6635ef['options'][_0xa5ae('0x19')]||null:null,'limit':_0x6635ef['options']?_0x6635ef[_0xa5ae('0x16')][_0xa5ae('0x1a')]||null:null,'include':_0x6635ef[_0xa5ae('0x16')]?_0x6635ef[_0xa5ae('0x16')][_0xa5ae('0x1b')]?_[_0xa5ae('0x1c')](_0x6635ef[_0xa5ae('0x16')]['include'],function(_0xd9b8e9){return{'model':db[_0xd9b8e9[_0xa5ae('0x1d')]],'as':_0xd9b8e9['as'],'attributes':_0xd9b8e9[_0xa5ae('0x19')],'include':_0xd9b8e9[_0xa5ae('0x1b')]?_[_0xa5ae('0x1c')](_0xd9b8e9['include'],function(_0x568fb0){return{'model':db[_0x568fb0['model']],'as':_0x568fb0['as'],'attributes':_0x568fb0[_0xa5ae('0x19')],'include':_0x568fb0[_0xa5ae('0x1b')]?_[_0xa5ae('0x1c')](_0x568fb0[_0xa5ae('0x1b')],function(_0x30abf4){return{'model':db[_0x30abf4[_0xa5ae('0x1d')]],'as':_0x30abf4['as'],'attributes':_0x30abf4[_0xa5ae('0x19')]};}):[]};}):[]};}):[]:[]})[_0xa5ae('0xa')](function(_0x2fc64e){logger[_0xa5ae('0xb')](_0xa5ae('0x1e'),_0x6635ef);logger[_0xa5ae('0xd')]('GetServicenowAccount',_0x6635ef,JSON[_0xa5ae('0x10')](_0x2fc64e));_0x47f2c0(_0x2fc64e);})[_0xa5ae('0x14')](function(_0x231a79){logger[_0xa5ae('0x11')](_0xa5ae('0x1e'),_0x231a79[_0xa5ae('0x12')],_0x6635ef);_0x45b99f(_0x3b1a42[_0xa5ae('0x11')](0x1f4,_0x231a79['message']));});});};exports[_0xa5ae('0x1f')]=function(_0x1e49ea){var _0x100781=this;return new Promise(function(_0x345790,_0x3e05c5){return db[_0xa5ae('0x15')][_0xa5ae('0x20')]({'raw':_0x1e49ea[_0xa5ae('0x16')]?_0x1e49ea[_0xa5ae('0x16')][_0xa5ae('0x17')]===undefined?!![]:![]:!![],'where':_0x1e49ea[_0xa5ae('0x16')]?_0x1e49ea[_0xa5ae('0x16')][_0xa5ae('0x18')]||null:null,'attributes':_0x1e49ea[_0xa5ae('0x16')]?_0x1e49ea[_0xa5ae('0x16')][_0xa5ae('0x19')]||null:null,'include':_0x1e49ea[_0xa5ae('0x16')]?_0x1e49ea[_0xa5ae('0x16')][_0xa5ae('0x1b')]?_[_0xa5ae('0x1c')](_0x1e49ea[_0xa5ae('0x16')][_0xa5ae('0x1b')],function(_0xf0626e){return{'model':db[_0xf0626e['model']],'as':_0xf0626e['as'],'attributes':_0xf0626e[_0xa5ae('0x19')],'include':_0xf0626e['include']?_[_0xa5ae('0x1c')](_0xf0626e['include'],function(_0x3a47c4){return{'model':db[_0x3a47c4[_0xa5ae('0x1d')]],'as':_0x3a47c4['as'],'attributes':_0x3a47c4['attributes'],'include':_0x3a47c4[_0xa5ae('0x1b')]?_['map'](_0x3a47c4[_0xa5ae('0x1b')],function(_0x56c4bb){return{'model':db[_0x56c4bb[_0xa5ae('0x1d')]],'as':_0x56c4bb['as'],'attributes':_0x56c4bb['attributes']};}):[]};}):[]};}):[]:[]})[_0xa5ae('0xa')](function(_0x388e62){logger[_0xa5ae('0xb')](_0xa5ae('0x1f'),_0x1e49ea);logger[_0xa5ae('0xd')](_0xa5ae('0x1f'),_0x1e49ea,JSON[_0xa5ae('0x10')](_0x388e62));_0x345790(_0x388e62);})[_0xa5ae('0x14')](function(_0x2d8529){logger['error'](_0xa5ae('0x1f'),_0x2d8529[_0xa5ae('0x12')],_0x1e49ea);_0x3e05c5(_0x100781['error'](0x1f4,_0x2d8529['message']));});});};