Built motion from commit 19a84241.|2.5.34
[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 _0x9075=['include','model','map','GetDynamics365Account','debug','stringify','ShowDynamics365Account','Dynamics365Account','find','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','http','info','Dynamics365Account,\x20%s,\x20%s','Dynamics365Account,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','findAll','options','raw','where','attributes','limit'];(function(_0x41f10a,_0x58034a){var _0x79bc70=function(_0x3ae8b9){while(--_0x3ae8b9){_0x41f10a['push'](_0x41f10a['shift']());}};_0x79bc70(++_0x58034a);}(_0x9075,0x1d7));var _0x5907=function(_0x21aec3,_0x5c97e9){_0x21aec3=_0x21aec3-0x0;var _0x288bbc=_0x9075[_0x21aec3];return _0x288bbc;};'use strict';var _=require(_0x5907('0x0'));var util=require(_0x5907('0x1'));var moment=require(_0x5907('0x2'));var BPromise=require(_0x5907('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x5907('0x4'));var db=require(_0x5907('0x5'))['db'];var utils=require(_0x5907('0x6'));var logger=require(_0x5907('0x7'))(_0x5907('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0x5907('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x13d4f6,_0x2e057b,_0xfeeb44){return new BPromise(function(_0x34060b,_0x1e8798){return client['request'](_0x13d4f6,_0xfeeb44)['then'](function(_0x16362a){logger[_0x5907('0xa')](_0x5907('0xb'),_0x2e057b,'request\x20sent');logger['debug'](_0x5907('0xc'),_0x2e057b,'request\x20sent',JSON['stringify'](_0x16362a));if(_0x16362a[_0x5907('0xd')]){if(_0x16362a[_0x5907('0xd')][_0x5907('0xe')]===0x1f4){logger[_0x5907('0xd')](_0x5907('0xb'),_0x2e057b,_0x16362a[_0x5907('0xd')][_0x5907('0xf')]);return _0x1e8798(_0x16362a[_0x5907('0xd')]['message']);}logger[_0x5907('0xd')](_0x5907('0xb'),_0x2e057b,_0x16362a['error']['message']);return _0x34060b(_0x16362a[_0x5907('0xd')][_0x5907('0xf')]);}else{logger[_0x5907('0xa')](_0x5907('0xb'),_0x2e057b,'request\x20sent');_0x34060b(_0x16362a[_0x5907('0x10')][_0x5907('0xf')]);}})[_0x5907('0x11')](function(_0x1deac7){logger[_0x5907('0xd')](_0x5907('0xb'),_0x2e057b,_0x1deac7);_0x1e8798(_0x1deac7);});});}exports['GetDynamics365Account']=function(_0xaa74dc){var _0x381a7b=this;return new Promise(function(_0x4d2b0d,_0x268a0a){return db['Dynamics365Account'][_0x5907('0x12')]({'raw':_0xaa74dc[_0x5907('0x13')]?_0xaa74dc['options'][_0x5907('0x14')]===undefined?!![]:![]:!![],'where':_0xaa74dc[_0x5907('0x13')]?_0xaa74dc[_0x5907('0x13')][_0x5907('0x15')]||null:null,'attributes':_0xaa74dc[_0x5907('0x13')]?_0xaa74dc[_0x5907('0x13')][_0x5907('0x16')]||null:null,'limit':_0xaa74dc[_0x5907('0x13')]?_0xaa74dc['options'][_0x5907('0x17')]||null:null,'include':_0xaa74dc[_0x5907('0x13')]?_0xaa74dc[_0x5907('0x13')][_0x5907('0x18')]?_['map'](_0xaa74dc[_0x5907('0x13')][_0x5907('0x18')],function(_0x5eebf4){return{'model':db[_0x5eebf4[_0x5907('0x19')]],'as':_0x5eebf4['as'],'attributes':_0x5eebf4[_0x5907('0x16')],'include':_0x5eebf4['include']?_[_0x5907('0x1a')](_0x5eebf4['include'],function(_0x3bea5b){return{'model':db[_0x3bea5b[_0x5907('0x19')]],'as':_0x3bea5b['as'],'attributes':_0x3bea5b['attributes'],'include':_0x3bea5b[_0x5907('0x18')]?_[_0x5907('0x1a')](_0x3bea5b[_0x5907('0x18')],function(_0x10b160){return{'model':db[_0x10b160['model']],'as':_0x10b160['as'],'attributes':_0x10b160[_0x5907('0x16')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x4fbb2b){logger[_0x5907('0xa')](_0x5907('0x1b'),_0xaa74dc);logger[_0x5907('0x1c')](_0x5907('0x1b'),_0xaa74dc,JSON[_0x5907('0x1d')](_0x4fbb2b));_0x4d2b0d(_0x4fbb2b);})[_0x5907('0x11')](function(_0x5b45f0){logger[_0x5907('0xd')](_0x5907('0x1b'),_0x5b45f0['message'],_0xaa74dc);_0x268a0a(_0x381a7b[_0x5907('0xd')](0x1f4,_0x5b45f0['message']));});});};exports[_0x5907('0x1e')]=function(_0x4fcad7){var _0x2d3b67=this;return new Promise(function(_0x39d2d7,_0x1fe420){return db[_0x5907('0x1f')][_0x5907('0x20')]({'raw':_0x4fcad7[_0x5907('0x13')]?_0x4fcad7['options'][_0x5907('0x14')]===undefined?!![]:![]:!![],'where':_0x4fcad7[_0x5907('0x13')]?_0x4fcad7[_0x5907('0x13')]['where']||null:null,'attributes':_0x4fcad7[_0x5907('0x13')]?_0x4fcad7[_0x5907('0x13')][_0x5907('0x16')]||null:null,'include':_0x4fcad7['options']?_0x4fcad7[_0x5907('0x13')][_0x5907('0x18')]?_['map'](_0x4fcad7[_0x5907('0x13')][_0x5907('0x18')],function(_0x4abd2e){return{'model':db[_0x4abd2e[_0x5907('0x19')]],'as':_0x4abd2e['as'],'attributes':_0x4abd2e[_0x5907('0x16')],'include':_0x4abd2e[_0x5907('0x18')]?_['map'](_0x4abd2e[_0x5907('0x18')],function(_0x4110c1){return{'model':db[_0x4110c1[_0x5907('0x19')]],'as':_0x4110c1['as'],'attributes':_0x4110c1[_0x5907('0x16')],'include':_0x4110c1[_0x5907('0x18')]?_[_0x5907('0x1a')](_0x4110c1[_0x5907('0x18')],function(_0x2c290c){return{'model':db[_0x2c290c['model']],'as':_0x2c290c['as'],'attributes':_0x2c290c[_0x5907('0x16')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x101cdf){logger[_0x5907('0xa')](_0x5907('0x1e'),_0x4fcad7);logger[_0x5907('0x1c')]('ShowDynamics365Account',_0x4fcad7,JSON['stringify'](_0x101cdf));_0x39d2d7(_0x101cdf);})[_0x5907('0x11')](function(_0xfe600a){logger[_0x5907('0xd')]('ShowDynamics365Account',_0xfe600a[_0x5907('0xf')],_0x4fcad7);_0x1fe420(_0x2d3b67['error'](0x1f4,_0xfe600a['message']));});});};