b68ebe4895ffe7efe9e4c138eb5e9ff62d6056d2
[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 _0xf7ff=['model','attributes','ShowServicenowAccount','randomstring','../../config/utils','../../config/logger','client','http','request','ServicenowAccount,\x20%s,\x20%s','request\x20sent','debug','ServicenowAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','GetServicenowAccount','findAll','options','raw','where','limit','include','map'];(function(_0xc753c8,_0x5627ff){var _0xd02f5c=function(_0xfb552e){while(--_0xfb552e){_0xc753c8['push'](_0xc753c8['shift']());}};_0xd02f5c(++_0x5627ff);}(_0xf7ff,0xc7));var _0xff7f=function(_0x4306e3,_0x3308a8){_0x4306e3=_0x4306e3-0x0;var _0x20c822=_0xf7ff[_0x4306e3];return _0x20c822;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xff7f('0x0'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xff7f('0x1'));var logger=require(_0xff7f('0x2'))('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xff7f('0x3')][_0xff7f('0x4')]({'port':0x232a});function respondWithRpcPromise(_0x36386a,_0x1c43a0,_0x2025b7){return new BPromise(function(_0x5efe5a,_0xf52fc6){return client[_0xff7f('0x5')](_0x36386a,_0x2025b7)['then'](function(_0x45a1cb){logger['info'](_0xff7f('0x6'),_0x1c43a0,_0xff7f('0x7'));logger[_0xff7f('0x8')](_0xff7f('0x9'),_0x1c43a0,_0xff7f('0x7'),JSON[_0xff7f('0xa')](_0x45a1cb));if(_0x45a1cb[_0xff7f('0xb')]){if(_0x45a1cb[_0xff7f('0xb')][_0xff7f('0xc')]===0x1f4){logger['error'](_0xff7f('0x6'),_0x1c43a0,_0x45a1cb['error'][_0xff7f('0xd')]);return _0xf52fc6(_0x45a1cb[_0xff7f('0xb')][_0xff7f('0xd')]);}logger[_0xff7f('0xb')](_0xff7f('0x6'),_0x1c43a0,_0x45a1cb[_0xff7f('0xb')][_0xff7f('0xd')]);return _0x5efe5a(_0x45a1cb[_0xff7f('0xb')][_0xff7f('0xd')]);}else{logger[_0xff7f('0xe')]('ServicenowAccount,\x20%s,\x20%s',_0x1c43a0,_0xff7f('0x7'));_0x5efe5a(_0x45a1cb[_0xff7f('0xf')][_0xff7f('0xd')]);}})[_0xff7f('0x10')](function(_0xc7f7b4){logger[_0xff7f('0xb')](_0xff7f('0x6'),_0x1c43a0,_0xc7f7b4);_0xf52fc6(_0xc7f7b4);});});}exports[_0xff7f('0x11')]=function(_0x4c7f5f){var _0x195ffc=this;return new Promise(function(_0x546ab8,_0x329b91){return db['ServicenowAccount'][_0xff7f('0x12')]({'raw':_0x4c7f5f[_0xff7f('0x13')]?_0x4c7f5f['options'][_0xff7f('0x14')]===undefined?!![]:![]:!![],'where':_0x4c7f5f['options']?_0x4c7f5f[_0xff7f('0x13')][_0xff7f('0x15')]||null:null,'attributes':_0x4c7f5f[_0xff7f('0x13')]?_0x4c7f5f[_0xff7f('0x13')]['attributes']||null:null,'limit':_0x4c7f5f[_0xff7f('0x13')]?_0x4c7f5f[_0xff7f('0x13')][_0xff7f('0x16')]||null:null,'include':_0x4c7f5f[_0xff7f('0x13')]?_0x4c7f5f['options'][_0xff7f('0x17')]?_[_0xff7f('0x18')](_0x4c7f5f[_0xff7f('0x13')][_0xff7f('0x17')],function(_0x348e82){return{'model':db[_0x348e82['model']],'as':_0x348e82['as'],'attributes':_0x348e82['attributes'],'include':_0x348e82[_0xff7f('0x17')]?_[_0xff7f('0x18')](_0x348e82['include'],function(_0x36aa35){return{'model':db[_0x36aa35[_0xff7f('0x19')]],'as':_0x36aa35['as'],'attributes':_0x36aa35[_0xff7f('0x1a')],'include':_0x36aa35[_0xff7f('0x17')]?_[_0xff7f('0x18')](_0x36aa35[_0xff7f('0x17')],function(_0x24e3d3){return{'model':db[_0x24e3d3['model']],'as':_0x24e3d3['as'],'attributes':_0x24e3d3['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x2c3805){logger[_0xff7f('0xe')](_0xff7f('0x11'),_0x4c7f5f);logger[_0xff7f('0x8')]('GetServicenowAccount',_0x4c7f5f,JSON[_0xff7f('0xa')](_0x2c3805));_0x546ab8(_0x2c3805);})['catch'](function(_0x53f55b){logger[_0xff7f('0xb')](_0xff7f('0x11'),_0x53f55b['message'],_0x4c7f5f);_0x329b91(_0x195ffc[_0xff7f('0xb')](0x1f4,_0x53f55b[_0xff7f('0xd')]));});});};exports[_0xff7f('0x1b')]=function(_0x18e6b4){var _0xa0d1a4=this;return new Promise(function(_0x4dbacd,_0x5678dc){return db['ServicenowAccount']['find']({'raw':_0x18e6b4[_0xff7f('0x13')]?_0x18e6b4[_0xff7f('0x13')]['raw']===undefined?!![]:![]:!![],'where':_0x18e6b4['options']?_0x18e6b4['options']['where']||null:null,'attributes':_0x18e6b4[_0xff7f('0x13')]?_0x18e6b4[_0xff7f('0x13')][_0xff7f('0x1a')]||null:null,'include':_0x18e6b4[_0xff7f('0x13')]?_0x18e6b4[_0xff7f('0x13')][_0xff7f('0x17')]?_[_0xff7f('0x18')](_0x18e6b4[_0xff7f('0x13')][_0xff7f('0x17')],function(_0x26330e){return{'model':db[_0x26330e['model']],'as':_0x26330e['as'],'attributes':_0x26330e[_0xff7f('0x1a')],'include':_0x26330e['include']?_['map'](_0x26330e['include'],function(_0xc31702){return{'model':db[_0xc31702[_0xff7f('0x19')]],'as':_0xc31702['as'],'attributes':_0xc31702[_0xff7f('0x1a')],'include':_0xc31702['include']?_[_0xff7f('0x18')](_0xc31702['include'],function(_0x505bbe){return{'model':db[_0x505bbe[_0xff7f('0x19')]],'as':_0x505bbe['as'],'attributes':_0x505bbe[_0xff7f('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1663d9){logger['info']('ShowServicenowAccount',_0x18e6b4);logger[_0xff7f('0x8')](_0xff7f('0x1b'),_0x18e6b4,JSON[_0xff7f('0xa')](_0x1663d9));_0x4dbacd(_0x1663d9);})[_0xff7f('0x10')](function(_0x39c3e5){logger[_0xff7f('0xb')](_0xff7f('0x1b'),_0x39c3e5[_0xff7f('0xd')],_0x18e6b4);_0x5678dc(_0xa0d1a4['error'](0x1f4,_0x39c3e5['message']));});});};