Built motion from commit 192134f6.|2.6.25
[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 _0x2f74=['catch','GetServicenowAccount','ServicenowAccount','findAll','options','raw','limit','include','map','model','attributes','stringify','ShowServicenowAccount','find','where','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','http','request','then','info','ServicenowAccount,\x20%s,\x20%s','request\x20sent','debug','ServicenowAccount,\x20%s,\x20%s,\x20%s','error','code','message','result'];(function(_0x47137d,_0x484202){var _0x38a5f9=function(_0x29e326){while(--_0x29e326){_0x47137d['push'](_0x47137d['shift']());}};_0x38a5f9(++_0x484202);}(_0x2f74,0x7b));var _0x42f7=function(_0x1db29a,_0x5263e6){_0x1db29a=_0x1db29a-0x0;var _0x53525b=_0x2f74[_0x1db29a];return _0x53525b;};'use strict';var _=require(_0x42f7('0x0'));var util=require('util');var moment=require(_0x42f7('0x1'));var BPromise=require(_0x42f7('0x2'));var rs=require(_0x42f7('0x3'));var fs=require('fs');var Redis=require(_0x42f7('0x4'));var db=require(_0x42f7('0x5'))['db'];var utils=require(_0x42f7('0x6'));var logger=require(_0x42f7('0x7'))(_0x42f7('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0x42f7('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x1cb6e0,_0x20ff46,_0x36b55e){return new BPromise(function(_0x2c64b2,_0x28fc83){return client[_0x42f7('0xa')](_0x1cb6e0,_0x36b55e)[_0x42f7('0xb')](function(_0x5772a8){logger[_0x42f7('0xc')](_0x42f7('0xd'),_0x20ff46,_0x42f7('0xe'));logger[_0x42f7('0xf')](_0x42f7('0x10'),_0x20ff46,_0x42f7('0xe'),JSON['stringify'](_0x5772a8));if(_0x5772a8[_0x42f7('0x11')]){if(_0x5772a8[_0x42f7('0x11')][_0x42f7('0x12')]===0x1f4){logger[_0x42f7('0x11')](_0x42f7('0xd'),_0x20ff46,_0x5772a8[_0x42f7('0x11')][_0x42f7('0x13')]);return _0x28fc83(_0x5772a8[_0x42f7('0x11')]['message']);}logger['error'](_0x42f7('0xd'),_0x20ff46,_0x5772a8[_0x42f7('0x11')][_0x42f7('0x13')]);return _0x2c64b2(_0x5772a8[_0x42f7('0x11')][_0x42f7('0x13')]);}else{logger['info'](_0x42f7('0xd'),_0x20ff46,'request\x20sent');_0x2c64b2(_0x5772a8[_0x42f7('0x14')][_0x42f7('0x13')]);}})[_0x42f7('0x15')](function(_0x19eff3){logger[_0x42f7('0x11')](_0x42f7('0xd'),_0x20ff46,_0x19eff3);_0x28fc83(_0x19eff3);});});}exports[_0x42f7('0x16')]=function(_0x47aa1d){var _0x3fc38d=this;return new Promise(function(_0x29f472,_0x43ef57){return db[_0x42f7('0x17')][_0x42f7('0x18')]({'raw':_0x47aa1d[_0x42f7('0x19')]?_0x47aa1d['options'][_0x42f7('0x1a')]===undefined?!![]:![]:!![],'where':_0x47aa1d['options']?_0x47aa1d[_0x42f7('0x19')]['where']||null:null,'attributes':_0x47aa1d[_0x42f7('0x19')]?_0x47aa1d['options']['attributes']||null:null,'limit':_0x47aa1d['options']?_0x47aa1d[_0x42f7('0x19')][_0x42f7('0x1b')]||null:null,'include':_0x47aa1d[_0x42f7('0x19')]?_0x47aa1d[_0x42f7('0x19')][_0x42f7('0x1c')]?_[_0x42f7('0x1d')](_0x47aa1d[_0x42f7('0x19')][_0x42f7('0x1c')],function(_0x1d45a0){return{'model':db[_0x1d45a0[_0x42f7('0x1e')]],'as':_0x1d45a0['as'],'attributes':_0x1d45a0[_0x42f7('0x1f')],'include':_0x1d45a0[_0x42f7('0x1c')]?_[_0x42f7('0x1d')](_0x1d45a0[_0x42f7('0x1c')],function(_0x553531){return{'model':db[_0x553531['model']],'as':_0x553531['as'],'attributes':_0x553531[_0x42f7('0x1f')],'include':_0x553531[_0x42f7('0x1c')]?_[_0x42f7('0x1d')](_0x553531[_0x42f7('0x1c')],function(_0x1e31de){return{'model':db[_0x1e31de[_0x42f7('0x1e')]],'as':_0x1e31de['as'],'attributes':_0x1e31de[_0x42f7('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x42f7('0xb')](function(_0xe53027){logger[_0x42f7('0xc')]('GetServicenowAccount',_0x47aa1d);logger['debug'](_0x42f7('0x16'),_0x47aa1d,JSON[_0x42f7('0x20')](_0xe53027));_0x29f472(_0xe53027);})[_0x42f7('0x15')](function(_0x4d7137){logger[_0x42f7('0x11')](_0x42f7('0x16'),_0x4d7137['message'],_0x47aa1d);_0x43ef57(_0x3fc38d['error'](0x1f4,_0x4d7137[_0x42f7('0x13')]));});});};exports[_0x42f7('0x21')]=function(_0x210054){var _0xf6664c=this;return new Promise(function(_0x1e245c,_0x3a07b8){return db[_0x42f7('0x17')][_0x42f7('0x22')]({'raw':_0x210054[_0x42f7('0x19')]?_0x210054['options'][_0x42f7('0x1a')]===undefined?!![]:![]:!![],'where':_0x210054[_0x42f7('0x19')]?_0x210054[_0x42f7('0x19')][_0x42f7('0x23')]||null:null,'attributes':_0x210054[_0x42f7('0x19')]?_0x210054['options'][_0x42f7('0x1f')]||null:null,'include':_0x210054[_0x42f7('0x19')]?_0x210054[_0x42f7('0x19')][_0x42f7('0x1c')]?_['map'](_0x210054[_0x42f7('0x19')]['include'],function(_0x25007e){return{'model':db[_0x25007e[_0x42f7('0x1e')]],'as':_0x25007e['as'],'attributes':_0x25007e[_0x42f7('0x1f')],'include':_0x25007e[_0x42f7('0x1c')]?_[_0x42f7('0x1d')](_0x25007e[_0x42f7('0x1c')],function(_0x372a20){return{'model':db[_0x372a20['model']],'as':_0x372a20['as'],'attributes':_0x372a20['attributes'],'include':_0x372a20[_0x42f7('0x1c')]?_[_0x42f7('0x1d')](_0x372a20['include'],function(_0x33164e){return{'model':db[_0x33164e['model']],'as':_0x33164e['as'],'attributes':_0x33164e[_0x42f7('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x42f7('0xb')](function(_0x568d25){logger['info']('ShowServicenowAccount',_0x210054);logger[_0x42f7('0xf')]('ShowServicenowAccount',_0x210054,JSON[_0x42f7('0x20')](_0x568d25));_0x1e245c(_0x568d25);})[_0x42f7('0x15')](function(_0x44ec4b){logger[_0x42f7('0x11')](_0x42f7('0x21'),_0x44ec4b['message'],_0x210054);_0x3a07b8(_0xf6664c[_0x42f7('0x11')](0x1f4,_0x44ec4b[_0x42f7('0x13')]));});});};