ea20d0e3bb538c8556e18836d97a942cd4bea26f
[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 _0x67c2=['ShowServicenowAccount','ServicenowAccount','bluebird','randomstring','../../mysqldb','../../config/logger','../../config/environment','client','http','request','then','info','ServicenowAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','GetServicenowAccount','findAll','options','raw','where','attributes','limit','map','model','include','catch'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x67c2,0x14c));var _0x267c=function(_0x42c81c,_0x5352e1){_0x42c81c=_0x42c81c-0x0;var _0x24b0b4=_0x67c2[_0x42c81c];return _0x24b0b4;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0x267c('0x0'));var rs=require(_0x267c('0x1'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x267c('0x2'))['db'];var utils=require('../../config/utils');var logger=require(_0x267c('0x3'))('rpc');var config=require(_0x267c('0x4'));var jayson=require('jayson/promise');var client=jayson[_0x267c('0x5')][_0x267c('0x6')]({'port':0x232a});function respondWithRpcPromise(_0x1afc38,_0x55b0b1,_0x2b9053){return new BPromise(function(_0x32c94d,_0x166781){return client[_0x267c('0x7')](_0x1afc38,_0x2b9053)[_0x267c('0x8')](function(_0x24aee3){logger[_0x267c('0x9')](_0x267c('0xa'),_0x55b0b1,_0x267c('0xb'));logger[_0x267c('0xc')]('ServicenowAccount,\x20%s,\x20%s,\x20%s',_0x55b0b1,_0x267c('0xb'),JSON[_0x267c('0xd')](_0x24aee3));if(_0x24aee3[_0x267c('0xe')]){if(_0x24aee3['error'][_0x267c('0xf')]===0x1f4){logger[_0x267c('0xe')](_0x267c('0xa'),_0x55b0b1,_0x24aee3[_0x267c('0xe')][_0x267c('0x10')]);return _0x166781(_0x24aee3[_0x267c('0xe')][_0x267c('0x10')]);}logger['error'](_0x267c('0xa'),_0x55b0b1,_0x24aee3[_0x267c('0xe')][_0x267c('0x10')]);return _0x32c94d(_0x24aee3[_0x267c('0xe')]['message']);}else{logger[_0x267c('0x9')](_0x267c('0xa'),_0x55b0b1,_0x267c('0xb'));_0x32c94d(_0x24aee3['result'][_0x267c('0x10')]);}})['catch'](function(_0x2175e7){logger[_0x267c('0xe')](_0x267c('0xa'),_0x55b0b1,_0x2175e7);_0x166781(_0x2175e7);});});}exports[_0x267c('0x11')]=function(_0x3496a7){var _0x133f1a=this;return new Promise(function(_0x5a18ac,_0x29e320){return db['ServicenowAccount'][_0x267c('0x12')]({'raw':_0x3496a7[_0x267c('0x13')]?_0x3496a7[_0x267c('0x13')][_0x267c('0x14')]===undefined?!![]:![]:!![],'where':_0x3496a7['options']?_0x3496a7[_0x267c('0x13')][_0x267c('0x15')]||null:null,'attributes':_0x3496a7[_0x267c('0x13')]?_0x3496a7[_0x267c('0x13')][_0x267c('0x16')]||null:null,'limit':_0x3496a7[_0x267c('0x13')]?_0x3496a7[_0x267c('0x13')][_0x267c('0x17')]||null:null,'include':_0x3496a7['options']?_0x3496a7[_0x267c('0x13')]['include']?_[_0x267c('0x18')](_0x3496a7[_0x267c('0x13')]['include'],function(_0x1627b6){return{'model':db[_0x1627b6[_0x267c('0x19')]],'as':_0x1627b6['as'],'attributes':_0x1627b6[_0x267c('0x16')],'include':_0x1627b6[_0x267c('0x1a')]?_[_0x267c('0x18')](_0x1627b6[_0x267c('0x1a')],function(_0x1bc66f){return{'model':db[_0x1bc66f[_0x267c('0x19')]],'as':_0x1bc66f['as'],'attributes':_0x1bc66f[_0x267c('0x16')],'include':_0x1bc66f[_0x267c('0x1a')]?_['map'](_0x1bc66f[_0x267c('0x1a')],function(_0x23abb5){return{'model':db[_0x23abb5[_0x267c('0x19')]],'as':_0x23abb5['as'],'attributes':_0x23abb5[_0x267c('0x16')]};}):[]};}):[]};}):[]:[]})[_0x267c('0x8')](function(_0x45c894){logger['info'](_0x267c('0x11'),_0x3496a7);logger[_0x267c('0xc')](_0x267c('0x11'),_0x3496a7,JSON[_0x267c('0xd')](_0x45c894));_0x5a18ac(_0x45c894);})[_0x267c('0x1b')](function(_0x36d000){logger[_0x267c('0xe')](_0x267c('0x11'),_0x36d000[_0x267c('0x10')],_0x3496a7);_0x29e320(_0x133f1a[_0x267c('0xe')](0x1f4,_0x36d000[_0x267c('0x10')]));});});};exports[_0x267c('0x1c')]=function(_0x2bfbbb){var _0x591cc0=this;return new Promise(function(_0x9fc261,_0x1d7a7c){return db[_0x267c('0x1d')]['find']({'raw':_0x2bfbbb[_0x267c('0x13')]?_0x2bfbbb['options'][_0x267c('0x14')]===undefined?!![]:![]:!![],'where':_0x2bfbbb[_0x267c('0x13')]?_0x2bfbbb['options'][_0x267c('0x15')]||null:null,'attributes':_0x2bfbbb[_0x267c('0x13')]?_0x2bfbbb['options']['attributes']||null:null,'include':_0x2bfbbb['options']?_0x2bfbbb[_0x267c('0x13')]['include']?_[_0x267c('0x18')](_0x2bfbbb[_0x267c('0x13')]['include'],function(_0x2d368c){return{'model':db[_0x2d368c['model']],'as':_0x2d368c['as'],'attributes':_0x2d368c[_0x267c('0x16')],'include':_0x2d368c[_0x267c('0x1a')]?_[_0x267c('0x18')](_0x2d368c['include'],function(_0x1ef3ce){return{'model':db[_0x1ef3ce[_0x267c('0x19')]],'as':_0x1ef3ce['as'],'attributes':_0x1ef3ce[_0x267c('0x16')],'include':_0x1ef3ce['include']?_[_0x267c('0x18')](_0x1ef3ce[_0x267c('0x1a')],function(_0x962a60){return{'model':db[_0x962a60['model']],'as':_0x962a60['as'],'attributes':_0x962a60['attributes']};}):[]};}):[]};}):[]:[]})[_0x267c('0x8')](function(_0x1160a7){logger[_0x267c('0x9')](_0x267c('0x1c'),_0x2bfbbb);logger[_0x267c('0xc')](_0x267c('0x1c'),_0x2bfbbb,JSON[_0x267c('0xd')](_0x1160a7));_0x9fc261(_0x1160a7);})[_0x267c('0x1b')](function(_0x5275){logger[_0x267c('0xe')](_0x267c('0x1c'),_0x5275[_0x267c('0x10')],_0x2bfbbb);_0x1d7a7c(_0x591cc0['error'](0x1f4,_0x5275[_0x267c('0x10')]));});});};