a59a3394b0e558cf5284a3596dc39d2cd79afbb6
[motion2.git] / server / api / intDynamics365Account / intDynamics365Account.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 _0xdade=['stringify','error','code','Dynamics365Account,\x20%s,\x20%s','message','result','catch','GetDynamics365Account','findAll','options','where','attributes','limit','model','include','map','debug','ShowDynamics365Account','Dynamics365Account','raw','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','then','info','request\x20sent','Dynamics365Account,\x20%s,\x20%s,\x20%s'];(function(_0x1e4bfe,_0x5396a4){var _0x421fa8=function(_0x318f7d){while(--_0x318f7d){_0x1e4bfe['push'](_0x1e4bfe['shift']());}};_0x421fa8(++_0x5396a4);}(_0xdade,0xe0));var _0xedad=function(_0x42d1f8,_0x22e529){_0x42d1f8=_0x42d1f8-0x0;var _0x40d234=_0xdade[_0x42d1f8];return _0x40d234;};'use strict';var _=require('lodash');var util=require(_0xedad('0x0'));var moment=require(_0xedad('0x1'));var BPromise=require(_0xedad('0x2'));var rs=require(_0xedad('0x3'));var fs=require('fs');var Redis=require(_0xedad('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xedad('0x5'));var logger=require(_0xedad('0x6'))(_0xedad('0x7'));var config=require(_0xedad('0x8'));var jayson=require(_0xedad('0x9'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x321f9b,_0x82ad24,_0x3a18b9){return new BPromise(function(_0x1f9ee9,_0x1837b5){return client['request'](_0x321f9b,_0x3a18b9)[_0xedad('0xa')](function(_0x3611b2){logger[_0xedad('0xb')]('Dynamics365Account,\x20%s,\x20%s',_0x82ad24,_0xedad('0xc'));logger['debug'](_0xedad('0xd'),_0x82ad24,_0xedad('0xc'),JSON[_0xedad('0xe')](_0x3611b2));if(_0x3611b2[_0xedad('0xf')]){if(_0x3611b2[_0xedad('0xf')][_0xedad('0x10')]===0x1f4){logger[_0xedad('0xf')](_0xedad('0x11'),_0x82ad24,_0x3611b2[_0xedad('0xf')][_0xedad('0x12')]);return _0x1837b5(_0x3611b2[_0xedad('0xf')][_0xedad('0x12')]);}logger[_0xedad('0xf')](_0xedad('0x11'),_0x82ad24,_0x3611b2['error']['message']);return _0x1f9ee9(_0x3611b2[_0xedad('0xf')]['message']);}else{logger[_0xedad('0xb')]('Dynamics365Account,\x20%s,\x20%s',_0x82ad24,_0xedad('0xc'));_0x1f9ee9(_0x3611b2[_0xedad('0x13')][_0xedad('0x12')]);}})[_0xedad('0x14')](function(_0x4965f6){logger[_0xedad('0xf')](_0xedad('0x11'),_0x82ad24,_0x4965f6);_0x1837b5(_0x4965f6);});});}exports[_0xedad('0x15')]=function(_0x548e48){var _0x48dfa6=this;return new Promise(function(_0x43d9bb,_0x20f794){return db['Dynamics365Account'][_0xedad('0x16')]({'raw':_0x548e48[_0xedad('0x17')]?_0x548e48[_0xedad('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x548e48[_0xedad('0x17')]?_0x548e48[_0xedad('0x17')][_0xedad('0x18')]||null:null,'attributes':_0x548e48[_0xedad('0x17')]?_0x548e48[_0xedad('0x17')][_0xedad('0x19')]||null:null,'limit':_0x548e48['options']?_0x548e48[_0xedad('0x17')][_0xedad('0x1a')]||null:null,'include':_0x548e48['options']?_0x548e48[_0xedad('0x17')]['include']?_['map'](_0x548e48['options']['include'],function(_0x230263){return{'model':db[_0x230263[_0xedad('0x1b')]],'as':_0x230263['as'],'attributes':_0x230263[_0xedad('0x19')],'include':_0x230263['include']?_['map'](_0x230263[_0xedad('0x1c')],function(_0x17f53c){return{'model':db[_0x17f53c[_0xedad('0x1b')]],'as':_0x17f53c['as'],'attributes':_0x17f53c[_0xedad('0x19')],'include':_0x17f53c['include']?_[_0xedad('0x1d')](_0x17f53c['include'],function(_0x5cb637){return{'model':db[_0x5cb637[_0xedad('0x1b')]],'as':_0x5cb637['as'],'attributes':_0x5cb637['attributes']};}):[]};}):[]};}):[]:[]})[_0xedad('0xa')](function(_0xb47d9){logger[_0xedad('0xb')](_0xedad('0x15'),_0x548e48);logger[_0xedad('0x1e')]('GetDynamics365Account',_0x548e48,JSON[_0xedad('0xe')](_0xb47d9));_0x43d9bb(_0xb47d9);})[_0xedad('0x14')](function(_0x4189ae){logger['error']('GetDynamics365Account',_0x4189ae[_0xedad('0x12')],_0x548e48);_0x20f794(_0x48dfa6[_0xedad('0xf')](0x1f4,_0x4189ae[_0xedad('0x12')]));});});};exports[_0xedad('0x1f')]=function(_0x150315){var _0xd80a8=this;return new Promise(function(_0x197ee3,_0x4f59ba){return db[_0xedad('0x20')]['find']({'raw':_0x150315[_0xedad('0x17')]?_0x150315[_0xedad('0x17')][_0xedad('0x21')]===undefined?!![]:![]:!![],'where':_0x150315[_0xedad('0x17')]?_0x150315['options'][_0xedad('0x18')]||null:null,'attributes':_0x150315[_0xedad('0x17')]?_0x150315['options'][_0xedad('0x19')]||null:null,'include':_0x150315[_0xedad('0x17')]?_0x150315['options'][_0xedad('0x1c')]?_[_0xedad('0x1d')](_0x150315[_0xedad('0x17')][_0xedad('0x1c')],function(_0x128a20){return{'model':db[_0x128a20[_0xedad('0x1b')]],'as':_0x128a20['as'],'attributes':_0x128a20[_0xedad('0x19')],'include':_0x128a20['include']?_['map'](_0x128a20[_0xedad('0x1c')],function(_0x5bc970){return{'model':db[_0x5bc970[_0xedad('0x1b')]],'as':_0x5bc970['as'],'attributes':_0x5bc970[_0xedad('0x19')],'include':_0x5bc970[_0xedad('0x1c')]?_[_0xedad('0x1d')](_0x5bc970['include'],function(_0x3b82f6){return{'model':db[_0x3b82f6[_0xedad('0x1b')]],'as':_0x3b82f6['as'],'attributes':_0x3b82f6[_0xedad('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x339563){logger[_0xedad('0xb')](_0xedad('0x1f'),_0x150315);logger[_0xedad('0x1e')](_0xedad('0x1f'),_0x150315,JSON[_0xedad('0xe')](_0x339563));_0x197ee3(_0x339563);})[_0xedad('0x14')](function(_0x2a0ad6){logger[_0xedad('0xf')](_0xedad('0x1f'),_0x2a0ad6['message'],_0x150315);_0x4f59ba(_0xd80a8['error'](0x1f4,_0x2a0ad6[_0xedad('0x12')]));});});};