430c5608aa9e454a0ce6b52f21c5b95fe5816df8
[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 _0x472f=['../../config/environment','jayson/promise','client','http','request','then','info','ServicenowAccount,\x20%s,\x20%s','request\x20sent','debug','ServicenowAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetServicenowAccount','ServicenowAccount','options','raw','where','attributes','limit','include','map','model','ShowServicenowAccount','find','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x498e33,_0x985556){var _0x80dcc1=function(_0x416e86){while(--_0x416e86){_0x498e33['push'](_0x498e33['shift']());}};_0x80dcc1(++_0x985556);}(_0x472f,0x1e5));var _0xf472=function(_0x539fc9,_0x4d414c){_0x539fc9=_0x539fc9-0x0;var _0x3824fe=_0x472f[_0x539fc9];return _0x3824fe;};'use strict';var _=require(_0xf472('0x0'));var util=require(_0xf472('0x1'));var moment=require(_0xf472('0x2'));var BPromise=require('bluebird');var rs=require(_0xf472('0x3'));var fs=require('fs');var Redis=require(_0xf472('0x4'));var db=require(_0xf472('0x5'))['db'];var utils=require(_0xf472('0x6'));var logger=require(_0xf472('0x7'))(_0xf472('0x8'));var config=require(_0xf472('0x9'));var jayson=require(_0xf472('0xa'));var client=jayson[_0xf472('0xb')][_0xf472('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x2facc1,_0x386aa6,_0x317530){return new BPromise(function(_0x113643,_0x595897){return client[_0xf472('0xd')](_0x2facc1,_0x317530)[_0xf472('0xe')](function(_0x9d9a37){logger[_0xf472('0xf')](_0xf472('0x10'),_0x386aa6,_0xf472('0x11'));logger[_0xf472('0x12')](_0xf472('0x13'),_0x386aa6,_0xf472('0x11'),JSON[_0xf472('0x14')](_0x9d9a37));if(_0x9d9a37[_0xf472('0x15')]){if(_0x9d9a37['error'][_0xf472('0x16')]===0x1f4){logger[_0xf472('0x15')](_0xf472('0x10'),_0x386aa6,_0x9d9a37['error']['message']);return _0x595897(_0x9d9a37['error'][_0xf472('0x17')]);}logger['error'](_0xf472('0x10'),_0x386aa6,_0x9d9a37[_0xf472('0x15')][_0xf472('0x17')]);return _0x113643(_0x9d9a37['error']['message']);}else{logger[_0xf472('0xf')](_0xf472('0x10'),_0x386aa6,_0xf472('0x11'));_0x113643(_0x9d9a37[_0xf472('0x18')]['message']);}})[_0xf472('0x19')](function(_0x138558){logger[_0xf472('0x15')](_0xf472('0x10'),_0x386aa6,_0x138558);_0x595897(_0x138558);});});}exports[_0xf472('0x1a')]=function(_0x1b41cd){var _0x900121=this;return new Promise(function(_0x389c32,_0xe45edd){return db[_0xf472('0x1b')]['findAll']({'raw':_0x1b41cd[_0xf472('0x1c')]?_0x1b41cd[_0xf472('0x1c')][_0xf472('0x1d')]===undefined?!![]:![]:!![],'where':_0x1b41cd[_0xf472('0x1c')]?_0x1b41cd[_0xf472('0x1c')][_0xf472('0x1e')]||null:null,'attributes':_0x1b41cd['options']?_0x1b41cd['options'][_0xf472('0x1f')]||null:null,'limit':_0x1b41cd[_0xf472('0x1c')]?_0x1b41cd[_0xf472('0x1c')][_0xf472('0x20')]||null:null,'include':_0x1b41cd[_0xf472('0x1c')]?_0x1b41cd[_0xf472('0x1c')][_0xf472('0x21')]?_[_0xf472('0x22')](_0x1b41cd[_0xf472('0x1c')][_0xf472('0x21')],function(_0x4c149c){return{'model':db[_0x4c149c['model']],'as':_0x4c149c['as'],'attributes':_0x4c149c['attributes'],'include':_0x4c149c['include']?_['map'](_0x4c149c['include'],function(_0x2ac633){return{'model':db[_0x2ac633[_0xf472('0x23')]],'as':_0x2ac633['as'],'attributes':_0x2ac633[_0xf472('0x1f')],'include':_0x2ac633[_0xf472('0x21')]?_[_0xf472('0x22')](_0x2ac633[_0xf472('0x21')],function(_0x1a3ef5){return{'model':db[_0x1a3ef5['model']],'as':_0x1a3ef5['as'],'attributes':_0x1a3ef5[_0xf472('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xf472('0xe')](function(_0x53bd6d){logger[_0xf472('0xf')](_0xf472('0x1a'),_0x1b41cd);logger[_0xf472('0x12')](_0xf472('0x1a'),_0x1b41cd,JSON[_0xf472('0x14')](_0x53bd6d));_0x389c32(_0x53bd6d);})['catch'](function(_0x267f60){logger[_0xf472('0x15')](_0xf472('0x1a'),_0x267f60[_0xf472('0x17')],_0x1b41cd);_0xe45edd(_0x900121[_0xf472('0x15')](0x1f4,_0x267f60[_0xf472('0x17')]));});});};exports[_0xf472('0x24')]=function(_0x2a32e3){var _0x2d569f=this;return new Promise(function(_0x35bc6c,_0x13ded7){return db[_0xf472('0x1b')][_0xf472('0x25')]({'raw':_0x2a32e3['options']?_0x2a32e3['options'][_0xf472('0x1d')]===undefined?!![]:![]:!![],'where':_0x2a32e3['options']?_0x2a32e3[_0xf472('0x1c')][_0xf472('0x1e')]||null:null,'attributes':_0x2a32e3[_0xf472('0x1c')]?_0x2a32e3[_0xf472('0x1c')][_0xf472('0x1f')]||null:null,'include':_0x2a32e3['options']?_0x2a32e3[_0xf472('0x1c')]['include']?_['map'](_0x2a32e3['options'][_0xf472('0x21')],function(_0x2f395b){return{'model':db[_0x2f395b[_0xf472('0x23')]],'as':_0x2f395b['as'],'attributes':_0x2f395b[_0xf472('0x1f')],'include':_0x2f395b['include']?_[_0xf472('0x22')](_0x2f395b[_0xf472('0x21')],function(_0x31634e){return{'model':db[_0x31634e[_0xf472('0x23')]],'as':_0x31634e['as'],'attributes':_0x31634e[_0xf472('0x1f')],'include':_0x31634e[_0xf472('0x21')]?_[_0xf472('0x22')](_0x31634e[_0xf472('0x21')],function(_0x31f394){return{'model':db[_0x31f394[_0xf472('0x23')]],'as':_0x31f394['as'],'attributes':_0x31f394[_0xf472('0x1f')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x47682a){logger[_0xf472('0xf')](_0xf472('0x24'),_0x2a32e3);logger[_0xf472('0x12')](_0xf472('0x24'),_0x2a32e3,JSON[_0xf472('0x14')](_0x47682a));_0x35bc6c(_0x47682a);})['catch'](function(_0x31c688){logger['error'](_0xf472('0x24'),_0x31c688[_0xf472('0x17')],_0x2a32e3);_0x13ded7(_0x2d569f[_0xf472('0x15')](0x1f4,_0x31c688[_0xf472('0x17')]));});});};