Built motion from commit 092f8824.|2.5.49
[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 _0x8757=['model','lodash','util','bluebird','ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','request','Dynamics365Account,\x20%s,\x20%s','debug','Dynamics365Account,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','catch','GetDynamics365Account','Dynamics365Account','options','where','attributes','limit','include','map','then','ShowDynamics365Account','find','raw'];(function(_0x580576,_0x2f107d){var _0x3f55a0=function(_0x2e180b){while(--_0x2e180b){_0x580576['push'](_0x580576['shift']());}};_0x3f55a0(++_0x2f107d);}(_0x8757,0x67));var _0x7875=function(_0x136c1d,_0x4f2ce3){_0x136c1d=_0x136c1d-0x0;var _0x21c1ed=_0x8757[_0x136c1d];return _0x21c1ed;};'use strict';var _=require(_0x7875('0x0'));var util=require(_0x7875('0x1'));var moment=require('moment');var BPromise=require(_0x7875('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x7875('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x7875('0x4'));var logger=require(_0x7875('0x5'))('rpc');var config=require(_0x7875('0x6'));var jayson=require(_0x7875('0x7'));var client=jayson['client'][_0x7875('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x5a47d,_0x3380af,_0x5ebcb6){return new BPromise(function(_0x50d90c,_0x4b2df5){return client[_0x7875('0x9')](_0x5a47d,_0x5ebcb6)['then'](function(_0x3c15c4){logger['info'](_0x7875('0xa'),_0x3380af,'request\x20sent');logger[_0x7875('0xb')](_0x7875('0xc'),_0x3380af,_0x7875('0xd'),JSON[_0x7875('0xe')](_0x3c15c4));if(_0x3c15c4[_0x7875('0xf')]){if(_0x3c15c4[_0x7875('0xf')][_0x7875('0x10')]===0x1f4){logger['error'](_0x7875('0xa'),_0x3380af,_0x3c15c4[_0x7875('0xf')][_0x7875('0x11')]);return _0x4b2df5(_0x3c15c4[_0x7875('0xf')][_0x7875('0x11')]);}logger[_0x7875('0xf')](_0x7875('0xa'),_0x3380af,_0x3c15c4[_0x7875('0xf')][_0x7875('0x11')]);return _0x50d90c(_0x3c15c4[_0x7875('0xf')]['message']);}else{logger[_0x7875('0x12')](_0x7875('0xa'),_0x3380af,'request\x20sent');_0x50d90c(_0x3c15c4[_0x7875('0x13')]['message']);}})[_0x7875('0x14')](function(_0x3b76d2){logger['error'](_0x7875('0xa'),_0x3380af,_0x3b76d2);_0x4b2df5(_0x3b76d2);});});}exports[_0x7875('0x15')]=function(_0x2c486e){var _0x383762=this;return new Promise(function(_0x45cab0,_0x3849c0){return db[_0x7875('0x16')]['findAll']({'raw':_0x2c486e[_0x7875('0x17')]?_0x2c486e['options']['raw']===undefined?!![]:![]:!![],'where':_0x2c486e[_0x7875('0x17')]?_0x2c486e[_0x7875('0x17')][_0x7875('0x18')]||null:null,'attributes':_0x2c486e[_0x7875('0x17')]?_0x2c486e[_0x7875('0x17')][_0x7875('0x19')]||null:null,'limit':_0x2c486e[_0x7875('0x17')]?_0x2c486e[_0x7875('0x17')][_0x7875('0x1a')]||null:null,'include':_0x2c486e[_0x7875('0x17')]?_0x2c486e['options'][_0x7875('0x1b')]?_[_0x7875('0x1c')](_0x2c486e['options']['include'],function(_0x3033d8){return{'model':db[_0x3033d8['model']],'as':_0x3033d8['as'],'attributes':_0x3033d8[_0x7875('0x19')],'include':_0x3033d8[_0x7875('0x1b')]?_[_0x7875('0x1c')](_0x3033d8[_0x7875('0x1b')],function(_0x1143cf){return{'model':db[_0x1143cf['model']],'as':_0x1143cf['as'],'attributes':_0x1143cf[_0x7875('0x19')],'include':_0x1143cf[_0x7875('0x1b')]?_[_0x7875('0x1c')](_0x1143cf[_0x7875('0x1b')],function(_0x3cb9f5){return{'model':db[_0x3cb9f5['model']],'as':_0x3cb9f5['as'],'attributes':_0x3cb9f5[_0x7875('0x19')]};}):[]};}):[]};}):[]:[]})[_0x7875('0x1d')](function(_0x235077){logger[_0x7875('0x12')](_0x7875('0x15'),_0x2c486e);logger[_0x7875('0xb')](_0x7875('0x15'),_0x2c486e,JSON[_0x7875('0xe')](_0x235077));_0x45cab0(_0x235077);})[_0x7875('0x14')](function(_0x11fdea){logger[_0x7875('0xf')]('GetDynamics365Account',_0x11fdea[_0x7875('0x11')],_0x2c486e);_0x3849c0(_0x383762['error'](0x1f4,_0x11fdea[_0x7875('0x11')]));});});};exports[_0x7875('0x1e')]=function(_0x432cce){var _0x3c5bdb=this;return new Promise(function(_0x413567,_0x28307a){return db[_0x7875('0x16')][_0x7875('0x1f')]({'raw':_0x432cce['options']?_0x432cce['options'][_0x7875('0x20')]===undefined?!![]:![]:!![],'where':_0x432cce['options']?_0x432cce[_0x7875('0x17')][_0x7875('0x18')]||null:null,'attributes':_0x432cce[_0x7875('0x17')]?_0x432cce[_0x7875('0x17')]['attributes']||null:null,'include':_0x432cce[_0x7875('0x17')]?_0x432cce[_0x7875('0x17')][_0x7875('0x1b')]?_[_0x7875('0x1c')](_0x432cce['options'][_0x7875('0x1b')],function(_0x18fda8){return{'model':db[_0x18fda8['model']],'as':_0x18fda8['as'],'attributes':_0x18fda8['attributes'],'include':_0x18fda8['include']?_[_0x7875('0x1c')](_0x18fda8[_0x7875('0x1b')],function(_0x2510e0){return{'model':db[_0x2510e0[_0x7875('0x21')]],'as':_0x2510e0['as'],'attributes':_0x2510e0[_0x7875('0x19')],'include':_0x2510e0[_0x7875('0x1b')]?_[_0x7875('0x1c')](_0x2510e0['include'],function(_0x5154fe){return{'model':db[_0x5154fe[_0x7875('0x21')]],'as':_0x5154fe['as'],'attributes':_0x5154fe[_0x7875('0x19')]};}):[]};}):[]};}):[]:[]})[_0x7875('0x1d')](function(_0x511b76){logger['info'](_0x7875('0x1e'),_0x432cce);logger[_0x7875('0xb')]('ShowDynamics365Account',_0x432cce,JSON[_0x7875('0xe')](_0x511b76));_0x413567(_0x511b76);})[_0x7875('0x14')](function(_0x3bdc6b){logger[_0x7875('0xf')](_0x7875('0x1e'),_0x3bdc6b[_0x7875('0x11')],_0x432cce);_0x28307a(_0x3c5bdb[_0x7875('0xf')](0x1f4,_0x3bdc6b[_0x7875('0x11')]));});});};