Built motion from commit (unavailable).|2.5.31
[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 _0xf10e=['moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','request','then','info','request\x20sent','debug','stringify','error','ServicenowAccount,\x20%s,\x20%s','message','catch','findAll','options','where','attributes','limit','include','map','model','GetServicenowAccount','ShowServicenowAccount','ServicenowAccount','find','raw','lodash'];(function(_0x12e75f,_0xb261e8){var _0x10f606=function(_0x33e4d3){while(--_0x33e4d3){_0x12e75f['push'](_0x12e75f['shift']());}};_0x10f606(++_0xb261e8);}(_0xf10e,0x11f));var _0xef10=function(_0x411017,_0x4a8117){_0x411017=_0x411017-0x0;var _0x2adeea=_0xf10e[_0x411017];return _0x2adeea;};'use strict';var _=require(_0xef10('0x0'));var util=require('util');var moment=require(_0xef10('0x1'));var BPromise=require('bluebird');var rs=require(_0xef10('0x2'));var fs=require('fs');var Redis=require(_0xef10('0x3'));var db=require(_0xef10('0x4'))['db'];var utils=require(_0xef10('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0xef10('0x6'));var jayson=require(_0xef10('0x7'));var client=jayson[_0xef10('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x4d6f9b,_0x3178d0,_0x54b8ee){return new BPromise(function(_0x1477e4,_0x52582e){return client[_0xef10('0x9')](_0x4d6f9b,_0x54b8ee)[_0xef10('0xa')](function(_0xf0cb8e){logger[_0xef10('0xb')]('ServicenowAccount,\x20%s,\x20%s',_0x3178d0,_0xef10('0xc'));logger[_0xef10('0xd')]('ServicenowAccount,\x20%s,\x20%s,\x20%s',_0x3178d0,_0xef10('0xc'),JSON[_0xef10('0xe')](_0xf0cb8e));if(_0xf0cb8e[_0xef10('0xf')]){if(_0xf0cb8e[_0xef10('0xf')]['code']===0x1f4){logger['error'](_0xef10('0x10'),_0x3178d0,_0xf0cb8e[_0xef10('0xf')][_0xef10('0x11')]);return _0x52582e(_0xf0cb8e['error']['message']);}logger[_0xef10('0xf')](_0xef10('0x10'),_0x3178d0,_0xf0cb8e[_0xef10('0xf')][_0xef10('0x11')]);return _0x1477e4(_0xf0cb8e[_0xef10('0xf')][_0xef10('0x11')]);}else{logger['info'](_0xef10('0x10'),_0x3178d0,_0xef10('0xc'));_0x1477e4(_0xf0cb8e['result'][_0xef10('0x11')]);}})[_0xef10('0x12')](function(_0x1088ae){logger['error'](_0xef10('0x10'),_0x3178d0,_0x1088ae);_0x52582e(_0x1088ae);});});}exports['GetServicenowAccount']=function(_0x57fb94){var _0x9ad9e8=this;return new Promise(function(_0x2bf840,_0xd872b1){return db['ServicenowAccount'][_0xef10('0x13')]({'raw':_0x57fb94['options']?_0x57fb94[_0xef10('0x14')]['raw']===undefined?!![]:![]:!![],'where':_0x57fb94[_0xef10('0x14')]?_0x57fb94[_0xef10('0x14')][_0xef10('0x15')]||null:null,'attributes':_0x57fb94[_0xef10('0x14')]?_0x57fb94['options'][_0xef10('0x16')]||null:null,'limit':_0x57fb94[_0xef10('0x14')]?_0x57fb94[_0xef10('0x14')][_0xef10('0x17')]||null:null,'include':_0x57fb94[_0xef10('0x14')]?_0x57fb94[_0xef10('0x14')][_0xef10('0x18')]?_[_0xef10('0x19')](_0x57fb94['options'][_0xef10('0x18')],function(_0x54c0d6){return{'model':db[_0x54c0d6[_0xef10('0x1a')]],'as':_0x54c0d6['as'],'attributes':_0x54c0d6[_0xef10('0x16')],'include':_0x54c0d6[_0xef10('0x18')]?_[_0xef10('0x19')](_0x54c0d6[_0xef10('0x18')],function(_0x5f023c){return{'model':db[_0x5f023c[_0xef10('0x1a')]],'as':_0x5f023c['as'],'attributes':_0x5f023c[_0xef10('0x16')],'include':_0x5f023c['include']?_[_0xef10('0x19')](_0x5f023c[_0xef10('0x18')],function(_0x374220){return{'model':db[_0x374220[_0xef10('0x1a')]],'as':_0x374220['as'],'attributes':_0x374220[_0xef10('0x16')]};}):[]};}):[]};}):[]:[]})[_0xef10('0xa')](function(_0x5c7bf5){logger[_0xef10('0xb')](_0xef10('0x1b'),_0x57fb94);logger[_0xef10('0xd')](_0xef10('0x1b'),_0x57fb94,JSON[_0xef10('0xe')](_0x5c7bf5));_0x2bf840(_0x5c7bf5);})[_0xef10('0x12')](function(_0x4d271d){logger['error'](_0xef10('0x1b'),_0x4d271d['message'],_0x57fb94);_0xd872b1(_0x9ad9e8['error'](0x1f4,_0x4d271d[_0xef10('0x11')]));});});};exports[_0xef10('0x1c')]=function(_0x259745){var _0x8c2570=this;return new Promise(function(_0xd006cc,_0x377509){return db[_0xef10('0x1d')][_0xef10('0x1e')]({'raw':_0x259745[_0xef10('0x14')]?_0x259745[_0xef10('0x14')][_0xef10('0x1f')]===undefined?!![]:![]:!![],'where':_0x259745['options']?_0x259745[_0xef10('0x14')][_0xef10('0x15')]||null:null,'attributes':_0x259745[_0xef10('0x14')]?_0x259745['options']['attributes']||null:null,'include':_0x259745['options']?_0x259745[_0xef10('0x14')][_0xef10('0x18')]?_['map'](_0x259745[_0xef10('0x14')][_0xef10('0x18')],function(_0x5597da){return{'model':db[_0x5597da[_0xef10('0x1a')]],'as':_0x5597da['as'],'attributes':_0x5597da[_0xef10('0x16')],'include':_0x5597da[_0xef10('0x18')]?_['map'](_0x5597da[_0xef10('0x18')],function(_0x5733c2){return{'model':db[_0x5733c2['model']],'as':_0x5733c2['as'],'attributes':_0x5733c2[_0xef10('0x16')],'include':_0x5733c2[_0xef10('0x18')]?_[_0xef10('0x19')](_0x5733c2[_0xef10('0x18')],function(_0xaf89a){return{'model':db[_0xaf89a['model']],'as':_0xaf89a['as'],'attributes':_0xaf89a['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x20bc39){logger['info']('ShowServicenowAccount',_0x259745);logger['debug'](_0xef10('0x1c'),_0x259745,JSON[_0xef10('0xe')](_0x20bc39));_0xd006cc(_0x20bc39);})[_0xef10('0x12')](function(_0xf0b36){logger[_0xef10('0xf')](_0xef10('0x1c'),_0xf0b36['message'],_0x259745);_0x377509(_0x8c2570['error'](0x1f4,_0xf0b36['message']));});});};