e0156a2d58e8e32b6f31bf05a80db54aa04a9c78
[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 _0x48e3=['debug','stringify','error','code','message','ServicenowAccount,\x20%s,\x20%s','catch','GetServicenowAccount','ServicenowAccount','findAll','options','raw','where','limit','include','model','attributes','map','ShowServicenowAccount','find','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','http','request','then','info','request\x20sent'];(function(_0x5627e1,_0x1b2dbf){var _0x2f013f=function(_0x142015){while(--_0x142015){_0x5627e1['push'](_0x5627e1['shift']());}};_0x2f013f(++_0x1b2dbf);}(_0x48e3,0x114));var _0x348e=function(_0x3a24ac,_0x57f3d5){_0x3a24ac=_0x3a24ac-0x0;var _0x28b980=_0x48e3[_0x3a24ac];return _0x28b980;};'use strict';var _=require('lodash');var util=require(_0x348e('0x0'));var moment=require(_0x348e('0x1'));var BPromise=require(_0x348e('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x348e('0x3'))['db'];var utils=require(_0x348e('0x4'));var logger=require(_0x348e('0x5'))('rpc');var config=require(_0x348e('0x6'));var jayson=require('jayson/promise');var client=jayson['client'][_0x348e('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x23a145,_0xef382e,_0x16b59c){return new BPromise(function(_0x55f924,_0x4d7367){return client[_0x348e('0x8')](_0x23a145,_0x16b59c)[_0x348e('0x9')](function(_0x284554){logger[_0x348e('0xa')]('ServicenowAccount,\x20%s,\x20%s',_0xef382e,_0x348e('0xb'));logger[_0x348e('0xc')]('ServicenowAccount,\x20%s,\x20%s,\x20%s',_0xef382e,_0x348e('0xb'),JSON[_0x348e('0xd')](_0x284554));if(_0x284554[_0x348e('0xe')]){if(_0x284554[_0x348e('0xe')][_0x348e('0xf')]===0x1f4){logger[_0x348e('0xe')]('ServicenowAccount,\x20%s,\x20%s',_0xef382e,_0x284554[_0x348e('0xe')][_0x348e('0x10')]);return _0x4d7367(_0x284554[_0x348e('0xe')][_0x348e('0x10')]);}logger[_0x348e('0xe')](_0x348e('0x11'),_0xef382e,_0x284554['error'][_0x348e('0x10')]);return _0x55f924(_0x284554[_0x348e('0xe')][_0x348e('0x10')]);}else{logger['info']('ServicenowAccount,\x20%s,\x20%s',_0xef382e,'request\x20sent');_0x55f924(_0x284554['result'][_0x348e('0x10')]);}})[_0x348e('0x12')](function(_0x4076d9){logger['error'](_0x348e('0x11'),_0xef382e,_0x4076d9);_0x4d7367(_0x4076d9);});});}exports[_0x348e('0x13')]=function(_0x2af5de){var _0x16384a=this;return new Promise(function(_0x5ed10b,_0x5c20ee){return db[_0x348e('0x14')][_0x348e('0x15')]({'raw':_0x2af5de[_0x348e('0x16')]?_0x2af5de[_0x348e('0x16')][_0x348e('0x17')]===undefined?!![]:![]:!![],'where':_0x2af5de['options']?_0x2af5de['options'][_0x348e('0x18')]||null:null,'attributes':_0x2af5de[_0x348e('0x16')]?_0x2af5de['options']['attributes']||null:null,'limit':_0x2af5de[_0x348e('0x16')]?_0x2af5de[_0x348e('0x16')][_0x348e('0x19')]||null:null,'include':_0x2af5de['options']?_0x2af5de[_0x348e('0x16')][_0x348e('0x1a')]?_['map'](_0x2af5de[_0x348e('0x16')][_0x348e('0x1a')],function(_0x4ea56e){return{'model':db[_0x4ea56e[_0x348e('0x1b')]],'as':_0x4ea56e['as'],'attributes':_0x4ea56e[_0x348e('0x1c')],'include':_0x4ea56e[_0x348e('0x1a')]?_[_0x348e('0x1d')](_0x4ea56e[_0x348e('0x1a')],function(_0x557539){return{'model':db[_0x557539[_0x348e('0x1b')]],'as':_0x557539['as'],'attributes':_0x557539[_0x348e('0x1c')],'include':_0x557539[_0x348e('0x1a')]?_[_0x348e('0x1d')](_0x557539[_0x348e('0x1a')],function(_0x5efd8){return{'model':db[_0x5efd8[_0x348e('0x1b')]],'as':_0x5efd8['as'],'attributes':_0x5efd8['attributes']};}):[]};}):[]};}):[]:[]})[_0x348e('0x9')](function(_0x50a138){logger['info'](_0x348e('0x13'),_0x2af5de);logger[_0x348e('0xc')]('GetServicenowAccount',_0x2af5de,JSON[_0x348e('0xd')](_0x50a138));_0x5ed10b(_0x50a138);})[_0x348e('0x12')](function(_0x2d204b){logger[_0x348e('0xe')](_0x348e('0x13'),_0x2d204b['message'],_0x2af5de);_0x5c20ee(_0x16384a['error'](0x1f4,_0x2d204b[_0x348e('0x10')]));});});};exports[_0x348e('0x1e')]=function(_0x42ca27){var _0xe25b18=this;return new Promise(function(_0x4b2b94,_0x1dc25e){return db[_0x348e('0x14')][_0x348e('0x1f')]({'raw':_0x42ca27[_0x348e('0x16')]?_0x42ca27[_0x348e('0x16')][_0x348e('0x17')]===undefined?!![]:![]:!![],'where':_0x42ca27[_0x348e('0x16')]?_0x42ca27[_0x348e('0x16')][_0x348e('0x18')]||null:null,'attributes':_0x42ca27[_0x348e('0x16')]?_0x42ca27['options'][_0x348e('0x1c')]||null:null,'include':_0x42ca27['options']?_0x42ca27[_0x348e('0x16')][_0x348e('0x1a')]?_[_0x348e('0x1d')](_0x42ca27[_0x348e('0x16')][_0x348e('0x1a')],function(_0x21bd8f){return{'model':db[_0x21bd8f['model']],'as':_0x21bd8f['as'],'attributes':_0x21bd8f['attributes'],'include':_0x21bd8f[_0x348e('0x1a')]?_['map'](_0x21bd8f[_0x348e('0x1a')],function(_0x435d93){return{'model':db[_0x435d93[_0x348e('0x1b')]],'as':_0x435d93['as'],'attributes':_0x435d93['attributes'],'include':_0x435d93[_0x348e('0x1a')]?_[_0x348e('0x1d')](_0x435d93[_0x348e('0x1a')],function(_0x74ddad){return{'model':db[_0x74ddad[_0x348e('0x1b')]],'as':_0x74ddad['as'],'attributes':_0x74ddad['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x1be7c5){logger['info'](_0x348e('0x1e'),_0x42ca27);logger[_0x348e('0xc')]('ShowServicenowAccount',_0x42ca27,JSON[_0x348e('0xd')](_0x1be7c5));_0x4b2b94(_0x1be7c5);})[_0x348e('0x12')](function(_0x46cd35){logger[_0x348e('0xe')](_0x348e('0x1e'),_0x46cd35['message'],_0x42ca27);_0x1dc25e(_0xe25b18['error'](0x1f4,_0x46cd35[_0x348e('0x10')]));});});};