9699510da281ecdb711d8c5732ee0b8d289885a5
[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 _0x19fb=['model','GetDynamics365Account','find','raw','ShowDynamics365Account','lodash','util','moment','bluebird','randomstring','ioredis','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then','Dynamics365Account,\x20%s,\x20%s','request\x20sent','debug','Dynamics365Account,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','Dynamics365Account','options','where','attributes','limit','include','map'];(function(_0x4cc926,_0x436b0b){var _0x24121e=function(_0x39965e){while(--_0x39965e){_0x4cc926['push'](_0x4cc926['shift']());}};_0x24121e(++_0x436b0b);}(_0x19fb,0xdd));var _0xb19f=function(_0x397397,_0x28d05b){_0x397397=_0x397397-0x0;var _0x5bbbc3=_0x19fb[_0x397397];return _0x5bbbc3;};'use strict';var _=require(_0xb19f('0x0'));var util=require(_0xb19f('0x1'));var moment=require(_0xb19f('0x2'));var BPromise=require(_0xb19f('0x3'));var rs=require(_0xb19f('0x4'));var fs=require('fs');var Redis=require(_0xb19f('0x5'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xb19f('0x6'))(_0xb19f('0x7'));var config=require(_0xb19f('0x8'));var jayson=require(_0xb19f('0x9'));var client=jayson[_0xb19f('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2aab5c,_0x34597a,_0x3feb03){return new BPromise(function(_0x2c70a2,_0x8c9198){return client[_0xb19f('0xb')](_0x2aab5c,_0x3feb03)[_0xb19f('0xc')](function(_0x111431){logger['info'](_0xb19f('0xd'),_0x34597a,_0xb19f('0xe'));logger[_0xb19f('0xf')](_0xb19f('0x10'),_0x34597a,_0xb19f('0xe'),JSON[_0xb19f('0x11')](_0x111431));if(_0x111431[_0xb19f('0x12')]){if(_0x111431[_0xb19f('0x12')][_0xb19f('0x13')]===0x1f4){logger[_0xb19f('0x12')](_0xb19f('0xd'),_0x34597a,_0x111431[_0xb19f('0x12')][_0xb19f('0x14')]);return _0x8c9198(_0x111431[_0xb19f('0x12')][_0xb19f('0x14')]);}logger['error'](_0xb19f('0xd'),_0x34597a,_0x111431[_0xb19f('0x12')][_0xb19f('0x14')]);return _0x2c70a2(_0x111431['error'][_0xb19f('0x14')]);}else{logger[_0xb19f('0x15')](_0xb19f('0xd'),_0x34597a,'request\x20sent');_0x2c70a2(_0x111431[_0xb19f('0x16')][_0xb19f('0x14')]);}})[_0xb19f('0x17')](function(_0x5cdbf5){logger[_0xb19f('0x12')]('Dynamics365Account,\x20%s,\x20%s',_0x34597a,_0x5cdbf5);_0x8c9198(_0x5cdbf5);});});}exports['GetDynamics365Account']=function(_0x5b52d9){var _0x358180=this;return new Promise(function(_0x3b4367,_0x1dc030){return db[_0xb19f('0x18')]['findAll']({'raw':_0x5b52d9[_0xb19f('0x19')]?_0x5b52d9[_0xb19f('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x5b52d9[_0xb19f('0x19')]?_0x5b52d9['options'][_0xb19f('0x1a')]||null:null,'attributes':_0x5b52d9[_0xb19f('0x19')]?_0x5b52d9[_0xb19f('0x19')][_0xb19f('0x1b')]||null:null,'limit':_0x5b52d9[_0xb19f('0x19')]?_0x5b52d9[_0xb19f('0x19')][_0xb19f('0x1c')]||null:null,'include':_0x5b52d9['options']?_0x5b52d9[_0xb19f('0x19')][_0xb19f('0x1d')]?_[_0xb19f('0x1e')](_0x5b52d9[_0xb19f('0x19')]['include'],function(_0x25fbdc){return{'model':db[_0x25fbdc[_0xb19f('0x1f')]],'as':_0x25fbdc['as'],'attributes':_0x25fbdc[_0xb19f('0x1b')],'include':_0x25fbdc[_0xb19f('0x1d')]?_[_0xb19f('0x1e')](_0x25fbdc[_0xb19f('0x1d')],function(_0x28e0ad){return{'model':db[_0x28e0ad[_0xb19f('0x1f')]],'as':_0x28e0ad['as'],'attributes':_0x28e0ad[_0xb19f('0x1b')],'include':_0x28e0ad[_0xb19f('0x1d')]?_[_0xb19f('0x1e')](_0x28e0ad['include'],function(_0x3e1365){return{'model':db[_0x3e1365[_0xb19f('0x1f')]],'as':_0x3e1365['as'],'attributes':_0x3e1365['attributes']};}):[]};}):[]};}):[]:[]})[_0xb19f('0xc')](function(_0x43de02){logger['info']('GetDynamics365Account',_0x5b52d9);logger[_0xb19f('0xf')](_0xb19f('0x20'),_0x5b52d9,JSON[_0xb19f('0x11')](_0x43de02));_0x3b4367(_0x43de02);})[_0xb19f('0x17')](function(_0x5e479a){logger['error']('GetDynamics365Account',_0x5e479a[_0xb19f('0x14')],_0x5b52d9);_0x1dc030(_0x358180['error'](0x1f4,_0x5e479a['message']));});});};exports['ShowDynamics365Account']=function(_0xeac9a3){var _0xac9814=this;return new Promise(function(_0x10d949,_0x1131f6){return db[_0xb19f('0x18')][_0xb19f('0x21')]({'raw':_0xeac9a3['options']?_0xeac9a3[_0xb19f('0x19')][_0xb19f('0x22')]===undefined?!![]:![]:!![],'where':_0xeac9a3['options']?_0xeac9a3[_0xb19f('0x19')][_0xb19f('0x1a')]||null:null,'attributes':_0xeac9a3[_0xb19f('0x19')]?_0xeac9a3[_0xb19f('0x19')][_0xb19f('0x1b')]||null:null,'include':_0xeac9a3[_0xb19f('0x19')]?_0xeac9a3['options'][_0xb19f('0x1d')]?_[_0xb19f('0x1e')](_0xeac9a3[_0xb19f('0x19')][_0xb19f('0x1d')],function(_0x3211e1){return{'model':db[_0x3211e1[_0xb19f('0x1f')]],'as':_0x3211e1['as'],'attributes':_0x3211e1['attributes'],'include':_0x3211e1[_0xb19f('0x1d')]?_[_0xb19f('0x1e')](_0x3211e1[_0xb19f('0x1d')],function(_0x1e02c5){return{'model':db[_0x1e02c5[_0xb19f('0x1f')]],'as':_0x1e02c5['as'],'attributes':_0x1e02c5[_0xb19f('0x1b')],'include':_0x1e02c5['include']?_[_0xb19f('0x1e')](_0x1e02c5[_0xb19f('0x1d')],function(_0x862bf1){return{'model':db[_0x862bf1[_0xb19f('0x1f')]],'as':_0x862bf1['as'],'attributes':_0x862bf1[_0xb19f('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xb19f('0xc')](function(_0x1a6bbe){logger['info'](_0xb19f('0x23'),_0xeac9a3);logger['debug'](_0xb19f('0x23'),_0xeac9a3,JSON[_0xb19f('0x11')](_0x1a6bbe));_0x10d949(_0x1a6bbe);})[_0xb19f('0x17')](function(_0x4b3ca0){logger[_0xb19f('0x12')]('ShowDynamics365Account',_0x4b3ca0[_0xb19f('0x14')],_0xeac9a3);_0x1131f6(_0xac9814[_0xb19f('0x12')](0x1f4,_0x4b3ca0['message']));});});};