582f3872fc77d4a35a65a5325eaf7e3e459ea3ee
[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 _0xdded=['error','code','message','info','GetDynamics365Account','findAll','options','where','attributes','limit','include','map','model','then','catch','ShowDynamics365Account','Dynamics365Account','find','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','Dynamics365Account,\x20%s,\x20%s','debug','request\x20sent','stringify'];(function(_0x32fb31,_0x56f8c8){var _0x489262=function(_0x3dadf1){while(--_0x3dadf1){_0x32fb31['push'](_0x32fb31['shift']());}};_0x489262(++_0x56f8c8);}(_0xdded,0x17a));var _0xddde=function(_0x5ced85,_0x31f067){_0x5ced85=_0x5ced85-0x0;var _0x20fde0=_0xdded[_0x5ced85];return _0x20fde0;};'use strict';var _=require(_0xddde('0x0'));var util=require(_0xddde('0x1'));var moment=require(_0xddde('0x2'));var BPromise=require(_0xddde('0x3'));var rs=require(_0xddde('0x4'));var fs=require('fs');var Redis=require(_0xddde('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xddde('0x6'));var logger=require(_0xddde('0x7'))(_0xddde('0x8'));var config=require(_0xddde('0x9'));var jayson=require(_0xddde('0xa'));var client=jayson[_0xddde('0xb')][_0xddde('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x3cea18,_0x516eb5,_0x18d8b8){return new BPromise(function(_0x3a5e8a,_0x5f1a34){return client[_0xddde('0xd')](_0x3cea18,_0x18d8b8)['then'](function(_0x48dd55){logger['info'](_0xddde('0xe'),_0x516eb5,'request\x20sent');logger[_0xddde('0xf')]('Dynamics365Account,\x20%s,\x20%s,\x20%s',_0x516eb5,_0xddde('0x10'),JSON[_0xddde('0x11')](_0x48dd55));if(_0x48dd55[_0xddde('0x12')]){if(_0x48dd55[_0xddde('0x12')][_0xddde('0x13')]===0x1f4){logger[_0xddde('0x12')](_0xddde('0xe'),_0x516eb5,_0x48dd55[_0xddde('0x12')]['message']);return _0x5f1a34(_0x48dd55[_0xddde('0x12')][_0xddde('0x14')]);}logger[_0xddde('0x12')](_0xddde('0xe'),_0x516eb5,_0x48dd55[_0xddde('0x12')][_0xddde('0x14')]);return _0x3a5e8a(_0x48dd55['error'][_0xddde('0x14')]);}else{logger[_0xddde('0x15')](_0xddde('0xe'),_0x516eb5,'request\x20sent');_0x3a5e8a(_0x48dd55['result'][_0xddde('0x14')]);}})['catch'](function(_0x30a9da){logger[_0xddde('0x12')](_0xddde('0xe'),_0x516eb5,_0x30a9da);_0x5f1a34(_0x30a9da);});});}exports[_0xddde('0x16')]=function(_0x2f0e58){var _0x55349b=this;return new Promise(function(_0x249f19,_0x129e3e){return db['Dynamics365Account'][_0xddde('0x17')]({'raw':_0x2f0e58[_0xddde('0x18')]?_0x2f0e58['options']['raw']===undefined?!![]:![]:!![],'where':_0x2f0e58[_0xddde('0x18')]?_0x2f0e58['options'][_0xddde('0x19')]||null:null,'attributes':_0x2f0e58['options']?_0x2f0e58[_0xddde('0x18')][_0xddde('0x1a')]||null:null,'limit':_0x2f0e58['options']?_0x2f0e58['options'][_0xddde('0x1b')]||null:null,'include':_0x2f0e58[_0xddde('0x18')]?_0x2f0e58[_0xddde('0x18')][_0xddde('0x1c')]?_[_0xddde('0x1d')](_0x2f0e58[_0xddde('0x18')][_0xddde('0x1c')],function(_0x56a33a){return{'model':db[_0x56a33a['model']],'as':_0x56a33a['as'],'attributes':_0x56a33a[_0xddde('0x1a')],'include':_0x56a33a[_0xddde('0x1c')]?_[_0xddde('0x1d')](_0x56a33a[_0xddde('0x1c')],function(_0xdb57ef){return{'model':db[_0xdb57ef['model']],'as':_0xdb57ef['as'],'attributes':_0xdb57ef[_0xddde('0x1a')],'include':_0xdb57ef[_0xddde('0x1c')]?_['map'](_0xdb57ef['include'],function(_0xa60e85){return{'model':db[_0xa60e85[_0xddde('0x1e')]],'as':_0xa60e85['as'],'attributes':_0xa60e85['attributes']};}):[]};}):[]};}):[]:[]})[_0xddde('0x1f')](function(_0x45941e){logger['info'](_0xddde('0x16'),_0x2f0e58);logger[_0xddde('0xf')](_0xddde('0x16'),_0x2f0e58,JSON[_0xddde('0x11')](_0x45941e));_0x249f19(_0x45941e);})[_0xddde('0x20')](function(_0xb5d4b6){logger[_0xddde('0x12')](_0xddde('0x16'),_0xb5d4b6[_0xddde('0x14')],_0x2f0e58);_0x129e3e(_0x55349b[_0xddde('0x12')](0x1f4,_0xb5d4b6[_0xddde('0x14')]));});});};exports[_0xddde('0x21')]=function(_0xe3d006){var _0x718921=this;return new Promise(function(_0x5e04d6,_0x380acb){return db[_0xddde('0x22')][_0xddde('0x23')]({'raw':_0xe3d006[_0xddde('0x18')]?_0xe3d006[_0xddde('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0xe3d006['options']?_0xe3d006[_0xddde('0x18')][_0xddde('0x19')]||null:null,'attributes':_0xe3d006[_0xddde('0x18')]?_0xe3d006['options']['attributes']||null:null,'include':_0xe3d006[_0xddde('0x18')]?_0xe3d006[_0xddde('0x18')][_0xddde('0x1c')]?_[_0xddde('0x1d')](_0xe3d006['options'][_0xddde('0x1c')],function(_0x5d64cb){return{'model':db[_0x5d64cb[_0xddde('0x1e')]],'as':_0x5d64cb['as'],'attributes':_0x5d64cb[_0xddde('0x1a')],'include':_0x5d64cb[_0xddde('0x1c')]?_[_0xddde('0x1d')](_0x5d64cb[_0xddde('0x1c')],function(_0x2b2661){return{'model':db[_0x2b2661[_0xddde('0x1e')]],'as':_0x2b2661['as'],'attributes':_0x2b2661[_0xddde('0x1a')],'include':_0x2b2661[_0xddde('0x1c')]?_[_0xddde('0x1d')](_0x2b2661[_0xddde('0x1c')],function(_0x872116){return{'model':db[_0x872116['model']],'as':_0x872116['as'],'attributes':_0x872116[_0xddde('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xddde('0x1f')](function(_0x4c68ab){logger['info']('ShowDynamics365Account',_0xe3d006);logger[_0xddde('0xf')](_0xddde('0x21'),_0xe3d006,JSON[_0xddde('0x11')](_0x4c68ab));_0x5e04d6(_0x4c68ab);})[_0xddde('0x20')](function(_0x2825c6){logger[_0xddde('0x12')](_0xddde('0x21'),_0x2825c6['message'],_0xe3d006);_0x380acb(_0x718921['error'](0x1f4,_0x2825c6[_0xddde('0x14')]));});});};