a77b359c2c18d9647cda8bf0a26030e20224f6cc
[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 _0xf895=['../../mysqldb','../../config/utils','rpc','jayson/promise','client','http','request','then','info','ServicenowAccount,\x20%s,\x20%s','debug','ServicenowAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','GetServicenowAccount','options','raw','attributes','limit','include','model','map','ShowServicenowAccount','find','where','catch','lodash','util','bluebird','randomstring','ioredis'];(function(_0x4596de,_0x49e8e7){var _0x3f2a40=function(_0x5a8564){while(--_0x5a8564){_0x4596de['push'](_0x4596de['shift']());}};_0x3f2a40(++_0x49e8e7);}(_0xf895,0x1e5));var _0x5f89=function(_0x2ca0bd,_0x311bac){_0x2ca0bd=_0x2ca0bd-0x0;var _0x22b721=_0xf895[_0x2ca0bd];return _0x22b721;};'use strict';var _=require(_0x5f89('0x0'));var util=require(_0x5f89('0x1'));var moment=require('moment');var BPromise=require(_0x5f89('0x2'));var rs=require(_0x5f89('0x3'));var fs=require('fs');var Redis=require(_0x5f89('0x4'));var db=require(_0x5f89('0x5'))['db'];var utils=require(_0x5f89('0x6'));var logger=require('../../config/logger')(_0x5f89('0x7'));var config=require('../../config/environment');var jayson=require(_0x5f89('0x8'));var client=jayson[_0x5f89('0x9')][_0x5f89('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x35ed20,_0x124ad7,_0x56be40){return new BPromise(function(_0x2f077,_0x194a71){return client[_0x5f89('0xb')](_0x35ed20,_0x56be40)[_0x5f89('0xc')](function(_0x403d3c){logger[_0x5f89('0xd')](_0x5f89('0xe'),_0x124ad7,'request\x20sent');logger[_0x5f89('0xf')](_0x5f89('0x10'),_0x124ad7,_0x5f89('0x11'),JSON[_0x5f89('0x12')](_0x403d3c));if(_0x403d3c[_0x5f89('0x13')]){if(_0x403d3c[_0x5f89('0x13')][_0x5f89('0x14')]===0x1f4){logger[_0x5f89('0x13')](_0x5f89('0xe'),_0x124ad7,_0x403d3c['error'][_0x5f89('0x15')]);return _0x194a71(_0x403d3c[_0x5f89('0x13')][_0x5f89('0x15')]);}logger[_0x5f89('0x13')]('ServicenowAccount,\x20%s,\x20%s',_0x124ad7,_0x403d3c['error'][_0x5f89('0x15')]);return _0x2f077(_0x403d3c['error']['message']);}else{logger[_0x5f89('0xd')]('ServicenowAccount,\x20%s,\x20%s',_0x124ad7,_0x5f89('0x11'));_0x2f077(_0x403d3c[_0x5f89('0x16')]['message']);}})['catch'](function(_0x18baba){logger[_0x5f89('0x13')](_0x5f89('0xe'),_0x124ad7,_0x18baba);_0x194a71(_0x18baba);});});}exports[_0x5f89('0x17')]=function(_0x1c2007){var _0x3140b8=this;return new Promise(function(_0xb3d6d8,_0x51d885){return db['ServicenowAccount']['findAll']({'raw':_0x1c2007[_0x5f89('0x18')]?_0x1c2007[_0x5f89('0x18')][_0x5f89('0x19')]===undefined?!![]:![]:!![],'where':_0x1c2007['options']?_0x1c2007[_0x5f89('0x18')]['where']||null:null,'attributes':_0x1c2007[_0x5f89('0x18')]?_0x1c2007[_0x5f89('0x18')][_0x5f89('0x1a')]||null:null,'limit':_0x1c2007[_0x5f89('0x18')]?_0x1c2007[_0x5f89('0x18')][_0x5f89('0x1b')]||null:null,'include':_0x1c2007['options']?_0x1c2007[_0x5f89('0x18')][_0x5f89('0x1c')]?_['map'](_0x1c2007[_0x5f89('0x18')][_0x5f89('0x1c')],function(_0x1698e8){return{'model':db[_0x1698e8[_0x5f89('0x1d')]],'as':_0x1698e8['as'],'attributes':_0x1698e8[_0x5f89('0x1a')],'include':_0x1698e8['include']?_['map'](_0x1698e8[_0x5f89('0x1c')],function(_0x13bcc9){return{'model':db[_0x13bcc9['model']],'as':_0x13bcc9['as'],'attributes':_0x13bcc9[_0x5f89('0x1a')],'include':_0x13bcc9[_0x5f89('0x1c')]?_[_0x5f89('0x1e')](_0x13bcc9[_0x5f89('0x1c')],function(_0x289406){return{'model':db[_0x289406[_0x5f89('0x1d')]],'as':_0x289406['as'],'attributes':_0x289406[_0x5f89('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x3c4329){logger[_0x5f89('0xd')](_0x5f89('0x17'),_0x1c2007);logger['debug'](_0x5f89('0x17'),_0x1c2007,JSON[_0x5f89('0x12')](_0x3c4329));_0xb3d6d8(_0x3c4329);})['catch'](function(_0x47a75f){logger['error'](_0x5f89('0x17'),_0x47a75f[_0x5f89('0x15')],_0x1c2007);_0x51d885(_0x3140b8[_0x5f89('0x13')](0x1f4,_0x47a75f['message']));});});};exports[_0x5f89('0x1f')]=function(_0x195f29){var _0x5d23e3=this;return new Promise(function(_0x2d7ed1,_0x4f8015){return db['ServicenowAccount'][_0x5f89('0x20')]({'raw':_0x195f29[_0x5f89('0x18')]?_0x195f29[_0x5f89('0x18')][_0x5f89('0x19')]===undefined?!![]:![]:!![],'where':_0x195f29['options']?_0x195f29['options'][_0x5f89('0x21')]||null:null,'attributes':_0x195f29[_0x5f89('0x18')]?_0x195f29[_0x5f89('0x18')][_0x5f89('0x1a')]||null:null,'include':_0x195f29['options']?_0x195f29[_0x5f89('0x18')][_0x5f89('0x1c')]?_[_0x5f89('0x1e')](_0x195f29['options']['include'],function(_0x35475a){return{'model':db[_0x35475a[_0x5f89('0x1d')]],'as':_0x35475a['as'],'attributes':_0x35475a[_0x5f89('0x1a')],'include':_0x35475a[_0x5f89('0x1c')]?_[_0x5f89('0x1e')](_0x35475a[_0x5f89('0x1c')],function(_0xf5ccf3){return{'model':db[_0xf5ccf3[_0x5f89('0x1d')]],'as':_0xf5ccf3['as'],'attributes':_0xf5ccf3[_0x5f89('0x1a')],'include':_0xf5ccf3[_0x5f89('0x1c')]?_['map'](_0xf5ccf3[_0x5f89('0x1c')],function(_0x2d820f){return{'model':db[_0x2d820f['model']],'as':_0x2d820f['as'],'attributes':_0x2d820f['attributes']};}):[]};}):[]};}):[]:[]})[_0x5f89('0xc')](function(_0xb99b72){logger['info'](_0x5f89('0x1f'),_0x195f29);logger[_0x5f89('0xf')](_0x5f89('0x1f'),_0x195f29,JSON[_0x5f89('0x12')](_0xb99b72));_0x2d7ed1(_0xb99b72);})[_0x5f89('0x22')](function(_0x3b43f2){logger[_0x5f89('0x13')]('ShowServicenowAccount',_0x3b43f2[_0x5f89('0x15')],_0x195f29);_0x4f8015(_0x5d23e3[_0x5f89('0x13')](0x1f4,_0x3b43f2[_0x5f89('0x15')]));});});};