42fa7503383046aa894d76eb0765e13050169cc5
[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 _0x0386=['debug','Dynamics365Account,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','GetDynamics365Account','options','raw','where','attributes','limit','include','map','model','ShowDynamics365Account','Dynamics365Account','find','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','client','request','then','info','Dynamics365Account,\x20%s,\x20%s','request\x20sent'];(function(_0x22420f,_0x536255){var _0x4204b0=function(_0x4c3a14){while(--_0x4c3a14){_0x22420f['push'](_0x22420f['shift']());}};_0x4204b0(++_0x536255);}(_0x0386,0x1b7));var _0x6038=function(_0x1da5e9,_0x4f9a3a){_0x1da5e9=_0x1da5e9-0x0;var _0x1c62f8=_0x0386[_0x1da5e9];return _0x1c62f8;};'use strict';var _=require(_0x6038('0x0'));var util=require(_0x6038('0x1'));var moment=require(_0x6038('0x2'));var BPromise=require(_0x6038('0x3'));var rs=require(_0x6038('0x4'));var fs=require('fs');var Redis=require(_0x6038('0x5'));var db=require(_0x6038('0x6'))['db'];var utils=require(_0x6038('0x7'));var logger=require(_0x6038('0x8'))(_0x6038('0x9'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x6038('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x47b861,_0x54a2c3,_0x3a384d){return new BPromise(function(_0x57135b,_0x10d571){return client[_0x6038('0xb')](_0x47b861,_0x3a384d)[_0x6038('0xc')](function(_0x38ddac){logger[_0x6038('0xd')](_0x6038('0xe'),_0x54a2c3,_0x6038('0xf'));logger[_0x6038('0x10')](_0x6038('0x11'),_0x54a2c3,_0x6038('0xf'),JSON[_0x6038('0x12')](_0x38ddac));if(_0x38ddac[_0x6038('0x13')]){if(_0x38ddac[_0x6038('0x13')][_0x6038('0x14')]===0x1f4){logger[_0x6038('0x13')]('Dynamics365Account,\x20%s,\x20%s',_0x54a2c3,_0x38ddac[_0x6038('0x13')][_0x6038('0x15')]);return _0x10d571(_0x38ddac[_0x6038('0x13')][_0x6038('0x15')]);}logger['error'](_0x6038('0xe'),_0x54a2c3,_0x38ddac[_0x6038('0x13')][_0x6038('0x15')]);return _0x57135b(_0x38ddac[_0x6038('0x13')]['message']);}else{logger[_0x6038('0xd')]('Dynamics365Account,\x20%s,\x20%s',_0x54a2c3,_0x6038('0xf'));_0x57135b(_0x38ddac['result'][_0x6038('0x15')]);}})[_0x6038('0x16')](function(_0x250f46){logger[_0x6038('0x13')]('Dynamics365Account,\x20%s,\x20%s',_0x54a2c3,_0x250f46);_0x10d571(_0x250f46);});});}exports[_0x6038('0x17')]=function(_0x5745c3){var _0x458123=this;return new Promise(function(_0x3ff839,_0x3f08cf){return db['Dynamics365Account']['findAll']({'raw':_0x5745c3[_0x6038('0x18')]?_0x5745c3[_0x6038('0x18')][_0x6038('0x19')]===undefined?!![]:![]:!![],'where':_0x5745c3[_0x6038('0x18')]?_0x5745c3[_0x6038('0x18')][_0x6038('0x1a')]||null:null,'attributes':_0x5745c3['options']?_0x5745c3[_0x6038('0x18')][_0x6038('0x1b')]||null:null,'limit':_0x5745c3[_0x6038('0x18')]?_0x5745c3['options'][_0x6038('0x1c')]||null:null,'include':_0x5745c3['options']?_0x5745c3[_0x6038('0x18')][_0x6038('0x1d')]?_['map'](_0x5745c3['options']['include'],function(_0x4fae90){return{'model':db[_0x4fae90['model']],'as':_0x4fae90['as'],'attributes':_0x4fae90[_0x6038('0x1b')],'include':_0x4fae90[_0x6038('0x1d')]?_[_0x6038('0x1e')](_0x4fae90[_0x6038('0x1d')],function(_0x573215){return{'model':db[_0x573215['model']],'as':_0x573215['as'],'attributes':_0x573215[_0x6038('0x1b')],'include':_0x573215[_0x6038('0x1d')]?_['map'](_0x573215[_0x6038('0x1d')],function(_0xdd7637){return{'model':db[_0xdd7637[_0x6038('0x1f')]],'as':_0xdd7637['as'],'attributes':_0xdd7637['attributes']};}):[]};}):[]};}):[]:[]})[_0x6038('0xc')](function(_0x1f374c){logger[_0x6038('0xd')](_0x6038('0x17'),_0x5745c3);logger[_0x6038('0x10')](_0x6038('0x17'),_0x5745c3,JSON[_0x6038('0x12')](_0x1f374c));_0x3ff839(_0x1f374c);})[_0x6038('0x16')](function(_0xd31f23){logger[_0x6038('0x13')](_0x6038('0x17'),_0xd31f23['message'],_0x5745c3);_0x3f08cf(_0x458123[_0x6038('0x13')](0x1f4,_0xd31f23[_0x6038('0x15')]));});});};exports[_0x6038('0x20')]=function(_0x4d125d){var _0x248e22=this;return new Promise(function(_0x5a51bb,_0x33d97d){return db[_0x6038('0x21')][_0x6038('0x22')]({'raw':_0x4d125d[_0x6038('0x18')]?_0x4d125d['options'][_0x6038('0x19')]===undefined?!![]:![]:!![],'where':_0x4d125d[_0x6038('0x18')]?_0x4d125d[_0x6038('0x18')]['where']||null:null,'attributes':_0x4d125d['options']?_0x4d125d[_0x6038('0x18')][_0x6038('0x1b')]||null:null,'include':_0x4d125d[_0x6038('0x18')]?_0x4d125d['options'][_0x6038('0x1d')]?_[_0x6038('0x1e')](_0x4d125d[_0x6038('0x18')][_0x6038('0x1d')],function(_0x371da9){return{'model':db[_0x371da9[_0x6038('0x1f')]],'as':_0x371da9['as'],'attributes':_0x371da9[_0x6038('0x1b')],'include':_0x371da9['include']?_[_0x6038('0x1e')](_0x371da9[_0x6038('0x1d')],function(_0xa3d3bf){return{'model':db[_0xa3d3bf[_0x6038('0x1f')]],'as':_0xa3d3bf['as'],'attributes':_0xa3d3bf['attributes'],'include':_0xa3d3bf[_0x6038('0x1d')]?_['map'](_0xa3d3bf[_0x6038('0x1d')],function(_0x6c04d3){return{'model':db[_0x6c04d3[_0x6038('0x1f')]],'as':_0x6c04d3['as'],'attributes':_0x6c04d3['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x244109){logger[_0x6038('0xd')](_0x6038('0x20'),_0x4d125d);logger[_0x6038('0x10')](_0x6038('0x20'),_0x4d125d,JSON[_0x6038('0x12')](_0x244109));_0x5a51bb(_0x244109);})[_0x6038('0x16')](function(_0x55846a){logger[_0x6038('0x13')](_0x6038('0x20'),_0x55846a['message'],_0x4d125d);_0x33d97d(_0x248e22[_0x6038('0x13')](0x1f4,_0x55846a[_0x6038('0x15')]));});});};