4e97bfefd773e80c795317446fc290aa1739d6f0
[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 _0xbdd1=['result','catch','ServicenowAccount','findAll','options','raw','where','attributes','limit','map','model','include','GetServicenowAccount','debug','ShowServicenowAccount','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','jayson/promise','client','http','then','ServicenowAccount,\x20%s,\x20%s','request\x20sent','ServicenowAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','info'];(function(_0x427567,_0x56dc6){var _0x50c183=function(_0xdc7eca){while(--_0xdc7eca){_0x427567['push'](_0x427567['shift']());}};_0x50c183(++_0x56dc6);}(_0xbdd1,0x1dd));var _0x1bdd=function(_0x1415ef,_0x5c219e){_0x1415ef=_0x1415ef-0x0;var _0x234acc=_0xbdd1[_0x1415ef];return _0x234acc;};'use strict';var _=require(_0x1bdd('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x1bdd('0x1'));var rs=require(_0x1bdd('0x2'));var fs=require('fs');var Redis=require(_0x1bdd('0x3'));var db=require(_0x1bdd('0x4'))['db'];var utils=require(_0x1bdd('0x5'));var logger=require('../../config/logger')(_0x1bdd('0x6'));var config=require('../../config/environment');var jayson=require(_0x1bdd('0x7'));var client=jayson[_0x1bdd('0x8')][_0x1bdd('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3a754a,_0x5e526d,_0x2b1bdd){return new BPromise(function(_0x1b7bf4,_0x1b9869){return client['request'](_0x3a754a,_0x2b1bdd)[_0x1bdd('0xa')](function(_0x446d7f){logger['info'](_0x1bdd('0xb'),_0x5e526d,_0x1bdd('0xc'));logger['debug'](_0x1bdd('0xd'),_0x5e526d,_0x1bdd('0xc'),JSON[_0x1bdd('0xe')](_0x446d7f));if(_0x446d7f[_0x1bdd('0xf')]){if(_0x446d7f[_0x1bdd('0xf')]['code']===0x1f4){logger['error'](_0x1bdd('0xb'),_0x5e526d,_0x446d7f[_0x1bdd('0xf')][_0x1bdd('0x10')]);return _0x1b9869(_0x446d7f['error'][_0x1bdd('0x10')]);}logger[_0x1bdd('0xf')](_0x1bdd('0xb'),_0x5e526d,_0x446d7f[_0x1bdd('0xf')][_0x1bdd('0x10')]);return _0x1b7bf4(_0x446d7f[_0x1bdd('0xf')][_0x1bdd('0x10')]);}else{logger[_0x1bdd('0x11')](_0x1bdd('0xb'),_0x5e526d,_0x1bdd('0xc'));_0x1b7bf4(_0x446d7f[_0x1bdd('0x12')]['message']);}})[_0x1bdd('0x13')](function(_0x30d0a7){logger[_0x1bdd('0xf')](_0x1bdd('0xb'),_0x5e526d,_0x30d0a7);_0x1b9869(_0x30d0a7);});});}exports['GetServicenowAccount']=function(_0x30ac19){var _0x598c7d=this;return new Promise(function(_0xa06721,_0x5c4587){return db[_0x1bdd('0x14')][_0x1bdd('0x15')]({'raw':_0x30ac19[_0x1bdd('0x16')]?_0x30ac19[_0x1bdd('0x16')][_0x1bdd('0x17')]===undefined?!![]:![]:!![],'where':_0x30ac19[_0x1bdd('0x16')]?_0x30ac19[_0x1bdd('0x16')][_0x1bdd('0x18')]||null:null,'attributes':_0x30ac19['options']?_0x30ac19[_0x1bdd('0x16')][_0x1bdd('0x19')]||null:null,'limit':_0x30ac19[_0x1bdd('0x16')]?_0x30ac19['options'][_0x1bdd('0x1a')]||null:null,'include':_0x30ac19[_0x1bdd('0x16')]?_0x30ac19[_0x1bdd('0x16')]['include']?_[_0x1bdd('0x1b')](_0x30ac19['options']['include'],function(_0x4e6a36){return{'model':db[_0x4e6a36[_0x1bdd('0x1c')]],'as':_0x4e6a36['as'],'attributes':_0x4e6a36[_0x1bdd('0x19')],'include':_0x4e6a36[_0x1bdd('0x1d')]?_['map'](_0x4e6a36['include'],function(_0x533181){return{'model':db[_0x533181['model']],'as':_0x533181['as'],'attributes':_0x533181[_0x1bdd('0x19')],'include':_0x533181[_0x1bdd('0x1d')]?_[_0x1bdd('0x1b')](_0x533181[_0x1bdd('0x1d')],function(_0x39b34b){return{'model':db[_0x39b34b[_0x1bdd('0x1c')]],'as':_0x39b34b['as'],'attributes':_0x39b34b[_0x1bdd('0x19')]};}):[]};}):[]};}):[]:[]})[_0x1bdd('0xa')](function(_0x1b09fd){logger['info'](_0x1bdd('0x1e'),_0x30ac19);logger[_0x1bdd('0x1f')](_0x1bdd('0x1e'),_0x30ac19,JSON[_0x1bdd('0xe')](_0x1b09fd));_0xa06721(_0x1b09fd);})[_0x1bdd('0x13')](function(_0x373f95){logger[_0x1bdd('0xf')](_0x1bdd('0x1e'),_0x373f95[_0x1bdd('0x10')],_0x30ac19);_0x5c4587(_0x598c7d['error'](0x1f4,_0x373f95['message']));});});};exports[_0x1bdd('0x20')]=function(_0xf7c491){var _0x5e9de0=this;return new Promise(function(_0x1fa33a,_0x3df092){return db[_0x1bdd('0x14')]['find']({'raw':_0xf7c491[_0x1bdd('0x16')]?_0xf7c491['options'][_0x1bdd('0x17')]===undefined?!![]:![]:!![],'where':_0xf7c491['options']?_0xf7c491[_0x1bdd('0x16')][_0x1bdd('0x18')]||null:null,'attributes':_0xf7c491['options']?_0xf7c491[_0x1bdd('0x16')]['attributes']||null:null,'include':_0xf7c491[_0x1bdd('0x16')]?_0xf7c491[_0x1bdd('0x16')][_0x1bdd('0x1d')]?_[_0x1bdd('0x1b')](_0xf7c491[_0x1bdd('0x16')][_0x1bdd('0x1d')],function(_0x24d955){return{'model':db[_0x24d955[_0x1bdd('0x1c')]],'as':_0x24d955['as'],'attributes':_0x24d955[_0x1bdd('0x19')],'include':_0x24d955[_0x1bdd('0x1d')]?_[_0x1bdd('0x1b')](_0x24d955[_0x1bdd('0x1d')],function(_0x50d52){return{'model':db[_0x50d52[_0x1bdd('0x1c')]],'as':_0x50d52['as'],'attributes':_0x50d52['attributes'],'include':_0x50d52[_0x1bdd('0x1d')]?_[_0x1bdd('0x1b')](_0x50d52[_0x1bdd('0x1d')],function(_0x536b51){return{'model':db[_0x536b51['model']],'as':_0x536b51['as'],'attributes':_0x536b51['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x1ed9a6){logger['info'](_0x1bdd('0x20'),_0xf7c491);logger[_0x1bdd('0x1f')](_0x1bdd('0x20'),_0xf7c491,JSON['stringify'](_0x1ed9a6));_0x1fa33a(_0x1ed9a6);})[_0x1bdd('0x13')](function(_0xfee4f5){logger[_0x1bdd('0xf')]('ShowServicenowAccount',_0xfee4f5['message'],_0xf7c491);_0x3df092(_0x5e9de0['error'](0x1f4,_0xfee4f5[_0x1bdd('0x10')]));});});};