47014ca144635e5102960c93b2aa4ca16214cf1d
[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 _0xd6c6=['client','http','request','then','info','Dynamics365Account,\x20%s,\x20%s','request\x20sent','Dynamics365Account,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','Dynamics365Account','findAll','options','raw','where','limit','include','map','model','attributes','GetDynamics365Account','debug','stringify','ShowDynamics365Account','find','lodash','util','moment','bluebird','ioredis','../../config/utils','rpc','../../config/environment','jayson/promise'];(function(_0x3925ff,_0x3fe6e5){var _0x1f16d5=function(_0xc538a2){while(--_0xc538a2){_0x3925ff['push'](_0x3925ff['shift']());}};_0x1f16d5(++_0x3fe6e5);}(_0xd6c6,0x1b3));var _0x6d6c=function(_0x6b01ac,_0x193ed2){_0x6b01ac=_0x6b01ac-0x0;var _0x597664=_0xd6c6[_0x6b01ac];return _0x597664;};'use strict';var _=require(_0x6d6c('0x0'));var util=require(_0x6d6c('0x1'));var moment=require(_0x6d6c('0x2'));var BPromise=require(_0x6d6c('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x6d6c('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x6d6c('0x5'));var logger=require('../../config/logger')(_0x6d6c('0x6'));var config=require(_0x6d6c('0x7'));var jayson=require(_0x6d6c('0x8'));var client=jayson[_0x6d6c('0x9')][_0x6d6c('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x372b6c,_0x7a2cdc,_0x2e501a){return new BPromise(function(_0x2dcaca,_0x142adb){return client[_0x6d6c('0xb')](_0x372b6c,_0x2e501a)[_0x6d6c('0xc')](function(_0x25c7de){logger[_0x6d6c('0xd')](_0x6d6c('0xe'),_0x7a2cdc,_0x6d6c('0xf'));logger['debug'](_0x6d6c('0x10'),_0x7a2cdc,_0x6d6c('0xf'),JSON['stringify'](_0x25c7de));if(_0x25c7de[_0x6d6c('0x11')]){if(_0x25c7de[_0x6d6c('0x11')][_0x6d6c('0x12')]===0x1f4){logger[_0x6d6c('0x11')](_0x6d6c('0xe'),_0x7a2cdc,_0x25c7de[_0x6d6c('0x11')][_0x6d6c('0x13')]);return _0x142adb(_0x25c7de[_0x6d6c('0x11')]['message']);}logger[_0x6d6c('0x11')](_0x6d6c('0xe'),_0x7a2cdc,_0x25c7de[_0x6d6c('0x11')][_0x6d6c('0x13')]);return _0x2dcaca(_0x25c7de['error'][_0x6d6c('0x13')]);}else{logger[_0x6d6c('0xd')](_0x6d6c('0xe'),_0x7a2cdc,_0x6d6c('0xf'));_0x2dcaca(_0x25c7de[_0x6d6c('0x14')][_0x6d6c('0x13')]);}})[_0x6d6c('0x15')](function(_0x2bbb6f){logger['error']('Dynamics365Account,\x20%s,\x20%s',_0x7a2cdc,_0x2bbb6f);_0x142adb(_0x2bbb6f);});});}exports['GetDynamics365Account']=function(_0x2c753d){var _0x16096b=this;return new Promise(function(_0x213ead,_0x21075e){return db[_0x6d6c('0x16')][_0x6d6c('0x17')]({'raw':_0x2c753d[_0x6d6c('0x18')]?_0x2c753d[_0x6d6c('0x18')][_0x6d6c('0x19')]===undefined?!![]:![]:!![],'where':_0x2c753d[_0x6d6c('0x18')]?_0x2c753d[_0x6d6c('0x18')][_0x6d6c('0x1a')]||null:null,'attributes':_0x2c753d[_0x6d6c('0x18')]?_0x2c753d[_0x6d6c('0x18')]['attributes']||null:null,'limit':_0x2c753d[_0x6d6c('0x18')]?_0x2c753d[_0x6d6c('0x18')][_0x6d6c('0x1b')]||null:null,'include':_0x2c753d[_0x6d6c('0x18')]?_0x2c753d['options'][_0x6d6c('0x1c')]?_[_0x6d6c('0x1d')](_0x2c753d[_0x6d6c('0x18')]['include'],function(_0x56c4b0){return{'model':db[_0x56c4b0[_0x6d6c('0x1e')]],'as':_0x56c4b0['as'],'attributes':_0x56c4b0['attributes'],'include':_0x56c4b0[_0x6d6c('0x1c')]?_[_0x6d6c('0x1d')](_0x56c4b0['include'],function(_0x1e0075){return{'model':db[_0x1e0075['model']],'as':_0x1e0075['as'],'attributes':_0x1e0075[_0x6d6c('0x1f')],'include':_0x1e0075['include']?_[_0x6d6c('0x1d')](_0x1e0075[_0x6d6c('0x1c')],function(_0xc1fc55){return{'model':db[_0xc1fc55[_0x6d6c('0x1e')]],'as':_0xc1fc55['as'],'attributes':_0xc1fc55['attributes']};}):[]};}):[]};}):[]:[]})[_0x6d6c('0xc')](function(_0x3f5b8c){logger[_0x6d6c('0xd')](_0x6d6c('0x20'),_0x2c753d);logger[_0x6d6c('0x21')](_0x6d6c('0x20'),_0x2c753d,JSON[_0x6d6c('0x22')](_0x3f5b8c));_0x213ead(_0x3f5b8c);})[_0x6d6c('0x15')](function(_0x1cbbfb){logger[_0x6d6c('0x11')](_0x6d6c('0x20'),_0x1cbbfb[_0x6d6c('0x13')],_0x2c753d);_0x21075e(_0x16096b[_0x6d6c('0x11')](0x1f4,_0x1cbbfb[_0x6d6c('0x13')]));});});};exports[_0x6d6c('0x23')]=function(_0x1eca8a){var _0x5b2698=this;return new Promise(function(_0x5e767,_0x1b908a){return db[_0x6d6c('0x16')][_0x6d6c('0x24')]({'raw':_0x1eca8a[_0x6d6c('0x18')]?_0x1eca8a['options'][_0x6d6c('0x19')]===undefined?!![]:![]:!![],'where':_0x1eca8a[_0x6d6c('0x18')]?_0x1eca8a['options'][_0x6d6c('0x1a')]||null:null,'attributes':_0x1eca8a['options']?_0x1eca8a['options'][_0x6d6c('0x1f')]||null:null,'include':_0x1eca8a[_0x6d6c('0x18')]?_0x1eca8a[_0x6d6c('0x18')][_0x6d6c('0x1c')]?_[_0x6d6c('0x1d')](_0x1eca8a[_0x6d6c('0x18')][_0x6d6c('0x1c')],function(_0xb644d8){return{'model':db[_0xb644d8[_0x6d6c('0x1e')]],'as':_0xb644d8['as'],'attributes':_0xb644d8[_0x6d6c('0x1f')],'include':_0xb644d8[_0x6d6c('0x1c')]?_['map'](_0xb644d8['include'],function(_0x2bd86b){return{'model':db[_0x2bd86b[_0x6d6c('0x1e')]],'as':_0x2bd86b['as'],'attributes':_0x2bd86b[_0x6d6c('0x1f')],'include':_0x2bd86b['include']?_[_0x6d6c('0x1d')](_0x2bd86b[_0x6d6c('0x1c')],function(_0xb7be05){return{'model':db[_0xb7be05[_0x6d6c('0x1e')]],'as':_0xb7be05['as'],'attributes':_0xb7be05[_0x6d6c('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x6d6c('0xc')](function(_0x261aff){logger['info'](_0x6d6c('0x23'),_0x1eca8a);logger[_0x6d6c('0x21')](_0x6d6c('0x23'),_0x1eca8a,JSON['stringify'](_0x261aff));_0x5e767(_0x261aff);})[_0x6d6c('0x15')](function(_0x32b7c9){logger['error'](_0x6d6c('0x23'),_0x32b7c9[_0x6d6c('0x13')],_0x1eca8a);_0x1b908a(_0x5b2698['error'](0x1f4,_0x32b7c9[_0x6d6c('0x13')]));});});};