33db845872a987b430b7b386234f47f18f4ab1a6
[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 _0x9f02=['limit','include','map','model','ShowDynamics365Account','find','stringify','catch','lodash','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','http','then','info','debug','error','message','Dynamics365Account,\x20%s,\x20%s','request\x20sent','result','GetDynamics365Account','Dynamics365Account','findAll','options','raw','where','attributes'];(function(_0x3d64a1,_0x5551c0){var _0x5d4398=function(_0x13307a){while(--_0x13307a){_0x3d64a1['push'](_0x3d64a1['shift']());}};_0x5d4398(++_0x5551c0);}(_0x9f02,0x68));var _0x29f0=function(_0x1d2645,_0x1eb178){_0x1d2645=_0x1d2645-0x0;var _0x230896=_0x9f02[_0x1d2645];return _0x230896;};'use strict';var _=require(_0x29f0('0x0'));var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x29f0('0x1'));var fs=require('fs');var Redis=require(_0x29f0('0x2'));var db=require(_0x29f0('0x3'))['db'];var utils=require(_0x29f0('0x4'));var logger=require(_0x29f0('0x5'))('rpc');var config=require(_0x29f0('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x29f0('0x7')][_0x29f0('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x2d4852,_0x53d629,_0x4d47b3){return new BPromise(function(_0x594e30,_0x1da49e){return client['request'](_0x2d4852,_0x4d47b3)[_0x29f0('0x9')](function(_0x232592){logger[_0x29f0('0xa')]('Dynamics365Account,\x20%s,\x20%s',_0x53d629,'request\x20sent');logger[_0x29f0('0xb')]('Dynamics365Account,\x20%s,\x20%s,\x20%s',_0x53d629,'request\x20sent',JSON['stringify'](_0x232592));if(_0x232592['error']){if(_0x232592[_0x29f0('0xc')]['code']===0x1f4){logger[_0x29f0('0xc')]('Dynamics365Account,\x20%s,\x20%s',_0x53d629,_0x232592[_0x29f0('0xc')][_0x29f0('0xd')]);return _0x1da49e(_0x232592[_0x29f0('0xc')][_0x29f0('0xd')]);}logger['error'](_0x29f0('0xe'),_0x53d629,_0x232592[_0x29f0('0xc')]['message']);return _0x594e30(_0x232592[_0x29f0('0xc')]['message']);}else{logger[_0x29f0('0xa')]('Dynamics365Account,\x20%s,\x20%s',_0x53d629,_0x29f0('0xf'));_0x594e30(_0x232592[_0x29f0('0x10')]['message']);}})['catch'](function(_0x58e4e2){logger[_0x29f0('0xc')](_0x29f0('0xe'),_0x53d629,_0x58e4e2);_0x1da49e(_0x58e4e2);});});}exports[_0x29f0('0x11')]=function(_0x528f6f){var _0x10f878=this;return new Promise(function(_0x3416c1,_0x18e42e){return db[_0x29f0('0x12')][_0x29f0('0x13')]({'raw':_0x528f6f['options']?_0x528f6f[_0x29f0('0x14')][_0x29f0('0x15')]===undefined?!![]:![]:!![],'where':_0x528f6f[_0x29f0('0x14')]?_0x528f6f['options'][_0x29f0('0x16')]||null:null,'attributes':_0x528f6f['options']?_0x528f6f[_0x29f0('0x14')][_0x29f0('0x17')]||null:null,'limit':_0x528f6f[_0x29f0('0x14')]?_0x528f6f['options'][_0x29f0('0x18')]||null:null,'include':_0x528f6f[_0x29f0('0x14')]?_0x528f6f[_0x29f0('0x14')][_0x29f0('0x19')]?_[_0x29f0('0x1a')](_0x528f6f['options'][_0x29f0('0x19')],function(_0x3a726a){return{'model':db[_0x3a726a[_0x29f0('0x1b')]],'as':_0x3a726a['as'],'attributes':_0x3a726a[_0x29f0('0x17')],'include':_0x3a726a[_0x29f0('0x19')]?_[_0x29f0('0x1a')](_0x3a726a[_0x29f0('0x19')],function(_0x3ee1ab){return{'model':db[_0x3ee1ab[_0x29f0('0x1b')]],'as':_0x3ee1ab['as'],'attributes':_0x3ee1ab[_0x29f0('0x17')],'include':_0x3ee1ab[_0x29f0('0x19')]?_['map'](_0x3ee1ab[_0x29f0('0x19')],function(_0x4e2153){return{'model':db[_0x4e2153['model']],'as':_0x4e2153['as'],'attributes':_0x4e2153['attributes']};}):[]};}):[]};}):[]:[]})[_0x29f0('0x9')](function(_0x33d621){logger['info'](_0x29f0('0x11'),_0x528f6f);logger[_0x29f0('0xb')](_0x29f0('0x11'),_0x528f6f,JSON['stringify'](_0x33d621));_0x3416c1(_0x33d621);})['catch'](function(_0x1ac3ff){logger[_0x29f0('0xc')](_0x29f0('0x11'),_0x1ac3ff[_0x29f0('0xd')],_0x528f6f);_0x18e42e(_0x10f878[_0x29f0('0xc')](0x1f4,_0x1ac3ff['message']));});});};exports[_0x29f0('0x1c')]=function(_0x3a38ae){var _0x1fcdfa=this;return new Promise(function(_0x2f7c8a,_0x23471a){return db[_0x29f0('0x12')][_0x29f0('0x1d')]({'raw':_0x3a38ae['options']?_0x3a38ae[_0x29f0('0x14')][_0x29f0('0x15')]===undefined?!![]:![]:!![],'where':_0x3a38ae['options']?_0x3a38ae[_0x29f0('0x14')][_0x29f0('0x16')]||null:null,'attributes':_0x3a38ae['options']?_0x3a38ae['options'][_0x29f0('0x17')]||null:null,'include':_0x3a38ae['options']?_0x3a38ae[_0x29f0('0x14')]['include']?_[_0x29f0('0x1a')](_0x3a38ae[_0x29f0('0x14')]['include'],function(_0x1e653d){return{'model':db[_0x1e653d['model']],'as':_0x1e653d['as'],'attributes':_0x1e653d[_0x29f0('0x17')],'include':_0x1e653d[_0x29f0('0x19')]?_[_0x29f0('0x1a')](_0x1e653d[_0x29f0('0x19')],function(_0x48da37){return{'model':db[_0x48da37[_0x29f0('0x1b')]],'as':_0x48da37['as'],'attributes':_0x48da37['attributes'],'include':_0x48da37[_0x29f0('0x19')]?_[_0x29f0('0x1a')](_0x48da37[_0x29f0('0x19')],function(_0x456c1e){return{'model':db[_0x456c1e[_0x29f0('0x1b')]],'as':_0x456c1e['as'],'attributes':_0x456c1e[_0x29f0('0x17')]};}):[]};}):[]};}):[]:[]})[_0x29f0('0x9')](function(_0x4c4088){logger[_0x29f0('0xa')](_0x29f0('0x1c'),_0x3a38ae);logger[_0x29f0('0xb')]('ShowDynamics365Account',_0x3a38ae,JSON[_0x29f0('0x1e')](_0x4c4088));_0x2f7c8a(_0x4c4088);})[_0x29f0('0x1f')](function(_0x558969){logger[_0x29f0('0xc')](_0x29f0('0x1c'),_0x558969[_0x29f0('0xd')],_0x3a38ae);_0x23471a(_0x1fcdfa[_0x29f0('0xc')](0x1f4,_0x558969['message']));});});};