ac7967fb534c756d1f0fc3bda4c602451c6e124f
[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 _0xecfb=['raw','where','include','map','model','attributes','GetDynamics365Account','stringify','ShowDynamics365Account','find','debug','lodash','util','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','Dynamics365Account,\x20%s,\x20%s','request\x20sent','Dynamics365Account,\x20%s,\x20%s,\x20%s','error','code','message','info','catch','Dynamics365Account','findAll','options'];(function(_0x374ada,_0x27b3a5){var _0x449ed8=function(_0x3efc46){while(--_0x3efc46){_0x374ada['push'](_0x374ada['shift']());}};_0x449ed8(++_0x27b3a5);}(_0xecfb,0x1d2));var _0xbecf=function(_0x37a5a7,_0x2bdad5){_0x37a5a7=_0x37a5a7-0x0;var _0x5981d2=_0xecfb[_0x37a5a7];return _0x5981d2;};'use strict';var _=require(_0xbecf('0x0'));var util=require(_0xbecf('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xbecf('0x2'));var fs=require('fs');var Redis=require(_0xbecf('0x3'));var db=require(_0xbecf('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xbecf('0x5'))(_0xbecf('0x6'));var config=require(_0xbecf('0x7'));var jayson=require(_0xbecf('0x8'));var client=jayson[_0xbecf('0x9')][_0xbecf('0xa')]({'port':0x232a});function respondWithRpcPromise(_0xf17f2a,_0x4260ec,_0x26836f){return new BPromise(function(_0x580309,_0x12210e){return client[_0xbecf('0xb')](_0xf17f2a,_0x26836f)[_0xbecf('0xc')](function(_0x495532){logger['info'](_0xbecf('0xd'),_0x4260ec,_0xbecf('0xe'));logger['debug'](_0xbecf('0xf'),_0x4260ec,_0xbecf('0xe'),JSON['stringify'](_0x495532));if(_0x495532[_0xbecf('0x10')]){if(_0x495532[_0xbecf('0x10')][_0xbecf('0x11')]===0x1f4){logger[_0xbecf('0x10')](_0xbecf('0xd'),_0x4260ec,_0x495532[_0xbecf('0x10')][_0xbecf('0x12')]);return _0x12210e(_0x495532[_0xbecf('0x10')][_0xbecf('0x12')]);}logger['error']('Dynamics365Account,\x20%s,\x20%s',_0x4260ec,_0x495532['error']['message']);return _0x580309(_0x495532['error'][_0xbecf('0x12')]);}else{logger[_0xbecf('0x13')](_0xbecf('0xd'),_0x4260ec,_0xbecf('0xe'));_0x580309(_0x495532['result']['message']);}})[_0xbecf('0x14')](function(_0xd02931){logger[_0xbecf('0x10')](_0xbecf('0xd'),_0x4260ec,_0xd02931);_0x12210e(_0xd02931);});});}exports['GetDynamics365Account']=function(_0x12ad90){var _0xa2464=this;return new Promise(function(_0x3bb877,_0x174e92){return db[_0xbecf('0x15')][_0xbecf('0x16')]({'raw':_0x12ad90[_0xbecf('0x17')]?_0x12ad90[_0xbecf('0x17')][_0xbecf('0x18')]===undefined?!![]:![]:!![],'where':_0x12ad90[_0xbecf('0x17')]?_0x12ad90[_0xbecf('0x17')][_0xbecf('0x19')]||null:null,'attributes':_0x12ad90[_0xbecf('0x17')]?_0x12ad90[_0xbecf('0x17')]['attributes']||null:null,'limit':_0x12ad90[_0xbecf('0x17')]?_0x12ad90['options']['limit']||null:null,'include':_0x12ad90[_0xbecf('0x17')]?_0x12ad90[_0xbecf('0x17')][_0xbecf('0x1a')]?_[_0xbecf('0x1b')](_0x12ad90[_0xbecf('0x17')]['include'],function(_0x43f927){return{'model':db[_0x43f927[_0xbecf('0x1c')]],'as':_0x43f927['as'],'attributes':_0x43f927[_0xbecf('0x1d')],'include':_0x43f927[_0xbecf('0x1a')]?_[_0xbecf('0x1b')](_0x43f927[_0xbecf('0x1a')],function(_0x204ef9){return{'model':db[_0x204ef9[_0xbecf('0x1c')]],'as':_0x204ef9['as'],'attributes':_0x204ef9[_0xbecf('0x1d')],'include':_0x204ef9[_0xbecf('0x1a')]?_[_0xbecf('0x1b')](_0x204ef9['include'],function(_0x3b7fa5){return{'model':db[_0x3b7fa5['model']],'as':_0x3b7fa5['as'],'attributes':_0x3b7fa5[_0xbecf('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xbecf('0xc')](function(_0x58f3b9){logger[_0xbecf('0x13')](_0xbecf('0x1e'),_0x12ad90);logger['debug'](_0xbecf('0x1e'),_0x12ad90,JSON[_0xbecf('0x1f')](_0x58f3b9));_0x3bb877(_0x58f3b9);})['catch'](function(_0xbba93e){logger[_0xbecf('0x10')](_0xbecf('0x1e'),_0xbba93e[_0xbecf('0x12')],_0x12ad90);_0x174e92(_0xa2464[_0xbecf('0x10')](0x1f4,_0xbba93e[_0xbecf('0x12')]));});});};exports[_0xbecf('0x20')]=function(_0x3a846e){var _0x18cb3a=this;return new Promise(function(_0x5e24ad,_0x17cf56){return db[_0xbecf('0x15')][_0xbecf('0x21')]({'raw':_0x3a846e[_0xbecf('0x17')]?_0x3a846e[_0xbecf('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x3a846e[_0xbecf('0x17')]?_0x3a846e['options'][_0xbecf('0x19')]||null:null,'attributes':_0x3a846e['options']?_0x3a846e[_0xbecf('0x17')][_0xbecf('0x1d')]||null:null,'include':_0x3a846e[_0xbecf('0x17')]?_0x3a846e[_0xbecf('0x17')][_0xbecf('0x1a')]?_[_0xbecf('0x1b')](_0x3a846e[_0xbecf('0x17')][_0xbecf('0x1a')],function(_0x5f4bb9){return{'model':db[_0x5f4bb9[_0xbecf('0x1c')]],'as':_0x5f4bb9['as'],'attributes':_0x5f4bb9[_0xbecf('0x1d')],'include':_0x5f4bb9['include']?_[_0xbecf('0x1b')](_0x5f4bb9['include'],function(_0x49f781){return{'model':db[_0x49f781[_0xbecf('0x1c')]],'as':_0x49f781['as'],'attributes':_0x49f781[_0xbecf('0x1d')],'include':_0x49f781['include']?_[_0xbecf('0x1b')](_0x49f781[_0xbecf('0x1a')],function(_0x3baca5){return{'model':db[_0x3baca5[_0xbecf('0x1c')]],'as':_0x3baca5['as'],'attributes':_0x3baca5['attributes']};}):[]};}):[]};}):[]:[]})[_0xbecf('0xc')](function(_0x26e397){logger[_0xbecf('0x13')](_0xbecf('0x20'),_0x3a846e);logger[_0xbecf('0x22')]('ShowDynamics365Account',_0x3a846e,JSON[_0xbecf('0x1f')](_0x26e397));_0x5e24ad(_0x26e397);})[_0xbecf('0x14')](function(_0x52ee36){logger['error'](_0xbecf('0x20'),_0x52ee36[_0xbecf('0x12')],_0x3a846e);_0x17cf56(_0x18cb3a[_0xbecf('0x10')](0x1f4,_0x52ee36['message']));});});};