8da56a8bd48c1ca7ecf9d2f20f28dcefcc96a41b
[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 _0x2678=['attributes','limit','include','map','model','GetDynamics365Account','stringify','catch','ShowDynamics365Account','util','moment','bluebird','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','then','Dynamics365Account,\x20%s,\x20%s','request\x20sent','debug','Dynamics365Account,\x20%s,\x20%s,\x20%s','error','code','message','info','findAll','options','raw','where'];(function(_0x340a34,_0x1fe485){var _0x3dd990=function(_0x5262b0){while(--_0x5262b0){_0x340a34['push'](_0x340a34['shift']());}};_0x3dd990(++_0x1fe485);}(_0x2678,0x1bb));var _0x8267=function(_0x12cbdd,_0x4ee21b){_0x12cbdd=_0x12cbdd-0x0;var _0x3bde34=_0x2678[_0x12cbdd];return _0x3bde34;};'use strict';var _=require('lodash');var util=require(_0x8267('0x0'));var moment=require(_0x8267('0x1'));var BPromise=require(_0x8267('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x8267('0x3'));var logger=require(_0x8267('0x4'))(_0x8267('0x5'));var config=require('../../config/environment');var jayson=require(_0x8267('0x6'));var client=jayson[_0x8267('0x7')][_0x8267('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x3e6635,_0x264d94,_0x3f30c2){return new BPromise(function(_0x2ac4ad,_0x2bbb0d){return client['request'](_0x3e6635,_0x3f30c2)[_0x8267('0x9')](function(_0x2f7832){logger['info'](_0x8267('0xa'),_0x264d94,_0x8267('0xb'));logger[_0x8267('0xc')](_0x8267('0xd'),_0x264d94,_0x8267('0xb'),JSON['stringify'](_0x2f7832));if(_0x2f7832[_0x8267('0xe')]){if(_0x2f7832[_0x8267('0xe')][_0x8267('0xf')]===0x1f4){logger[_0x8267('0xe')](_0x8267('0xa'),_0x264d94,_0x2f7832[_0x8267('0xe')][_0x8267('0x10')]);return _0x2bbb0d(_0x2f7832[_0x8267('0xe')][_0x8267('0x10')]);}logger[_0x8267('0xe')](_0x8267('0xa'),_0x264d94,_0x2f7832['error'][_0x8267('0x10')]);return _0x2ac4ad(_0x2f7832['error'][_0x8267('0x10')]);}else{logger[_0x8267('0x11')](_0x8267('0xa'),_0x264d94,_0x8267('0xb'));_0x2ac4ad(_0x2f7832['result'][_0x8267('0x10')]);}})['catch'](function(_0x3d2c1e){logger[_0x8267('0xe')]('Dynamics365Account,\x20%s,\x20%s',_0x264d94,_0x3d2c1e);_0x2bbb0d(_0x3d2c1e);});});}exports['GetDynamics365Account']=function(_0x2577a5){var _0x39f8c8=this;return new Promise(function(_0x1bce2d,_0x312166){return db['Dynamics365Account'][_0x8267('0x12')]({'raw':_0x2577a5['options']?_0x2577a5[_0x8267('0x13')][_0x8267('0x14')]===undefined?!![]:![]:!![],'where':_0x2577a5[_0x8267('0x13')]?_0x2577a5['options'][_0x8267('0x15')]||null:null,'attributes':_0x2577a5[_0x8267('0x13')]?_0x2577a5[_0x8267('0x13')][_0x8267('0x16')]||null:null,'limit':_0x2577a5[_0x8267('0x13')]?_0x2577a5[_0x8267('0x13')][_0x8267('0x17')]||null:null,'include':_0x2577a5['options']?_0x2577a5['options'][_0x8267('0x18')]?_[_0x8267('0x19')](_0x2577a5[_0x8267('0x13')][_0x8267('0x18')],function(_0x4426ca){return{'model':db[_0x4426ca[_0x8267('0x1a')]],'as':_0x4426ca['as'],'attributes':_0x4426ca['attributes'],'include':_0x4426ca[_0x8267('0x18')]?_[_0x8267('0x19')](_0x4426ca[_0x8267('0x18')],function(_0x2903bb){return{'model':db[_0x2903bb[_0x8267('0x1a')]],'as':_0x2903bb['as'],'attributes':_0x2903bb['attributes'],'include':_0x2903bb[_0x8267('0x18')]?_[_0x8267('0x19')](_0x2903bb[_0x8267('0x18')],function(_0xb55ec0){return{'model':db[_0xb55ec0[_0x8267('0x1a')]],'as':_0xb55ec0['as'],'attributes':_0xb55ec0[_0x8267('0x16')]};}):[]};}):[]};}):[]:[]})[_0x8267('0x9')](function(_0x59cee3){logger[_0x8267('0x11')](_0x8267('0x1b'),_0x2577a5);logger[_0x8267('0xc')](_0x8267('0x1b'),_0x2577a5,JSON[_0x8267('0x1c')](_0x59cee3));_0x1bce2d(_0x59cee3);})[_0x8267('0x1d')](function(_0x2d75e1){logger[_0x8267('0xe')](_0x8267('0x1b'),_0x2d75e1[_0x8267('0x10')],_0x2577a5);_0x312166(_0x39f8c8[_0x8267('0xe')](0x1f4,_0x2d75e1['message']));});});};exports[_0x8267('0x1e')]=function(_0x4f7377){var _0x1e976d=this;return new Promise(function(_0x4f4501,_0x5001d0){return db['Dynamics365Account']['find']({'raw':_0x4f7377['options']?_0x4f7377[_0x8267('0x13')][_0x8267('0x14')]===undefined?!![]:![]:!![],'where':_0x4f7377['options']?_0x4f7377[_0x8267('0x13')][_0x8267('0x15')]||null:null,'attributes':_0x4f7377['options']?_0x4f7377[_0x8267('0x13')][_0x8267('0x16')]||null:null,'include':_0x4f7377[_0x8267('0x13')]?_0x4f7377[_0x8267('0x13')]['include']?_[_0x8267('0x19')](_0x4f7377[_0x8267('0x13')][_0x8267('0x18')],function(_0x54dabe){return{'model':db[_0x54dabe[_0x8267('0x1a')]],'as':_0x54dabe['as'],'attributes':_0x54dabe[_0x8267('0x16')],'include':_0x54dabe[_0x8267('0x18')]?_[_0x8267('0x19')](_0x54dabe[_0x8267('0x18')],function(_0x26955b){return{'model':db[_0x26955b['model']],'as':_0x26955b['as'],'attributes':_0x26955b[_0x8267('0x16')],'include':_0x26955b[_0x8267('0x18')]?_[_0x8267('0x19')](_0x26955b[_0x8267('0x18')],function(_0x4b975f){return{'model':db[_0x4b975f[_0x8267('0x1a')]],'as':_0x4b975f['as'],'attributes':_0x4b975f[_0x8267('0x16')]};}):[]};}):[]};}):[]:[]})[_0x8267('0x9')](function(_0x39d957){logger[_0x8267('0x11')](_0x8267('0x1e'),_0x4f7377);logger[_0x8267('0xc')]('ShowDynamics365Account',_0x4f7377,JSON[_0x8267('0x1c')](_0x39d957));_0x4f4501(_0x39d957);})[_0x8267('0x1d')](function(_0xa87476){logger['error'](_0x8267('0x1e'),_0xa87476[_0x8267('0x10')],_0x4f7377);_0x5001d0(_0x1e976d[_0x8267('0xe')](0x1f4,_0xa87476[_0x8267('0x10')]));});});};