Built motion from commit 5b761a7b.|2.5.36
[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 _0x6974=['rpc','jayson/promise','http','then','ServicenowAccount,\x20%s,\x20%s','request\x20sent','debug','error','code','message','catch','ServicenowAccount','findAll','raw','options','where','attributes','include','map','GetServicenowAccount','stringify','find','model','ShowServicenowAccount','lodash','ioredis','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x2641f9,_0x26715f){var _0x585741=function(_0x2d1462){while(--_0x2d1462){_0x2641f9['push'](_0x2641f9['shift']());}};_0x585741(++_0x26715f);}(_0x6974,0x157));var _0x4697=function(_0x27b702,_0x14ce1f){_0x27b702=_0x27b702-0x0;var _0x5c0ac3=_0x6974[_0x27b702];return _0x5c0ac3;};'use strict';var _=require(_0x4697('0x0'));var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x4697('0x1'));var db=require(_0x4697('0x2'))['db'];var utils=require(_0x4697('0x3'));var logger=require(_0x4697('0x4'))(_0x4697('0x5'));var config=require('../../config/environment');var jayson=require(_0x4697('0x6'));var client=jayson['client'][_0x4697('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x212b73,_0x382599,_0x49f70e){return new BPromise(function(_0x5cc8b9,_0x35fb8e){return client['request'](_0x212b73,_0x49f70e)[_0x4697('0x8')](function(_0x2f190b){logger['info'](_0x4697('0x9'),_0x382599,_0x4697('0xa'));logger[_0x4697('0xb')]('ServicenowAccount,\x20%s,\x20%s,\x20%s',_0x382599,_0x4697('0xa'),JSON['stringify'](_0x2f190b));if(_0x2f190b['error']){if(_0x2f190b[_0x4697('0xc')][_0x4697('0xd')]===0x1f4){logger[_0x4697('0xc')](_0x4697('0x9'),_0x382599,_0x2f190b[_0x4697('0xc')][_0x4697('0xe')]);return _0x35fb8e(_0x2f190b['error'][_0x4697('0xe')]);}logger[_0x4697('0xc')]('ServicenowAccount,\x20%s,\x20%s',_0x382599,_0x2f190b[_0x4697('0xc')]['message']);return _0x5cc8b9(_0x2f190b[_0x4697('0xc')][_0x4697('0xe')]);}else{logger['info']('ServicenowAccount,\x20%s,\x20%s',_0x382599,_0x4697('0xa'));_0x5cc8b9(_0x2f190b['result']['message']);}})[_0x4697('0xf')](function(_0x527beb){logger[_0x4697('0xc')](_0x4697('0x9'),_0x382599,_0x527beb);_0x35fb8e(_0x527beb);});});}exports['GetServicenowAccount']=function(_0x572f1c){var _0x3e3510=this;return new Promise(function(_0x3896d4,_0x238720){return db[_0x4697('0x10')][_0x4697('0x11')]({'raw':_0x572f1c['options']?_0x572f1c['options'][_0x4697('0x12')]===undefined?!![]:![]:!![],'where':_0x572f1c[_0x4697('0x13')]?_0x572f1c[_0x4697('0x13')][_0x4697('0x14')]||null:null,'attributes':_0x572f1c[_0x4697('0x13')]?_0x572f1c[_0x4697('0x13')][_0x4697('0x15')]||null:null,'limit':_0x572f1c[_0x4697('0x13')]?_0x572f1c[_0x4697('0x13')]['limit']||null:null,'include':_0x572f1c[_0x4697('0x13')]?_0x572f1c[_0x4697('0x13')][_0x4697('0x16')]?_[_0x4697('0x17')](_0x572f1c['options'][_0x4697('0x16')],function(_0x297625){return{'model':db[_0x297625['model']],'as':_0x297625['as'],'attributes':_0x297625[_0x4697('0x15')],'include':_0x297625[_0x4697('0x16')]?_['map'](_0x297625[_0x4697('0x16')],function(_0x80a6a2){return{'model':db[_0x80a6a2['model']],'as':_0x80a6a2['as'],'attributes':_0x80a6a2[_0x4697('0x15')],'include':_0x80a6a2[_0x4697('0x16')]?_[_0x4697('0x17')](_0x80a6a2[_0x4697('0x16')],function(_0xf7d6cc){return{'model':db[_0xf7d6cc['model']],'as':_0xf7d6cc['as'],'attributes':_0xf7d6cc[_0x4697('0x15')]};}):[]};}):[]};}):[]:[]})[_0x4697('0x8')](function(_0x1e64f3){logger['info'](_0x4697('0x18'),_0x572f1c);logger[_0x4697('0xb')](_0x4697('0x18'),_0x572f1c,JSON[_0x4697('0x19')](_0x1e64f3));_0x3896d4(_0x1e64f3);})[_0x4697('0xf')](function(_0x463a81){logger[_0x4697('0xc')]('GetServicenowAccount',_0x463a81[_0x4697('0xe')],_0x572f1c);_0x238720(_0x3e3510[_0x4697('0xc')](0x1f4,_0x463a81[_0x4697('0xe')]));});});};exports['ShowServicenowAccount']=function(_0x357987){var _0x5b0343=this;return new Promise(function(_0x2722e7,_0x1d10df){return db[_0x4697('0x10')][_0x4697('0x1a')]({'raw':_0x357987[_0x4697('0x13')]?_0x357987[_0x4697('0x13')][_0x4697('0x12')]===undefined?!![]:![]:!![],'where':_0x357987[_0x4697('0x13')]?_0x357987[_0x4697('0x13')][_0x4697('0x14')]||null:null,'attributes':_0x357987['options']?_0x357987[_0x4697('0x13')]['attributes']||null:null,'include':_0x357987[_0x4697('0x13')]?_0x357987[_0x4697('0x13')][_0x4697('0x16')]?_[_0x4697('0x17')](_0x357987[_0x4697('0x13')][_0x4697('0x16')],function(_0x586814){return{'model':db[_0x586814['model']],'as':_0x586814['as'],'attributes':_0x586814[_0x4697('0x15')],'include':_0x586814[_0x4697('0x16')]?_['map'](_0x586814['include'],function(_0x4956e0){return{'model':db[_0x4956e0[_0x4697('0x1b')]],'as':_0x4956e0['as'],'attributes':_0x4956e0[_0x4697('0x15')],'include':_0x4956e0['include']?_[_0x4697('0x17')](_0x4956e0['include'],function(_0x557ff0){return{'model':db[_0x557ff0[_0x4697('0x1b')]],'as':_0x557ff0['as'],'attributes':_0x557ff0[_0x4697('0x15')]};}):[]};}):[]};}):[]:[]})[_0x4697('0x8')](function(_0x44a8fe){logger['info'](_0x4697('0x1c'),_0x357987);logger['debug'](_0x4697('0x1c'),_0x357987,JSON[_0x4697('0x19')](_0x44a8fe));_0x2722e7(_0x44a8fe);})['catch'](function(_0x3a3baf){logger['error'](_0x4697('0x1c'),_0x3a3baf[_0x4697('0xe')],_0x357987);_0x1d10df(_0x5b0343[_0x4697('0xc')](0x1f4,_0x3a3baf['message']));});});};