47a29fc65950cc48b91c7d217daf97b8775b290c
[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 _0x7aee=['ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','request','ServicenowAccount,\x20%s,\x20%s','request\x20sent','stringify','error','message','info','catch','GetServicenowAccount','ServicenowAccount','options','raw','where','limit','include','map','attributes','model','debug','ShowServicenowAccount','find','then','util','moment','bluebird','randomstring'];(function(_0x3fc48e,_0x59ca65){var _0x472328=function(_0x3ef99d){while(--_0x3ef99d){_0x3fc48e['push'](_0x3fc48e['shift']());}};_0x472328(++_0x59ca65);}(_0x7aee,0x9c));var _0xe7ae=function(_0x5e4c0a,_0x34f000){_0x5e4c0a=_0x5e4c0a-0x0;var _0x517c78=_0x7aee[_0x5e4c0a];return _0x517c78;};'use strict';var _=require('lodash');var util=require(_0xe7ae('0x0'));var moment=require(_0xe7ae('0x1'));var BPromise=require(_0xe7ae('0x2'));var rs=require(_0xe7ae('0x3'));var fs=require('fs');var Redis=require(_0xe7ae('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xe7ae('0x5'));var logger=require(_0xe7ae('0x6'))('rpc');var config=require(_0xe7ae('0x7'));var jayson=require(_0xe7ae('0x8'));var client=jayson['client'][_0xe7ae('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x4f1f15,_0x91f4e4,_0x33c152){return new BPromise(function(_0x384cbc,_0x222e37){return client[_0xe7ae('0xa')](_0x4f1f15,_0x33c152)['then'](function(_0x1a4824){logger['info'](_0xe7ae('0xb'),_0x91f4e4,'request\x20sent');logger['debug']('ServicenowAccount,\x20%s,\x20%s,\x20%s',_0x91f4e4,_0xe7ae('0xc'),JSON[_0xe7ae('0xd')](_0x1a4824));if(_0x1a4824[_0xe7ae('0xe')]){if(_0x1a4824['error']['code']===0x1f4){logger[_0xe7ae('0xe')]('ServicenowAccount,\x20%s,\x20%s',_0x91f4e4,_0x1a4824['error'][_0xe7ae('0xf')]);return _0x222e37(_0x1a4824[_0xe7ae('0xe')][_0xe7ae('0xf')]);}logger[_0xe7ae('0xe')](_0xe7ae('0xb'),_0x91f4e4,_0x1a4824[_0xe7ae('0xe')][_0xe7ae('0xf')]);return _0x384cbc(_0x1a4824[_0xe7ae('0xe')][_0xe7ae('0xf')]);}else{logger[_0xe7ae('0x10')](_0xe7ae('0xb'),_0x91f4e4,_0xe7ae('0xc'));_0x384cbc(_0x1a4824['result'][_0xe7ae('0xf')]);}})[_0xe7ae('0x11')](function(_0x2617fb){logger['error'](_0xe7ae('0xb'),_0x91f4e4,_0x2617fb);_0x222e37(_0x2617fb);});});}exports[_0xe7ae('0x12')]=function(_0x13e814){var _0x115d50=this;return new Promise(function(_0x223acc,_0x836644){return db[_0xe7ae('0x13')]['findAll']({'raw':_0x13e814['options']?_0x13e814[_0xe7ae('0x14')][_0xe7ae('0x15')]===undefined?!![]:![]:!![],'where':_0x13e814['options']?_0x13e814[_0xe7ae('0x14')][_0xe7ae('0x16')]||null:null,'attributes':_0x13e814['options']?_0x13e814[_0xe7ae('0x14')]['attributes']||null:null,'limit':_0x13e814['options']?_0x13e814[_0xe7ae('0x14')][_0xe7ae('0x17')]||null:null,'include':_0x13e814[_0xe7ae('0x14')]?_0x13e814[_0xe7ae('0x14')][_0xe7ae('0x18')]?_[_0xe7ae('0x19')](_0x13e814['options']['include'],function(_0x5d544c){return{'model':db[_0x5d544c['model']],'as':_0x5d544c['as'],'attributes':_0x5d544c[_0xe7ae('0x1a')],'include':_0x5d544c[_0xe7ae('0x18')]?_[_0xe7ae('0x19')](_0x5d544c[_0xe7ae('0x18')],function(_0x10132b){return{'model':db[_0x10132b[_0xe7ae('0x1b')]],'as':_0x10132b['as'],'attributes':_0x10132b['attributes'],'include':_0x10132b[_0xe7ae('0x18')]?_[_0xe7ae('0x19')](_0x10132b[_0xe7ae('0x18')],function(_0x563ee1){return{'model':db[_0x563ee1[_0xe7ae('0x1b')]],'as':_0x563ee1['as'],'attributes':_0x563ee1['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0xf1b31){logger[_0xe7ae('0x10')]('GetServicenowAccount',_0x13e814);logger[_0xe7ae('0x1c')](_0xe7ae('0x12'),_0x13e814,JSON['stringify'](_0xf1b31));_0x223acc(_0xf1b31);})[_0xe7ae('0x11')](function(_0x486ac1){logger['error'](_0xe7ae('0x12'),_0x486ac1['message'],_0x13e814);_0x836644(_0x115d50[_0xe7ae('0xe')](0x1f4,_0x486ac1['message']));});});};exports[_0xe7ae('0x1d')]=function(_0x21577d){var _0x2fcc29=this;return new Promise(function(_0x4b8811,_0x402077){return db['ServicenowAccount'][_0xe7ae('0x1e')]({'raw':_0x21577d[_0xe7ae('0x14')]?_0x21577d[_0xe7ae('0x14')][_0xe7ae('0x15')]===undefined?!![]:![]:!![],'where':_0x21577d[_0xe7ae('0x14')]?_0x21577d[_0xe7ae('0x14')][_0xe7ae('0x16')]||null:null,'attributes':_0x21577d[_0xe7ae('0x14')]?_0x21577d[_0xe7ae('0x14')][_0xe7ae('0x1a')]||null:null,'include':_0x21577d['options']?_0x21577d[_0xe7ae('0x14')][_0xe7ae('0x18')]?_[_0xe7ae('0x19')](_0x21577d['options'][_0xe7ae('0x18')],function(_0x4c769b){return{'model':db[_0x4c769b[_0xe7ae('0x1b')]],'as':_0x4c769b['as'],'attributes':_0x4c769b[_0xe7ae('0x1a')],'include':_0x4c769b['include']?_[_0xe7ae('0x19')](_0x4c769b[_0xe7ae('0x18')],function(_0x2e69b6){return{'model':db[_0x2e69b6[_0xe7ae('0x1b')]],'as':_0x2e69b6['as'],'attributes':_0x2e69b6['attributes'],'include':_0x2e69b6[_0xe7ae('0x18')]?_[_0xe7ae('0x19')](_0x2e69b6[_0xe7ae('0x18')],function(_0x3897ed){return{'model':db[_0x3897ed[_0xe7ae('0x1b')]],'as':_0x3897ed['as'],'attributes':_0x3897ed[_0xe7ae('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xe7ae('0x1f')](function(_0x6a12cc){logger[_0xe7ae('0x10')](_0xe7ae('0x1d'),_0x21577d);logger['debug'](_0xe7ae('0x1d'),_0x21577d,JSON[_0xe7ae('0xd')](_0x6a12cc));_0x4b8811(_0x6a12cc);})[_0xe7ae('0x11')](function(_0x1c2adc){logger[_0xe7ae('0xe')](_0xe7ae('0x1d'),_0x1c2adc[_0xe7ae('0xf')],_0x21577d);_0x402077(_0x2fcc29['error'](0x1f4,_0x1c2adc['message']));});});};