0335cad8a7eb985651e9da7e3b2888b4845229b5
[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 _0xb0ff=['randomstring','../../config/utils','rpc','../../config/environment','http','request','then','info','ServicenowAccount,\x20%s,\x20%s','request\x20sent','debug','ServicenowAccount,\x20%s,\x20%s,\x20%s','error','code','message','findAll','options','raw','where','attributes','include','map','model','GetServicenowAccount','stringify','catch','ShowServicenowAccount','find','lodash','moment','bluebird'];(function(_0x1dda84,_0x3ae4cb){var _0x3cb62d=function(_0x42f525){while(--_0x42f525){_0x1dda84['push'](_0x1dda84['shift']());}};_0x3cb62d(++_0x3ae4cb);}(_0xb0ff,0xd6));var _0xfb0f=function(_0x2682fe,_0x4fe106){_0x2682fe=_0x2682fe-0x0;var _0x2dc372=_0xb0ff[_0x2682fe];return _0x2dc372;};'use strict';var _=require(_0xfb0f('0x0'));var util=require('util');var moment=require(_0xfb0f('0x1'));var BPromise=require(_0xfb0f('0x2'));var rs=require(_0xfb0f('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xfb0f('0x4'));var logger=require('../../config/logger')(_0xfb0f('0x5'));var config=require(_0xfb0f('0x6'));var jayson=require('jayson/promise');var client=jayson['client'][_0xfb0f('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x471c68,_0x8c0254,_0x44eea3){return new BPromise(function(_0x1c9425,_0x206aed){return client[_0xfb0f('0x8')](_0x471c68,_0x44eea3)[_0xfb0f('0x9')](function(_0x1b5d5e){logger[_0xfb0f('0xa')](_0xfb0f('0xb'),_0x8c0254,_0xfb0f('0xc'));logger[_0xfb0f('0xd')](_0xfb0f('0xe'),_0x8c0254,_0xfb0f('0xc'),JSON['stringify'](_0x1b5d5e));if(_0x1b5d5e[_0xfb0f('0xf')]){if(_0x1b5d5e[_0xfb0f('0xf')][_0xfb0f('0x10')]===0x1f4){logger['error'](_0xfb0f('0xb'),_0x8c0254,_0x1b5d5e[_0xfb0f('0xf')][_0xfb0f('0x11')]);return _0x206aed(_0x1b5d5e[_0xfb0f('0xf')][_0xfb0f('0x11')]);}logger[_0xfb0f('0xf')]('ServicenowAccount,\x20%s,\x20%s',_0x8c0254,_0x1b5d5e[_0xfb0f('0xf')][_0xfb0f('0x11')]);return _0x1c9425(_0x1b5d5e['error'][_0xfb0f('0x11')]);}else{logger[_0xfb0f('0xa')]('ServicenowAccount,\x20%s,\x20%s',_0x8c0254,_0xfb0f('0xc'));_0x1c9425(_0x1b5d5e['result'][_0xfb0f('0x11')]);}})['catch'](function(_0x37c412){logger[_0xfb0f('0xf')](_0xfb0f('0xb'),_0x8c0254,_0x37c412);_0x206aed(_0x37c412);});});}exports['GetServicenowAccount']=function(_0x170c0d){var _0x125a82=this;return new Promise(function(_0x16672e,_0x217647){return db['ServicenowAccount'][_0xfb0f('0x12')]({'raw':_0x170c0d[_0xfb0f('0x13')]?_0x170c0d[_0xfb0f('0x13')][_0xfb0f('0x14')]===undefined?!![]:![]:!![],'where':_0x170c0d[_0xfb0f('0x13')]?_0x170c0d[_0xfb0f('0x13')][_0xfb0f('0x15')]||null:null,'attributes':_0x170c0d[_0xfb0f('0x13')]?_0x170c0d[_0xfb0f('0x13')][_0xfb0f('0x16')]||null:null,'limit':_0x170c0d[_0xfb0f('0x13')]?_0x170c0d['options']['limit']||null:null,'include':_0x170c0d['options']?_0x170c0d[_0xfb0f('0x13')][_0xfb0f('0x17')]?_[_0xfb0f('0x18')](_0x170c0d['options']['include'],function(_0x3f7008){return{'model':db[_0x3f7008[_0xfb0f('0x19')]],'as':_0x3f7008['as'],'attributes':_0x3f7008['attributes'],'include':_0x3f7008[_0xfb0f('0x17')]?_[_0xfb0f('0x18')](_0x3f7008[_0xfb0f('0x17')],function(_0x3a8fc5){return{'model':db[_0x3a8fc5['model']],'as':_0x3a8fc5['as'],'attributes':_0x3a8fc5[_0xfb0f('0x16')],'include':_0x3a8fc5['include']?_[_0xfb0f('0x18')](_0x3a8fc5[_0xfb0f('0x17')],function(_0x396937){return{'model':db[_0x396937[_0xfb0f('0x19')]],'as':_0x396937['as'],'attributes':_0x396937[_0xfb0f('0x16')]};}):[]};}):[]};}):[]:[]})[_0xfb0f('0x9')](function(_0x1813e2){logger[_0xfb0f('0xa')]('GetServicenowAccount',_0x170c0d);logger['debug'](_0xfb0f('0x1a'),_0x170c0d,JSON[_0xfb0f('0x1b')](_0x1813e2));_0x16672e(_0x1813e2);})[_0xfb0f('0x1c')](function(_0x31b7fe){logger['error'](_0xfb0f('0x1a'),_0x31b7fe[_0xfb0f('0x11')],_0x170c0d);_0x217647(_0x125a82[_0xfb0f('0xf')](0x1f4,_0x31b7fe[_0xfb0f('0x11')]));});});};exports[_0xfb0f('0x1d')]=function(_0xbcc5cc){var _0x2cc57e=this;return new Promise(function(_0x360143,_0x293916){return db['ServicenowAccount'][_0xfb0f('0x1e')]({'raw':_0xbcc5cc[_0xfb0f('0x13')]?_0xbcc5cc['options']['raw']===undefined?!![]:![]:!![],'where':_0xbcc5cc['options']?_0xbcc5cc[_0xfb0f('0x13')]['where']||null:null,'attributes':_0xbcc5cc[_0xfb0f('0x13')]?_0xbcc5cc[_0xfb0f('0x13')]['attributes']||null:null,'include':_0xbcc5cc['options']?_0xbcc5cc[_0xfb0f('0x13')]['include']?_[_0xfb0f('0x18')](_0xbcc5cc[_0xfb0f('0x13')][_0xfb0f('0x17')],function(_0x2fb21c){return{'model':db[_0x2fb21c[_0xfb0f('0x19')]],'as':_0x2fb21c['as'],'attributes':_0x2fb21c['attributes'],'include':_0x2fb21c[_0xfb0f('0x17')]?_['map'](_0x2fb21c['include'],function(_0x253eac){return{'model':db[_0x253eac['model']],'as':_0x253eac['as'],'attributes':_0x253eac[_0xfb0f('0x16')],'include':_0x253eac['include']?_[_0xfb0f('0x18')](_0x253eac[_0xfb0f('0x17')],function(_0x1fb000){return{'model':db[_0x1fb000[_0xfb0f('0x19')]],'as':_0x1fb000['as'],'attributes':_0x1fb000[_0xfb0f('0x16')]};}):[]};}):[]};}):[]:[]})[_0xfb0f('0x9')](function(_0x456648){logger['info']('ShowServicenowAccount',_0xbcc5cc);logger[_0xfb0f('0xd')](_0xfb0f('0x1d'),_0xbcc5cc,JSON[_0xfb0f('0x1b')](_0x456648));_0x360143(_0x456648);})[_0xfb0f('0x1c')](function(_0xa87fe9){logger[_0xfb0f('0xf')](_0xfb0f('0x1d'),_0xa87fe9[_0xfb0f('0x11')],_0xbcc5cc);_0x293916(_0x2cc57e[_0xfb0f('0xf')](0x1f4,_0xa87fe9['message']));});});};