Built motion from commit 3d3e98f2.|2.6.29
[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 _0x8f35=['GetDynamics365Account','Dynamics365Account','options','raw','where','attributes','limit','include','map','model','ShowDynamics365Account','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','Dynamics365Account,\x20%s,\x20%s','request\x20sent','debug','Dynamics365Account,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','catch'];(function(_0x4a86d0,_0x3fa6ab){var _0x26dd24=function(_0x375512){while(--_0x375512){_0x4a86d0['push'](_0x4a86d0['shift']());}};_0x26dd24(++_0x3fa6ab);}(_0x8f35,0x107));var _0x58f3=function(_0x5ddaac,_0x2697a8){_0x5ddaac=_0x5ddaac-0x0;var _0x2a9c58=_0x8f35[_0x5ddaac];return _0x2a9c58;};'use strict';var _=require(_0x58f3('0x0'));var util=require(_0x58f3('0x1'));var moment=require('moment');var BPromise=require(_0x58f3('0x2'));var rs=require(_0x58f3('0x3'));var fs=require('fs');var Redis=require(_0x58f3('0x4'));var db=require(_0x58f3('0x5'))['db'];var utils=require(_0x58f3('0x6'));var logger=require(_0x58f3('0x7'))(_0x58f3('0x8'));var config=require(_0x58f3('0x9'));var jayson=require(_0x58f3('0xa'));var client=jayson[_0x58f3('0xb')][_0x58f3('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x4ccd9b,_0x1df835,_0x2052f1){return new BPromise(function(_0x4ab487,_0x4c941d){return client[_0x58f3('0xd')](_0x4ccd9b,_0x2052f1)[_0x58f3('0xe')](function(_0x1b4286){logger['info'](_0x58f3('0xf'),_0x1df835,_0x58f3('0x10'));logger[_0x58f3('0x11')](_0x58f3('0x12'),_0x1df835,'request\x20sent',JSON[_0x58f3('0x13')](_0x1b4286));if(_0x1b4286[_0x58f3('0x14')]){if(_0x1b4286[_0x58f3('0x14')]['code']===0x1f4){logger[_0x58f3('0x14')](_0x58f3('0xf'),_0x1df835,_0x1b4286[_0x58f3('0x14')]['message']);return _0x4c941d(_0x1b4286[_0x58f3('0x14')][_0x58f3('0x15')]);}logger[_0x58f3('0x14')](_0x58f3('0xf'),_0x1df835,_0x1b4286[_0x58f3('0x14')][_0x58f3('0x15')]);return _0x4ab487(_0x1b4286[_0x58f3('0x14')]['message']);}else{logger[_0x58f3('0x16')](_0x58f3('0xf'),_0x1df835,_0x58f3('0x10'));_0x4ab487(_0x1b4286[_0x58f3('0x17')]['message']);}})[_0x58f3('0x18')](function(_0xae31ec){logger['error']('Dynamics365Account,\x20%s,\x20%s',_0x1df835,_0xae31ec);_0x4c941d(_0xae31ec);});});}exports[_0x58f3('0x19')]=function(_0x510d44){var _0x391c4a=this;return new Promise(function(_0x51fc81,_0x186712){return db[_0x58f3('0x1a')]['findAll']({'raw':_0x510d44[_0x58f3('0x1b')]?_0x510d44[_0x58f3('0x1b')][_0x58f3('0x1c')]===undefined?!![]:![]:!![],'where':_0x510d44[_0x58f3('0x1b')]?_0x510d44['options'][_0x58f3('0x1d')]||null:null,'attributes':_0x510d44['options']?_0x510d44[_0x58f3('0x1b')][_0x58f3('0x1e')]||null:null,'limit':_0x510d44[_0x58f3('0x1b')]?_0x510d44[_0x58f3('0x1b')][_0x58f3('0x1f')]||null:null,'include':_0x510d44[_0x58f3('0x1b')]?_0x510d44[_0x58f3('0x1b')][_0x58f3('0x20')]?_[_0x58f3('0x21')](_0x510d44[_0x58f3('0x1b')][_0x58f3('0x20')],function(_0x2e8e4b){return{'model':db[_0x2e8e4b[_0x58f3('0x22')]],'as':_0x2e8e4b['as'],'attributes':_0x2e8e4b[_0x58f3('0x1e')],'include':_0x2e8e4b[_0x58f3('0x20')]?_[_0x58f3('0x21')](_0x2e8e4b[_0x58f3('0x20')],function(_0x4e95c0){return{'model':db[_0x4e95c0['model']],'as':_0x4e95c0['as'],'attributes':_0x4e95c0[_0x58f3('0x1e')],'include':_0x4e95c0[_0x58f3('0x20')]?_['map'](_0x4e95c0[_0x58f3('0x20')],function(_0xf92bcd){return{'model':db[_0xf92bcd['model']],'as':_0xf92bcd['as'],'attributes':_0xf92bcd[_0x58f3('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x58f3('0xe')](function(_0x420172){logger[_0x58f3('0x16')](_0x58f3('0x19'),_0x510d44);logger['debug'](_0x58f3('0x19'),_0x510d44,JSON[_0x58f3('0x13')](_0x420172));_0x51fc81(_0x420172);})[_0x58f3('0x18')](function(_0x4a3f3a){logger[_0x58f3('0x14')](_0x58f3('0x19'),_0x4a3f3a['message'],_0x510d44);_0x186712(_0x391c4a[_0x58f3('0x14')](0x1f4,_0x4a3f3a['message']));});});};exports['ShowDynamics365Account']=function(_0x46fb2f){var _0x23474b=this;return new Promise(function(_0x51399f,_0x123a07){return db[_0x58f3('0x1a')]['find']({'raw':_0x46fb2f[_0x58f3('0x1b')]?_0x46fb2f[_0x58f3('0x1b')][_0x58f3('0x1c')]===undefined?!![]:![]:!![],'where':_0x46fb2f[_0x58f3('0x1b')]?_0x46fb2f['options'][_0x58f3('0x1d')]||null:null,'attributes':_0x46fb2f[_0x58f3('0x1b')]?_0x46fb2f[_0x58f3('0x1b')][_0x58f3('0x1e')]||null:null,'include':_0x46fb2f['options']?_0x46fb2f[_0x58f3('0x1b')][_0x58f3('0x20')]?_[_0x58f3('0x21')](_0x46fb2f[_0x58f3('0x1b')][_0x58f3('0x20')],function(_0x4876d8){return{'model':db[_0x4876d8[_0x58f3('0x22')]],'as':_0x4876d8['as'],'attributes':_0x4876d8[_0x58f3('0x1e')],'include':_0x4876d8[_0x58f3('0x20')]?_[_0x58f3('0x21')](_0x4876d8[_0x58f3('0x20')],function(_0x2736b7){return{'model':db[_0x2736b7[_0x58f3('0x22')]],'as':_0x2736b7['as'],'attributes':_0x2736b7[_0x58f3('0x1e')],'include':_0x2736b7[_0x58f3('0x20')]?_[_0x58f3('0x21')](_0x2736b7[_0x58f3('0x20')],function(_0x5af5af){return{'model':db[_0x5af5af[_0x58f3('0x22')]],'as':_0x5af5af['as'],'attributes':_0x5af5af['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x543198){logger[_0x58f3('0x16')](_0x58f3('0x23'),_0x46fb2f);logger[_0x58f3('0x11')](_0x58f3('0x23'),_0x46fb2f,JSON['stringify'](_0x543198));_0x51399f(_0x543198);})[_0x58f3('0x18')](function(_0x4e62bf){logger[_0x58f3('0x14')]('ShowDynamics365Account',_0x4e62bf[_0x58f3('0x15')],_0x46fb2f);_0x123a07(_0x23474b[_0x58f3('0x14')](0x1f4,_0x4e62bf['message']));});});};