Built motion from commit bab6f49e.|2.6.17
[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 _0xb263=['randomstring','../../config/utils','../../config/logger','rpc','client','request','info','ServicenowAccount,\x20%s,\x20%s','debug','ServicenowAccount,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','result','catch','GetServicenowAccount','ServicenowAccount','findAll','options','raw','attributes','include','map','model','stringify','ShowServicenowAccount','find','util','moment','bluebird'];(function(_0x26b5cb,_0x15f879){var _0x3b2277=function(_0x12fe27){while(--_0x12fe27){_0x26b5cb['push'](_0x26b5cb['shift']());}};_0x3b2277(++_0x15f879);}(_0xb263,0xb7));var _0x3b26=function(_0x4a442c,_0x85730f){_0x4a442c=_0x4a442c-0x0;var _0xef960f=_0xb263[_0x4a442c];return _0xef960f;};'use strict';var _=require('lodash');var util=require(_0x3b26('0x0'));var moment=require(_0x3b26('0x1'));var BPromise=require(_0x3b26('0x2'));var rs=require(_0x3b26('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x3b26('0x4'));var logger=require(_0x3b26('0x5'))(_0x3b26('0x6'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x3b26('0x7')]['http']({'port':0x232a});function respondWithRpcPromise(_0x1930fa,_0x4a90ef,_0x1e32e8){return new BPromise(function(_0x4dbc97,_0x5baf04){return client[_0x3b26('0x8')](_0x1930fa,_0x1e32e8)['then'](function(_0x45c026){logger[_0x3b26('0x9')](_0x3b26('0xa'),_0x4a90ef,'request\x20sent');logger[_0x3b26('0xb')](_0x3b26('0xc'),_0x4a90ef,_0x3b26('0xd'),JSON['stringify'](_0x45c026));if(_0x45c026[_0x3b26('0xe')]){if(_0x45c026[_0x3b26('0xe')][_0x3b26('0xf')]===0x1f4){logger['error']('ServicenowAccount,\x20%s,\x20%s',_0x4a90ef,_0x45c026['error'][_0x3b26('0x10')]);return _0x5baf04(_0x45c026[_0x3b26('0xe')][_0x3b26('0x10')]);}logger[_0x3b26('0xe')]('ServicenowAccount,\x20%s,\x20%s',_0x4a90ef,_0x45c026['error']['message']);return _0x4dbc97(_0x45c026[_0x3b26('0xe')][_0x3b26('0x10')]);}else{logger[_0x3b26('0x9')](_0x3b26('0xa'),_0x4a90ef,_0x3b26('0xd'));_0x4dbc97(_0x45c026[_0x3b26('0x11')][_0x3b26('0x10')]);}})[_0x3b26('0x12')](function(_0x2eff5e){logger[_0x3b26('0xe')]('ServicenowAccount,\x20%s,\x20%s',_0x4a90ef,_0x2eff5e);_0x5baf04(_0x2eff5e);});});}exports[_0x3b26('0x13')]=function(_0x227643){var _0x479a7e=this;return new Promise(function(_0x5d6b17,_0x40a611){return db[_0x3b26('0x14')][_0x3b26('0x15')]({'raw':_0x227643[_0x3b26('0x16')]?_0x227643[_0x3b26('0x16')][_0x3b26('0x17')]===undefined?!![]:![]:!![],'where':_0x227643['options']?_0x227643[_0x3b26('0x16')]['where']||null:null,'attributes':_0x227643[_0x3b26('0x16')]?_0x227643['options'][_0x3b26('0x18')]||null:null,'limit':_0x227643[_0x3b26('0x16')]?_0x227643[_0x3b26('0x16')]['limit']||null:null,'include':_0x227643[_0x3b26('0x16')]?_0x227643[_0x3b26('0x16')][_0x3b26('0x19')]?_[_0x3b26('0x1a')](_0x227643[_0x3b26('0x16')][_0x3b26('0x19')],function(_0x3d40aa){return{'model':db[_0x3d40aa[_0x3b26('0x1b')]],'as':_0x3d40aa['as'],'attributes':_0x3d40aa[_0x3b26('0x18')],'include':_0x3d40aa[_0x3b26('0x19')]?_[_0x3b26('0x1a')](_0x3d40aa['include'],function(_0x2d0221){return{'model':db[_0x2d0221[_0x3b26('0x1b')]],'as':_0x2d0221['as'],'attributes':_0x2d0221[_0x3b26('0x18')],'include':_0x2d0221[_0x3b26('0x19')]?_[_0x3b26('0x1a')](_0x2d0221[_0x3b26('0x19')],function(_0x2e0732){return{'model':db[_0x2e0732[_0x3b26('0x1b')]],'as':_0x2e0732['as'],'attributes':_0x2e0732[_0x3b26('0x18')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x51ea0d){logger[_0x3b26('0x9')](_0x3b26('0x13'),_0x227643);logger[_0x3b26('0xb')](_0x3b26('0x13'),_0x227643,JSON[_0x3b26('0x1c')](_0x51ea0d));_0x5d6b17(_0x51ea0d);})[_0x3b26('0x12')](function(_0x529270){logger['error'](_0x3b26('0x13'),_0x529270[_0x3b26('0x10')],_0x227643);_0x40a611(_0x479a7e[_0x3b26('0xe')](0x1f4,_0x529270[_0x3b26('0x10')]));});});};exports[_0x3b26('0x1d')]=function(_0x137c70){var _0x51da8c=this;return new Promise(function(_0x4df297,_0x1e87f9){return db[_0x3b26('0x14')][_0x3b26('0x1e')]({'raw':_0x137c70[_0x3b26('0x16')]?_0x137c70[_0x3b26('0x16')][_0x3b26('0x17')]===undefined?!![]:![]:!![],'where':_0x137c70['options']?_0x137c70[_0x3b26('0x16')]['where']||null:null,'attributes':_0x137c70[_0x3b26('0x16')]?_0x137c70[_0x3b26('0x16')]['attributes']||null:null,'include':_0x137c70[_0x3b26('0x16')]?_0x137c70['options']['include']?_[_0x3b26('0x1a')](_0x137c70[_0x3b26('0x16')]['include'],function(_0x489f3d){return{'model':db[_0x489f3d[_0x3b26('0x1b')]],'as':_0x489f3d['as'],'attributes':_0x489f3d[_0x3b26('0x18')],'include':_0x489f3d['include']?_['map'](_0x489f3d['include'],function(_0x2989f8){return{'model':db[_0x2989f8['model']],'as':_0x2989f8['as'],'attributes':_0x2989f8[_0x3b26('0x18')],'include':_0x2989f8[_0x3b26('0x19')]?_[_0x3b26('0x1a')](_0x2989f8[_0x3b26('0x19')],function(_0x1ad0a4){return{'model':db[_0x1ad0a4[_0x3b26('0x1b')]],'as':_0x1ad0a4['as'],'attributes':_0x1ad0a4[_0x3b26('0x18')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x26569f){logger['info'](_0x3b26('0x1d'),_0x137c70);logger[_0x3b26('0xb')](_0x3b26('0x1d'),_0x137c70,JSON[_0x3b26('0x1c')](_0x26569f));_0x4df297(_0x26569f);})['catch'](function(_0x261abb){logger['error'](_0x3b26('0x1d'),_0x261abb[_0x3b26('0x10')],_0x137c70);_0x1e87f9(_0x51da8c[_0x3b26('0xe')](0x1f4,_0x261abb[_0x3b26('0x10')]));});});};