2eab715e5f4f1ea92d12a2aaf2da85726f0af8b3
[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 _0x5f71=['../../config/logger','rpc','jayson/promise','client','http','request','then','info','debug','Dynamics365Account,\x20%s,\x20%s,\x20%s','stringify','error','code','Dynamics365Account,\x20%s,\x20%s','message','request\x20sent','result','catch','Dynamics365Account','findAll','options','raw','where','attributes','limit','include','map','model','GetDynamics365Account','find','ShowDynamics365Account','lodash','moment','randomstring'];(function(_0x4de877,_0x340170){var _0xb2cfeb=function(_0x488634){while(--_0x488634){_0x4de877['push'](_0x4de877['shift']());}};_0xb2cfeb(++_0x340170);}(_0x5f71,0xc9));var _0x15f7=function(_0x18946c,_0x3a7d1d){_0x18946c=_0x18946c-0x0;var _0x470381=_0x5f71[_0x18946c];return _0x470381;};'use strict';var _=require(_0x15f7('0x0'));var util=require('util');var moment=require(_0x15f7('0x1'));var BPromise=require('bluebird');var rs=require(_0x15f7('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x15f7('0x3'))(_0x15f7('0x4'));var config=require('../../config/environment');var jayson=require(_0x15f7('0x5'));var client=jayson[_0x15f7('0x6')][_0x15f7('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x1de7b3,_0x307158,_0x30d083){return new BPromise(function(_0x1c9509,_0x3f1490){return client[_0x15f7('0x8')](_0x1de7b3,_0x30d083)[_0x15f7('0x9')](function(_0x3e2f43){logger[_0x15f7('0xa')]('Dynamics365Account,\x20%s,\x20%s',_0x307158,'request\x20sent');logger[_0x15f7('0xb')](_0x15f7('0xc'),_0x307158,'request\x20sent',JSON[_0x15f7('0xd')](_0x3e2f43));if(_0x3e2f43[_0x15f7('0xe')]){if(_0x3e2f43[_0x15f7('0xe')][_0x15f7('0xf')]===0x1f4){logger[_0x15f7('0xe')](_0x15f7('0x10'),_0x307158,_0x3e2f43[_0x15f7('0xe')]['message']);return _0x3f1490(_0x3e2f43[_0x15f7('0xe')][_0x15f7('0x11')]);}logger[_0x15f7('0xe')]('Dynamics365Account,\x20%s,\x20%s',_0x307158,_0x3e2f43[_0x15f7('0xe')][_0x15f7('0x11')]);return _0x1c9509(_0x3e2f43['error'][_0x15f7('0x11')]);}else{logger[_0x15f7('0xa')](_0x15f7('0x10'),_0x307158,_0x15f7('0x12'));_0x1c9509(_0x3e2f43[_0x15f7('0x13')][_0x15f7('0x11')]);}})[_0x15f7('0x14')](function(_0x4b0d42){logger[_0x15f7('0xe')](_0x15f7('0x10'),_0x307158,_0x4b0d42);_0x3f1490(_0x4b0d42);});});}exports['GetDynamics365Account']=function(_0x2c78ca){var _0x333ff8=this;return new Promise(function(_0x2d4bc3,_0x40b752){return db[_0x15f7('0x15')][_0x15f7('0x16')]({'raw':_0x2c78ca[_0x15f7('0x17')]?_0x2c78ca['options'][_0x15f7('0x18')]===undefined?!![]:![]:!![],'where':_0x2c78ca[_0x15f7('0x17')]?_0x2c78ca[_0x15f7('0x17')][_0x15f7('0x19')]||null:null,'attributes':_0x2c78ca[_0x15f7('0x17')]?_0x2c78ca[_0x15f7('0x17')][_0x15f7('0x1a')]||null:null,'limit':_0x2c78ca['options']?_0x2c78ca['options'][_0x15f7('0x1b')]||null:null,'include':_0x2c78ca[_0x15f7('0x17')]?_0x2c78ca[_0x15f7('0x17')][_0x15f7('0x1c')]?_[_0x15f7('0x1d')](_0x2c78ca['options'][_0x15f7('0x1c')],function(_0x4fe2ca){return{'model':db[_0x4fe2ca[_0x15f7('0x1e')]],'as':_0x4fe2ca['as'],'attributes':_0x4fe2ca[_0x15f7('0x1a')],'include':_0x4fe2ca['include']?_['map'](_0x4fe2ca[_0x15f7('0x1c')],function(_0x5a1e21){return{'model':db[_0x5a1e21['model']],'as':_0x5a1e21['as'],'attributes':_0x5a1e21[_0x15f7('0x1a')],'include':_0x5a1e21['include']?_[_0x15f7('0x1d')](_0x5a1e21[_0x15f7('0x1c')],function(_0x64f9d9){return{'model':db[_0x64f9d9[_0x15f7('0x1e')]],'as':_0x64f9d9['as'],'attributes':_0x64f9d9[_0x15f7('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x3adf28){logger[_0x15f7('0xa')](_0x15f7('0x1f'),_0x2c78ca);logger['debug']('GetDynamics365Account',_0x2c78ca,JSON['stringify'](_0x3adf28));_0x2d4bc3(_0x3adf28);})['catch'](function(_0x1aef2b){logger[_0x15f7('0xe')](_0x15f7('0x1f'),_0x1aef2b[_0x15f7('0x11')],_0x2c78ca);_0x40b752(_0x333ff8[_0x15f7('0xe')](0x1f4,_0x1aef2b[_0x15f7('0x11')]));});});};exports['ShowDynamics365Account']=function(_0x521934){var _0x31bf43=this;return new Promise(function(_0xd240bb,_0x350f8a){return db['Dynamics365Account'][_0x15f7('0x20')]({'raw':_0x521934['options']?_0x521934[_0x15f7('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x521934[_0x15f7('0x17')]?_0x521934[_0x15f7('0x17')][_0x15f7('0x19')]||null:null,'attributes':_0x521934[_0x15f7('0x17')]?_0x521934['options']['attributes']||null:null,'include':_0x521934[_0x15f7('0x17')]?_0x521934[_0x15f7('0x17')][_0x15f7('0x1c')]?_[_0x15f7('0x1d')](_0x521934[_0x15f7('0x17')][_0x15f7('0x1c')],function(_0x2954cb){return{'model':db[_0x2954cb[_0x15f7('0x1e')]],'as':_0x2954cb['as'],'attributes':_0x2954cb[_0x15f7('0x1a')],'include':_0x2954cb[_0x15f7('0x1c')]?_[_0x15f7('0x1d')](_0x2954cb['include'],function(_0x1c737c){return{'model':db[_0x1c737c['model']],'as':_0x1c737c['as'],'attributes':_0x1c737c[_0x15f7('0x1a')],'include':_0x1c737c[_0x15f7('0x1c')]?_[_0x15f7('0x1d')](_0x1c737c[_0x15f7('0x1c')],function(_0x2b2525){return{'model':db[_0x2b2525[_0x15f7('0x1e')]],'as':_0x2b2525['as'],'attributes':_0x2b2525['attributes']};}):[]};}):[]};}):[]:[]})[_0x15f7('0x9')](function(_0x5a2343){logger[_0x15f7('0xa')](_0x15f7('0x21'),_0x521934);logger[_0x15f7('0xb')](_0x15f7('0x21'),_0x521934,JSON[_0x15f7('0xd')](_0x5a2343));_0xd240bb(_0x5a2343);})['catch'](function(_0x2c875e){logger['error']('ShowDynamics365Account',_0x2c875e[_0x15f7('0x11')],_0x521934);_0x350f8a(_0x31bf43['error'](0x1f4,_0x2c875e[_0x15f7('0x11')]));});});};