Built motion from commit 616d3211.|2.6.4
[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 _0x1ff3=['request','then','info','request\x20sent','debug','Dynamics365Account,\x20%s,\x20%s,\x20%s','stringify','error','code','Dynamics365Account,\x20%s,\x20%s','message','result','catch','Dynamics365Account','findAll','raw','options','where','attributes','include','model','map','GetDynamics365Account','ShowDynamics365Account','find','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','client'];(function(_0x2f71a9,_0x4c5bf5){var _0x3e9cf9=function(_0x584998){while(--_0x584998){_0x2f71a9['push'](_0x2f71a9['shift']());}};_0x3e9cf9(++_0x4c5bf5);}(_0x1ff3,0x1bd));var _0x31ff=function(_0x75ef65,_0x34c921){_0x75ef65=_0x75ef65-0x0;var _0x1b84fb=_0x1ff3[_0x75ef65];return _0x1b84fb;};'use strict';var _=require('lodash');var util=require(_0x31ff('0x0'));var moment=require(_0x31ff('0x1'));var BPromise=require(_0x31ff('0x2'));var rs=require(_0x31ff('0x3'));var fs=require('fs');var Redis=require(_0x31ff('0x4'));var db=require(_0x31ff('0x5'))['db'];var utils=require(_0x31ff('0x6'));var logger=require(_0x31ff('0x7'))(_0x31ff('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x31ff('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x5efe84,_0x2aee39,_0x5bb4e4){return new BPromise(function(_0x271f41,_0x5c6e5a){return client[_0x31ff('0xa')](_0x5efe84,_0x5bb4e4)[_0x31ff('0xb')](function(_0x2f60c8){logger[_0x31ff('0xc')]('Dynamics365Account,\x20%s,\x20%s',_0x2aee39,_0x31ff('0xd'));logger[_0x31ff('0xe')](_0x31ff('0xf'),_0x2aee39,'request\x20sent',JSON[_0x31ff('0x10')](_0x2f60c8));if(_0x2f60c8[_0x31ff('0x11')]){if(_0x2f60c8[_0x31ff('0x11')][_0x31ff('0x12')]===0x1f4){logger[_0x31ff('0x11')](_0x31ff('0x13'),_0x2aee39,_0x2f60c8[_0x31ff('0x11')][_0x31ff('0x14')]);return _0x5c6e5a(_0x2f60c8[_0x31ff('0x11')][_0x31ff('0x14')]);}logger[_0x31ff('0x11')]('Dynamics365Account,\x20%s,\x20%s',_0x2aee39,_0x2f60c8['error']['message']);return _0x271f41(_0x2f60c8[_0x31ff('0x11')][_0x31ff('0x14')]);}else{logger[_0x31ff('0xc')]('Dynamics365Account,\x20%s,\x20%s',_0x2aee39,'request\x20sent');_0x271f41(_0x2f60c8[_0x31ff('0x15')][_0x31ff('0x14')]);}})[_0x31ff('0x16')](function(_0x142210){logger['error']('Dynamics365Account,\x20%s,\x20%s',_0x2aee39,_0x142210);_0x5c6e5a(_0x142210);});});}exports['GetDynamics365Account']=function(_0x1e17f6){var _0x2c425e=this;return new Promise(function(_0x521ee5,_0xa172fa){return db[_0x31ff('0x17')][_0x31ff('0x18')]({'raw':_0x1e17f6['options']?_0x1e17f6['options'][_0x31ff('0x19')]===undefined?!![]:![]:!![],'where':_0x1e17f6[_0x31ff('0x1a')]?_0x1e17f6['options'][_0x31ff('0x1b')]||null:null,'attributes':_0x1e17f6[_0x31ff('0x1a')]?_0x1e17f6['options'][_0x31ff('0x1c')]||null:null,'limit':_0x1e17f6[_0x31ff('0x1a')]?_0x1e17f6[_0x31ff('0x1a')]['limit']||null:null,'include':_0x1e17f6[_0x31ff('0x1a')]?_0x1e17f6[_0x31ff('0x1a')][_0x31ff('0x1d')]?_['map'](_0x1e17f6[_0x31ff('0x1a')][_0x31ff('0x1d')],function(_0x29f477){return{'model':db[_0x29f477[_0x31ff('0x1e')]],'as':_0x29f477['as'],'attributes':_0x29f477[_0x31ff('0x1c')],'include':_0x29f477['include']?_[_0x31ff('0x1f')](_0x29f477['include'],function(_0x42941a){return{'model':db[_0x42941a[_0x31ff('0x1e')]],'as':_0x42941a['as'],'attributes':_0x42941a[_0x31ff('0x1c')],'include':_0x42941a[_0x31ff('0x1d')]?_['map'](_0x42941a[_0x31ff('0x1d')],function(_0x115e7c){return{'model':db[_0x115e7c['model']],'as':_0x115e7c['as'],'attributes':_0x115e7c[_0x31ff('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x31ff('0xb')](function(_0x4f4361){logger[_0x31ff('0xc')]('GetDynamics365Account',_0x1e17f6);logger[_0x31ff('0xe')](_0x31ff('0x20'),_0x1e17f6,JSON[_0x31ff('0x10')](_0x4f4361));_0x521ee5(_0x4f4361);})['catch'](function(_0xebe28d){logger[_0x31ff('0x11')](_0x31ff('0x20'),_0xebe28d['message'],_0x1e17f6);_0xa172fa(_0x2c425e['error'](0x1f4,_0xebe28d[_0x31ff('0x14')]));});});};exports[_0x31ff('0x21')]=function(_0x33779f){var _0x875dab=this;return new Promise(function(_0x27340a,_0x44c8f6){return db[_0x31ff('0x17')][_0x31ff('0x22')]({'raw':_0x33779f[_0x31ff('0x1a')]?_0x33779f[_0x31ff('0x1a')][_0x31ff('0x19')]===undefined?!![]:![]:!![],'where':_0x33779f[_0x31ff('0x1a')]?_0x33779f[_0x31ff('0x1a')][_0x31ff('0x1b')]||null:null,'attributes':_0x33779f[_0x31ff('0x1a')]?_0x33779f['options'][_0x31ff('0x1c')]||null:null,'include':_0x33779f[_0x31ff('0x1a')]?_0x33779f[_0x31ff('0x1a')][_0x31ff('0x1d')]?_[_0x31ff('0x1f')](_0x33779f[_0x31ff('0x1a')]['include'],function(_0x2cc141){return{'model':db[_0x2cc141[_0x31ff('0x1e')]],'as':_0x2cc141['as'],'attributes':_0x2cc141[_0x31ff('0x1c')],'include':_0x2cc141['include']?_[_0x31ff('0x1f')](_0x2cc141[_0x31ff('0x1d')],function(_0x4456cf){return{'model':db[_0x4456cf[_0x31ff('0x1e')]],'as':_0x4456cf['as'],'attributes':_0x4456cf[_0x31ff('0x1c')],'include':_0x4456cf[_0x31ff('0x1d')]?_[_0x31ff('0x1f')](_0x4456cf[_0x31ff('0x1d')],function(_0x19fc83){return{'model':db[_0x19fc83[_0x31ff('0x1e')]],'as':_0x19fc83['as'],'attributes':_0x19fc83[_0x31ff('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2fe33b){logger[_0x31ff('0xc')](_0x31ff('0x21'),_0x33779f);logger[_0x31ff('0xe')](_0x31ff('0x21'),_0x33779f,JSON[_0x31ff('0x10')](_0x2fe33b));_0x27340a(_0x2fe33b);})[_0x31ff('0x16')](function(_0x22691e){logger[_0x31ff('0x11')](_0x31ff('0x21'),_0x22691e[_0x31ff('0x14')],_0x33779f);_0x44c8f6(_0x875dab['error'](0x1f4,_0x22691e[_0x31ff('0x14')]));});});};