945df6a0225f2b1e238cf4bb7edb71805e3803f5
[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 _0x223b=['attributes','GetServicenowAccount','stringify','ShowServicenowAccount','find','raw','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','http','request','then','info','ServicenowAccount,\x20%s,\x20%s','request\x20sent','debug','ServicenowAccount,\x20%s,\x20%s,\x20%s','error','message','result','catch','findAll','options','where','limit','include','map','model'];(function(_0x34eabc,_0x51d411){var _0x43e72f=function(_0x5619e8){while(--_0x5619e8){_0x34eabc['push'](_0x34eabc['shift']());}};_0x43e72f(++_0x51d411);}(_0x223b,0x10e));var _0xb223=function(_0x1329ae,_0x28f239){_0x1329ae=_0x1329ae-0x0;var _0x1129cb=_0x223b[_0x1329ae];return _0x1129cb;};'use strict';var _=require(_0xb223('0x0'));var util=require('util');var moment=require(_0xb223('0x1'));var BPromise=require('bluebird');var rs=require(_0xb223('0x2'));var fs=require('fs');var Redis=require(_0xb223('0x3'));var db=require(_0xb223('0x4'))['db'];var utils=require(_0xb223('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0xb223('0x6'));var jayson=require(_0xb223('0x7'));var client=jayson['client'][_0xb223('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x2833ae,_0x1c2c06,_0x208e27){return new BPromise(function(_0x2ee7e4,_0x2f257c){return client[_0xb223('0x9')](_0x2833ae,_0x208e27)[_0xb223('0xa')](function(_0x1760a8){logger[_0xb223('0xb')](_0xb223('0xc'),_0x1c2c06,_0xb223('0xd'));logger[_0xb223('0xe')](_0xb223('0xf'),_0x1c2c06,_0xb223('0xd'),JSON['stringify'](_0x1760a8));if(_0x1760a8[_0xb223('0x10')]){if(_0x1760a8['error']['code']===0x1f4){logger[_0xb223('0x10')](_0xb223('0xc'),_0x1c2c06,_0x1760a8[_0xb223('0x10')]['message']);return _0x2f257c(_0x1760a8[_0xb223('0x10')]['message']);}logger[_0xb223('0x10')](_0xb223('0xc'),_0x1c2c06,_0x1760a8[_0xb223('0x10')][_0xb223('0x11')]);return _0x2ee7e4(_0x1760a8[_0xb223('0x10')][_0xb223('0x11')]);}else{logger['info']('ServicenowAccount,\x20%s,\x20%s',_0x1c2c06,_0xb223('0xd'));_0x2ee7e4(_0x1760a8[_0xb223('0x12')]['message']);}})[_0xb223('0x13')](function(_0x1e3fe7){logger[_0xb223('0x10')](_0xb223('0xc'),_0x1c2c06,_0x1e3fe7);_0x2f257c(_0x1e3fe7);});});}exports['GetServicenowAccount']=function(_0x2d8f00){var _0x1a632b=this;return new Promise(function(_0x6de2f6,_0x1c3b37){return db['ServicenowAccount'][_0xb223('0x14')]({'raw':_0x2d8f00['options']?_0x2d8f00[_0xb223('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x2d8f00[_0xb223('0x15')]?_0x2d8f00[_0xb223('0x15')][_0xb223('0x16')]||null:null,'attributes':_0x2d8f00[_0xb223('0x15')]?_0x2d8f00[_0xb223('0x15')]['attributes']||null:null,'limit':_0x2d8f00[_0xb223('0x15')]?_0x2d8f00[_0xb223('0x15')][_0xb223('0x17')]||null:null,'include':_0x2d8f00[_0xb223('0x15')]?_0x2d8f00[_0xb223('0x15')][_0xb223('0x18')]?_[_0xb223('0x19')](_0x2d8f00[_0xb223('0x15')][_0xb223('0x18')],function(_0x15cd17){return{'model':db[_0x15cd17[_0xb223('0x1a')]],'as':_0x15cd17['as'],'attributes':_0x15cd17['attributes'],'include':_0x15cd17['include']?_[_0xb223('0x19')](_0x15cd17[_0xb223('0x18')],function(_0x5a537e){return{'model':db[_0x5a537e[_0xb223('0x1a')]],'as':_0x5a537e['as'],'attributes':_0x5a537e[_0xb223('0x1b')],'include':_0x5a537e[_0xb223('0x18')]?_['map'](_0x5a537e[_0xb223('0x18')],function(_0x345006){return{'model':db[_0x345006[_0xb223('0x1a')]],'as':_0x345006['as'],'attributes':_0x345006[_0xb223('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xb223('0xa')](function(_0x2db3ab){logger[_0xb223('0xb')](_0xb223('0x1c'),_0x2d8f00);logger[_0xb223('0xe')]('GetServicenowAccount',_0x2d8f00,JSON[_0xb223('0x1d')](_0x2db3ab));_0x6de2f6(_0x2db3ab);})[_0xb223('0x13')](function(_0x2daa7f){logger[_0xb223('0x10')](_0xb223('0x1c'),_0x2daa7f['message'],_0x2d8f00);_0x1c3b37(_0x1a632b['error'](0x1f4,_0x2daa7f['message']));});});};exports[_0xb223('0x1e')]=function(_0x2e81b0){var _0x57a42a=this;return new Promise(function(_0x2fce81,_0x268940){return db['ServicenowAccount'][_0xb223('0x1f')]({'raw':_0x2e81b0[_0xb223('0x15')]?_0x2e81b0[_0xb223('0x15')][_0xb223('0x20')]===undefined?!![]:![]:!![],'where':_0x2e81b0[_0xb223('0x15')]?_0x2e81b0[_0xb223('0x15')][_0xb223('0x16')]||null:null,'attributes':_0x2e81b0[_0xb223('0x15')]?_0x2e81b0[_0xb223('0x15')]['attributes']||null:null,'include':_0x2e81b0[_0xb223('0x15')]?_0x2e81b0[_0xb223('0x15')][_0xb223('0x18')]?_[_0xb223('0x19')](_0x2e81b0[_0xb223('0x15')]['include'],function(_0x3c149c){return{'model':db[_0x3c149c[_0xb223('0x1a')]],'as':_0x3c149c['as'],'attributes':_0x3c149c['attributes'],'include':_0x3c149c[_0xb223('0x18')]?_[_0xb223('0x19')](_0x3c149c[_0xb223('0x18')],function(_0x49adec){return{'model':db[_0x49adec[_0xb223('0x1a')]],'as':_0x49adec['as'],'attributes':_0x49adec[_0xb223('0x1b')],'include':_0x49adec[_0xb223('0x18')]?_[_0xb223('0x19')](_0x49adec[_0xb223('0x18')],function(_0x39469c){return{'model':db[_0x39469c['model']],'as':_0x39469c['as'],'attributes':_0x39469c[_0xb223('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xb223('0xa')](function(_0x191776){logger[_0xb223('0xb')](_0xb223('0x1e'),_0x2e81b0);logger[_0xb223('0xe')](_0xb223('0x1e'),_0x2e81b0,JSON['stringify'](_0x191776));_0x2fce81(_0x191776);})[_0xb223('0x13')](function(_0x254995){logger['error']('ShowServicenowAccount',_0x254995[_0xb223('0x11')],_0x2e81b0);_0x268940(_0x57a42a[_0xb223('0x10')](0x1f4,_0x254995['message']));});});};