458b7d391a80f79d14bcd793a272d8538b64b032
[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 _0xf304=['../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','request\x20sent','debug','error','code','ServicenowAccount,\x20%s,\x20%s','message','catch','GetServicenowAccount','ServicenowAccount','options','raw','where','attributes','limit','include','map','model','find','stringify','ShowServicenowAccount','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils'];(function(_0x474a37,_0x43012e){var _0x13c63e=function(_0x3cc08d){while(--_0x3cc08d){_0x474a37['push'](_0x474a37['shift']());}};_0x13c63e(++_0x43012e);}(_0xf304,0xd1));var _0x4f30=function(_0x505088,_0x23a321){_0x505088=_0x505088-0x0;var _0x3eb2c9=_0xf304[_0x505088];return _0x3eb2c9;};'use strict';var _=require(_0x4f30('0x0'));var util=require('util');var moment=require(_0x4f30('0x1'));var BPromise=require(_0x4f30('0x2'));var rs=require(_0x4f30('0x3'));var fs=require('fs');var Redis=require(_0x4f30('0x4'));var db=require(_0x4f30('0x5'))['db'];var utils=require(_0x4f30('0x6'));var logger=require(_0x4f30('0x7'))(_0x4f30('0x8'));var config=require(_0x4f30('0x9'));var jayson=require(_0x4f30('0xa'));var client=jayson[_0x4f30('0xb')][_0x4f30('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x1720e3,_0x2c86e2,_0x5f484a){return new BPromise(function(_0x2cb0ec,_0x523389){return client[_0x4f30('0xd')](_0x1720e3,_0x5f484a)[_0x4f30('0xe')](function(_0x2babf7){logger[_0x4f30('0xf')]('ServicenowAccount,\x20%s,\x20%s',_0x2c86e2,_0x4f30('0x10'));logger[_0x4f30('0x11')]('ServicenowAccount,\x20%s,\x20%s,\x20%s',_0x2c86e2,_0x4f30('0x10'),JSON['stringify'](_0x2babf7));if(_0x2babf7['error']){if(_0x2babf7[_0x4f30('0x12')][_0x4f30('0x13')]===0x1f4){logger[_0x4f30('0x12')](_0x4f30('0x14'),_0x2c86e2,_0x2babf7[_0x4f30('0x12')][_0x4f30('0x15')]);return _0x523389(_0x2babf7[_0x4f30('0x12')][_0x4f30('0x15')]);}logger['error'](_0x4f30('0x14'),_0x2c86e2,_0x2babf7['error'][_0x4f30('0x15')]);return _0x2cb0ec(_0x2babf7[_0x4f30('0x12')]['message']);}else{logger['info'](_0x4f30('0x14'),_0x2c86e2,_0x4f30('0x10'));_0x2cb0ec(_0x2babf7['result']['message']);}})[_0x4f30('0x16')](function(_0x21d557){logger[_0x4f30('0x12')](_0x4f30('0x14'),_0x2c86e2,_0x21d557);_0x523389(_0x21d557);});});}exports[_0x4f30('0x17')]=function(_0x1e2ba6){var _0x2b329c=this;return new Promise(function(_0x5c6e15,_0x5c762a){return db[_0x4f30('0x18')]['findAll']({'raw':_0x1e2ba6['options']?_0x1e2ba6[_0x4f30('0x19')][_0x4f30('0x1a')]===undefined?!![]:![]:!![],'where':_0x1e2ba6[_0x4f30('0x19')]?_0x1e2ba6['options'][_0x4f30('0x1b')]||null:null,'attributes':_0x1e2ba6['options']?_0x1e2ba6[_0x4f30('0x19')][_0x4f30('0x1c')]||null:null,'limit':_0x1e2ba6['options']?_0x1e2ba6[_0x4f30('0x19')][_0x4f30('0x1d')]||null:null,'include':_0x1e2ba6[_0x4f30('0x19')]?_0x1e2ba6[_0x4f30('0x19')][_0x4f30('0x1e')]?_[_0x4f30('0x1f')](_0x1e2ba6[_0x4f30('0x19')][_0x4f30('0x1e')],function(_0x174a84){return{'model':db[_0x174a84[_0x4f30('0x20')]],'as':_0x174a84['as'],'attributes':_0x174a84[_0x4f30('0x1c')],'include':_0x174a84[_0x4f30('0x1e')]?_[_0x4f30('0x1f')](_0x174a84[_0x4f30('0x1e')],function(_0x4140bf){return{'model':db[_0x4140bf['model']],'as':_0x4140bf['as'],'attributes':_0x4140bf[_0x4f30('0x1c')],'include':_0x4140bf[_0x4f30('0x1e')]?_[_0x4f30('0x1f')](_0x4140bf[_0x4f30('0x1e')],function(_0x5d1443){return{'model':db[_0x5d1443['model']],'as':_0x5d1443['as'],'attributes':_0x5d1443[_0x4f30('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x4f30('0xe')](function(_0x23bcc2){logger['info'](_0x4f30('0x17'),_0x1e2ba6);logger[_0x4f30('0x11')](_0x4f30('0x17'),_0x1e2ba6,JSON['stringify'](_0x23bcc2));_0x5c6e15(_0x23bcc2);})['catch'](function(_0x5b8b4a){logger[_0x4f30('0x12')](_0x4f30('0x17'),_0x5b8b4a[_0x4f30('0x15')],_0x1e2ba6);_0x5c762a(_0x2b329c['error'](0x1f4,_0x5b8b4a[_0x4f30('0x15')]));});});};exports['ShowServicenowAccount']=function(_0x3aed40){var _0x3a6272=this;return new Promise(function(_0xe7e5c5,_0x51f496){return db[_0x4f30('0x18')][_0x4f30('0x21')]({'raw':_0x3aed40['options']?_0x3aed40[_0x4f30('0x19')][_0x4f30('0x1a')]===undefined?!![]:![]:!![],'where':_0x3aed40[_0x4f30('0x19')]?_0x3aed40['options']['where']||null:null,'attributes':_0x3aed40[_0x4f30('0x19')]?_0x3aed40[_0x4f30('0x19')][_0x4f30('0x1c')]||null:null,'include':_0x3aed40[_0x4f30('0x19')]?_0x3aed40[_0x4f30('0x19')]['include']?_[_0x4f30('0x1f')](_0x3aed40['options'][_0x4f30('0x1e')],function(_0x541013){return{'model':db[_0x541013['model']],'as':_0x541013['as'],'attributes':_0x541013[_0x4f30('0x1c')],'include':_0x541013['include']?_['map'](_0x541013[_0x4f30('0x1e')],function(_0x59495f){return{'model':db[_0x59495f['model']],'as':_0x59495f['as'],'attributes':_0x59495f[_0x4f30('0x1c')],'include':_0x59495f[_0x4f30('0x1e')]?_[_0x4f30('0x1f')](_0x59495f[_0x4f30('0x1e')],function(_0x2fe8b5){return{'model':db[_0x2fe8b5[_0x4f30('0x20')]],'as':_0x2fe8b5['as'],'attributes':_0x2fe8b5[_0x4f30('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x4f30('0xe')](function(_0x216050){logger['info']('ShowServicenowAccount',_0x3aed40);logger[_0x4f30('0x11')]('ShowServicenowAccount',_0x3aed40,JSON[_0x4f30('0x22')](_0x216050));_0xe7e5c5(_0x216050);})[_0x4f30('0x16')](function(_0x1d84a0){logger['error'](_0x4f30('0x23'),_0x1d84a0[_0x4f30('0x15')],_0x3aed40);_0x51f496(_0x3a6272[_0x4f30('0x12')](0x1f4,_0x1d84a0[_0x4f30('0x15')]));});});};