bf5dca4131c374b42551f256bb4b5526dc2db6f4
[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 _0x5499=['find','lodash','moment','ioredis','../../mysqldb','../../config/logger','rpc','jayson/promise','client','http','then','info','debug','request\x20sent','error','code','ServicenowAccount,\x20%s,\x20%s','message','result','catch','GetServicenowAccount','ServicenowAccount','findAll','options','raw','where','attributes','limit','map','include','model','stringify','ShowServicenowAccount'];(function(_0x34a087,_0x4bd68e){var _0x5c15d7=function(_0x152823){while(--_0x152823){_0x34a087['push'](_0x34a087['shift']());}};_0x5c15d7(++_0x4bd68e);}(_0x5499,0x14b));var _0x9549=function(_0x245efb,_0x2c636b){_0x245efb=_0x245efb-0x0;var _0x59ee7b=_0x5499[_0x245efb];return _0x59ee7b;};'use strict';var _=require(_0x9549('0x0'));var util=require('util');var moment=require(_0x9549('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x9549('0x2'));var db=require(_0x9549('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x9549('0x4'))(_0x9549('0x5'));var config=require('../../config/environment');var jayson=require(_0x9549('0x6'));var client=jayson[_0x9549('0x7')][_0x9549('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x531992,_0x287e14,_0x51db6f){return new BPromise(function(_0x23369b,_0x38433b){return client['request'](_0x531992,_0x51db6f)[_0x9549('0x9')](function(_0x4454b5){logger[_0x9549('0xa')]('ServicenowAccount,\x20%s,\x20%s',_0x287e14,'request\x20sent');logger[_0x9549('0xb')]('ServicenowAccount,\x20%s,\x20%s,\x20%s',_0x287e14,_0x9549('0xc'),JSON['stringify'](_0x4454b5));if(_0x4454b5[_0x9549('0xd')]){if(_0x4454b5['error'][_0x9549('0xe')]===0x1f4){logger[_0x9549('0xd')](_0x9549('0xf'),_0x287e14,_0x4454b5[_0x9549('0xd')][_0x9549('0x10')]);return _0x38433b(_0x4454b5[_0x9549('0xd')][_0x9549('0x10')]);}logger[_0x9549('0xd')](_0x9549('0xf'),_0x287e14,_0x4454b5['error']['message']);return _0x23369b(_0x4454b5[_0x9549('0xd')][_0x9549('0x10')]);}else{logger[_0x9549('0xa')](_0x9549('0xf'),_0x287e14,'request\x20sent');_0x23369b(_0x4454b5[_0x9549('0x11')]['message']);}})[_0x9549('0x12')](function(_0x43188c){logger[_0x9549('0xd')](_0x9549('0xf'),_0x287e14,_0x43188c);_0x38433b(_0x43188c);});});}exports[_0x9549('0x13')]=function(_0x1e2985){var _0x572c73=this;return new Promise(function(_0x12d1a7,_0x38aeb0){return db[_0x9549('0x14')][_0x9549('0x15')]({'raw':_0x1e2985['options']?_0x1e2985[_0x9549('0x16')][_0x9549('0x17')]===undefined?!![]:![]:!![],'where':_0x1e2985[_0x9549('0x16')]?_0x1e2985[_0x9549('0x16')][_0x9549('0x18')]||null:null,'attributes':_0x1e2985[_0x9549('0x16')]?_0x1e2985[_0x9549('0x16')][_0x9549('0x19')]||null:null,'limit':_0x1e2985['options']?_0x1e2985[_0x9549('0x16')][_0x9549('0x1a')]||null:null,'include':_0x1e2985[_0x9549('0x16')]?_0x1e2985[_0x9549('0x16')]['include']?_[_0x9549('0x1b')](_0x1e2985['options'][_0x9549('0x1c')],function(_0x5d280a){return{'model':db[_0x5d280a[_0x9549('0x1d')]],'as':_0x5d280a['as'],'attributes':_0x5d280a[_0x9549('0x19')],'include':_0x5d280a['include']?_[_0x9549('0x1b')](_0x5d280a[_0x9549('0x1c')],function(_0x3fa044){return{'model':db[_0x3fa044[_0x9549('0x1d')]],'as':_0x3fa044['as'],'attributes':_0x3fa044['attributes'],'include':_0x3fa044[_0x9549('0x1c')]?_[_0x9549('0x1b')](_0x3fa044[_0x9549('0x1c')],function(_0x3dc42d){return{'model':db[_0x3dc42d[_0x9549('0x1d')]],'as':_0x3dc42d['as'],'attributes':_0x3dc42d[_0x9549('0x19')]};}):[]};}):[]};}):[]:[]})[_0x9549('0x9')](function(_0x326eb5){logger[_0x9549('0xa')](_0x9549('0x13'),_0x1e2985);logger[_0x9549('0xb')](_0x9549('0x13'),_0x1e2985,JSON[_0x9549('0x1e')](_0x326eb5));_0x12d1a7(_0x326eb5);})['catch'](function(_0x1ffc16){logger['error'](_0x9549('0x13'),_0x1ffc16[_0x9549('0x10')],_0x1e2985);_0x38aeb0(_0x572c73['error'](0x1f4,_0x1ffc16[_0x9549('0x10')]));});});};exports[_0x9549('0x1f')]=function(_0x14dae2){var _0x3f60da=this;return new Promise(function(_0x120047,_0x5d31cd){return db[_0x9549('0x14')][_0x9549('0x20')]({'raw':_0x14dae2[_0x9549('0x16')]?_0x14dae2[_0x9549('0x16')][_0x9549('0x17')]===undefined?!![]:![]:!![],'where':_0x14dae2[_0x9549('0x16')]?_0x14dae2[_0x9549('0x16')][_0x9549('0x18')]||null:null,'attributes':_0x14dae2[_0x9549('0x16')]?_0x14dae2['options']['attributes']||null:null,'include':_0x14dae2[_0x9549('0x16')]?_0x14dae2[_0x9549('0x16')][_0x9549('0x1c')]?_[_0x9549('0x1b')](_0x14dae2['options'][_0x9549('0x1c')],function(_0x2b10a0){return{'model':db[_0x2b10a0['model']],'as':_0x2b10a0['as'],'attributes':_0x2b10a0[_0x9549('0x19')],'include':_0x2b10a0[_0x9549('0x1c')]?_[_0x9549('0x1b')](_0x2b10a0[_0x9549('0x1c')],function(_0x532687){return{'model':db[_0x532687[_0x9549('0x1d')]],'as':_0x532687['as'],'attributes':_0x532687[_0x9549('0x19')],'include':_0x532687[_0x9549('0x1c')]?_['map'](_0x532687[_0x9549('0x1c')],function(_0x6943a){return{'model':db[_0x6943a['model']],'as':_0x6943a['as'],'attributes':_0x6943a[_0x9549('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xea3a49){logger['info'](_0x9549('0x1f'),_0x14dae2);logger[_0x9549('0xb')](_0x9549('0x1f'),_0x14dae2,JSON['stringify'](_0xea3a49));_0x120047(_0xea3a49);})['catch'](function(_0x125d76){logger[_0x9549('0xd')](_0x9549('0x1f'),_0x125d76[_0x9549('0x10')],_0x14dae2);_0x5d31cd(_0x3f60da[_0x9549('0xd')](0x1f4,_0x125d76[_0x9549('0x10')]));});});};