Built motion from commit 1fa89557.|2.6.10
[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 _0x8866=['bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','info','Dynamics365Account,\x20%s,\x20%s','request\x20sent','debug','Dynamics365Account,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetDynamics365Account','Dynamics365Account','findAll','options','raw','where','attributes','include','model','map','then','ShowDynamics365Account','lodash','util'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x8866,0x1ba));var _0x6886=function(_0x562559,_0x68159){_0x562559=_0x562559-0x0;var _0x11ea40=_0x8866[_0x562559];return _0x11ea40;};'use strict';var _=require(_0x6886('0x0'));var util=require(_0x6886('0x1'));var moment=require('moment');var BPromise=require(_0x6886('0x2'));var rs=require(_0x6886('0x3'));var fs=require('fs');var Redis=require(_0x6886('0x4'));var db=require(_0x6886('0x5'))['db'];var utils=require(_0x6886('0x6'));var logger=require(_0x6886('0x7'))(_0x6886('0x8'));var config=require(_0x6886('0x9'));var jayson=require(_0x6886('0xa'));var client=jayson[_0x6886('0xb')][_0x6886('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x2834da,_0x32e799,_0x5bff0f){return new BPromise(function(_0x424a98,_0x137dc3){return client[_0x6886('0xd')](_0x2834da,_0x5bff0f)['then'](function(_0x21563f){logger[_0x6886('0xe')](_0x6886('0xf'),_0x32e799,_0x6886('0x10'));logger[_0x6886('0x11')](_0x6886('0x12'),_0x32e799,'request\x20sent',JSON[_0x6886('0x13')](_0x21563f));if(_0x21563f[_0x6886('0x14')]){if(_0x21563f[_0x6886('0x14')][_0x6886('0x15')]===0x1f4){logger[_0x6886('0x14')](_0x6886('0xf'),_0x32e799,_0x21563f[_0x6886('0x14')][_0x6886('0x16')]);return _0x137dc3(_0x21563f[_0x6886('0x14')][_0x6886('0x16')]);}logger['error']('Dynamics365Account,\x20%s,\x20%s',_0x32e799,_0x21563f['error']['message']);return _0x424a98(_0x21563f[_0x6886('0x14')][_0x6886('0x16')]);}else{logger[_0x6886('0xe')](_0x6886('0xf'),_0x32e799,_0x6886('0x10'));_0x424a98(_0x21563f[_0x6886('0x17')]['message']);}})[_0x6886('0x18')](function(_0x43fe12){logger[_0x6886('0x14')](_0x6886('0xf'),_0x32e799,_0x43fe12);_0x137dc3(_0x43fe12);});});}exports[_0x6886('0x19')]=function(_0x3a2215){var _0x52e456=this;return new Promise(function(_0x193c4f,_0x379201){return db[_0x6886('0x1a')][_0x6886('0x1b')]({'raw':_0x3a2215[_0x6886('0x1c')]?_0x3a2215[_0x6886('0x1c')][_0x6886('0x1d')]===undefined?!![]:![]:!![],'where':_0x3a2215[_0x6886('0x1c')]?_0x3a2215[_0x6886('0x1c')][_0x6886('0x1e')]||null:null,'attributes':_0x3a2215[_0x6886('0x1c')]?_0x3a2215[_0x6886('0x1c')][_0x6886('0x1f')]||null:null,'limit':_0x3a2215[_0x6886('0x1c')]?_0x3a2215[_0x6886('0x1c')]['limit']||null:null,'include':_0x3a2215['options']?_0x3a2215[_0x6886('0x1c')][_0x6886('0x20')]?_['map'](_0x3a2215[_0x6886('0x1c')][_0x6886('0x20')],function(_0x525aad){return{'model':db[_0x525aad[_0x6886('0x21')]],'as':_0x525aad['as'],'attributes':_0x525aad[_0x6886('0x1f')],'include':_0x525aad[_0x6886('0x20')]?_[_0x6886('0x22')](_0x525aad[_0x6886('0x20')],function(_0x389cc6){return{'model':db[_0x389cc6[_0x6886('0x21')]],'as':_0x389cc6['as'],'attributes':_0x389cc6['attributes'],'include':_0x389cc6[_0x6886('0x20')]?_[_0x6886('0x22')](_0x389cc6[_0x6886('0x20')],function(_0x367815){return{'model':db[_0x367815['model']],'as':_0x367815['as'],'attributes':_0x367815[_0x6886('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x6886('0x23')](function(_0x316fff){logger[_0x6886('0xe')](_0x6886('0x19'),_0x3a2215);logger[_0x6886('0x11')](_0x6886('0x19'),_0x3a2215,JSON['stringify'](_0x316fff));_0x193c4f(_0x316fff);})[_0x6886('0x18')](function(_0x18e606){logger[_0x6886('0x14')](_0x6886('0x19'),_0x18e606[_0x6886('0x16')],_0x3a2215);_0x379201(_0x52e456[_0x6886('0x14')](0x1f4,_0x18e606['message']));});});};exports[_0x6886('0x24')]=function(_0x24567e){var _0x1a6eef=this;return new Promise(function(_0x1fc2f0,_0x469c78){return db[_0x6886('0x1a')]['find']({'raw':_0x24567e['options']?_0x24567e[_0x6886('0x1c')][_0x6886('0x1d')]===undefined?!![]:![]:!![],'where':_0x24567e[_0x6886('0x1c')]?_0x24567e[_0x6886('0x1c')][_0x6886('0x1e')]||null:null,'attributes':_0x24567e[_0x6886('0x1c')]?_0x24567e[_0x6886('0x1c')][_0x6886('0x1f')]||null:null,'include':_0x24567e['options']?_0x24567e[_0x6886('0x1c')][_0x6886('0x20')]?_[_0x6886('0x22')](_0x24567e[_0x6886('0x1c')][_0x6886('0x20')],function(_0x53c271){return{'model':db[_0x53c271[_0x6886('0x21')]],'as':_0x53c271['as'],'attributes':_0x53c271[_0x6886('0x1f')],'include':_0x53c271[_0x6886('0x20')]?_[_0x6886('0x22')](_0x53c271['include'],function(_0x5ca677){return{'model':db[_0x5ca677[_0x6886('0x21')]],'as':_0x5ca677['as'],'attributes':_0x5ca677[_0x6886('0x1f')],'include':_0x5ca677[_0x6886('0x20')]?_[_0x6886('0x22')](_0x5ca677[_0x6886('0x20')],function(_0x67a9db){return{'model':db[_0x67a9db['model']],'as':_0x67a9db['as'],'attributes':_0x67a9db['attributes']};}):[]};}):[]};}):[]:[]})[_0x6886('0x23')](function(_0x26ea91){logger['info'](_0x6886('0x24'),_0x24567e);logger[_0x6886('0x11')](_0x6886('0x24'),_0x24567e,JSON[_0x6886('0x13')](_0x26ea91));_0x1fc2f0(_0x26ea91);})['catch'](function(_0xbf02ab){logger[_0x6886('0x14')]('ShowDynamics365Account',_0xbf02ab[_0x6886('0x16')],_0x24567e);_0x469c78(_0x1a6eef[_0x6886('0x14')](0x1f4,_0xbf02ab['message']));});});};