64c47731d1de1954aff01eddd7f7ca28d99af52c
[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 _0xce4e=['stringify','error','code','message','result','findAll','options','include','map','model','attributes','GetDynamics365Account','catch','ShowDynamics365Account','find','raw','where','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','request','then','info','Dynamics365Account,\x20%s,\x20%s','request\x20sent','debug','Dynamics365Account,\x20%s,\x20%s,\x20%s'];(function(_0x527e04,_0x5e03ce){var _0x23b91b=function(_0x1ceafe){while(--_0x1ceafe){_0x527e04['push'](_0x527e04['shift']());}};_0x23b91b(++_0x5e03ce);}(_0xce4e,0x99));var _0xece4=function(_0x19e35c,_0x29cd1e){_0x19e35c=_0x19e35c-0x0;var _0x3e1fe8=_0xce4e[_0x19e35c];return _0x3e1fe8;};'use strict';var _=require(_0xece4('0x0'));var util=require(_0xece4('0x1'));var moment=require('moment');var BPromise=require(_0xece4('0x2'));var rs=require(_0xece4('0x3'));var fs=require('fs');var Redis=require(_0xece4('0x4'));var db=require(_0xece4('0x5'))['db'];var utils=require(_0xece4('0x6'));var logger=require(_0xece4('0x7'))(_0xece4('0x8'));var config=require('../../config/environment');var jayson=require(_0xece4('0x9'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x3fffe0,_0x989dfb,_0x147891){return new BPromise(function(_0x5e0f36,_0x4ed7e7){return client[_0xece4('0xa')](_0x3fffe0,_0x147891)[_0xece4('0xb')](function(_0x17600f){logger[_0xece4('0xc')](_0xece4('0xd'),_0x989dfb,_0xece4('0xe'));logger[_0xece4('0xf')](_0xece4('0x10'),_0x989dfb,_0xece4('0xe'),JSON[_0xece4('0x11')](_0x17600f));if(_0x17600f[_0xece4('0x12')]){if(_0x17600f[_0xece4('0x12')][_0xece4('0x13')]===0x1f4){logger[_0xece4('0x12')]('Dynamics365Account,\x20%s,\x20%s',_0x989dfb,_0x17600f['error'][_0xece4('0x14')]);return _0x4ed7e7(_0x17600f['error']['message']);}logger[_0xece4('0x12')](_0xece4('0xd'),_0x989dfb,_0x17600f[_0xece4('0x12')]['message']);return _0x5e0f36(_0x17600f[_0xece4('0x12')]['message']);}else{logger['info']('Dynamics365Account,\x20%s,\x20%s',_0x989dfb,_0xece4('0xe'));_0x5e0f36(_0x17600f[_0xece4('0x15')][_0xece4('0x14')]);}})['catch'](function(_0x3340d7){logger[_0xece4('0x12')](_0xece4('0xd'),_0x989dfb,_0x3340d7);_0x4ed7e7(_0x3340d7);});});}exports['GetDynamics365Account']=function(_0x599ec6){var _0x562bc2=this;return new Promise(function(_0x317a83,_0x4e7378){return db['Dynamics365Account'][_0xece4('0x16')]({'raw':_0x599ec6[_0xece4('0x17')]?_0x599ec6['options']['raw']===undefined?!![]:![]:!![],'where':_0x599ec6['options']?_0x599ec6['options']['where']||null:null,'attributes':_0x599ec6[_0xece4('0x17')]?_0x599ec6[_0xece4('0x17')]['attributes']||null:null,'limit':_0x599ec6['options']?_0x599ec6['options']['limit']||null:null,'include':_0x599ec6[_0xece4('0x17')]?_0x599ec6[_0xece4('0x17')][_0xece4('0x18')]?_[_0xece4('0x19')](_0x599ec6[_0xece4('0x17')]['include'],function(_0x1fb384){return{'model':db[_0x1fb384[_0xece4('0x1a')]],'as':_0x1fb384['as'],'attributes':_0x1fb384[_0xece4('0x1b')],'include':_0x1fb384['include']?_[_0xece4('0x19')](_0x1fb384['include'],function(_0x53c225){return{'model':db[_0x53c225['model']],'as':_0x53c225['as'],'attributes':_0x53c225[_0xece4('0x1b')],'include':_0x53c225[_0xece4('0x18')]?_['map'](_0x53c225[_0xece4('0x18')],function(_0x482333){return{'model':db[_0x482333['model']],'as':_0x482333['as'],'attributes':_0x482333[_0xece4('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xece4('0xb')](function(_0x33bd36){logger[_0xece4('0xc')](_0xece4('0x1c'),_0x599ec6);logger[_0xece4('0xf')](_0xece4('0x1c'),_0x599ec6,JSON[_0xece4('0x11')](_0x33bd36));_0x317a83(_0x33bd36);})[_0xece4('0x1d')](function(_0x5c53a8){logger[_0xece4('0x12')](_0xece4('0x1c'),_0x5c53a8[_0xece4('0x14')],_0x599ec6);_0x4e7378(_0x562bc2[_0xece4('0x12')](0x1f4,_0x5c53a8[_0xece4('0x14')]));});});};exports[_0xece4('0x1e')]=function(_0x552ba2){var _0x54adcb=this;return new Promise(function(_0x1f87e4,_0x5b4b3d){return db['Dynamics365Account'][_0xece4('0x1f')]({'raw':_0x552ba2[_0xece4('0x17')]?_0x552ba2[_0xece4('0x17')][_0xece4('0x20')]===undefined?!![]:![]:!![],'where':_0x552ba2[_0xece4('0x17')]?_0x552ba2['options'][_0xece4('0x21')]||null:null,'attributes':_0x552ba2[_0xece4('0x17')]?_0x552ba2['options'][_0xece4('0x1b')]||null:null,'include':_0x552ba2[_0xece4('0x17')]?_0x552ba2[_0xece4('0x17')]['include']?_[_0xece4('0x19')](_0x552ba2['options'][_0xece4('0x18')],function(_0x9169fb){return{'model':db[_0x9169fb[_0xece4('0x1a')]],'as':_0x9169fb['as'],'attributes':_0x9169fb[_0xece4('0x1b')],'include':_0x9169fb[_0xece4('0x18')]?_['map'](_0x9169fb[_0xece4('0x18')],function(_0x143c0c){return{'model':db[_0x143c0c[_0xece4('0x1a')]],'as':_0x143c0c['as'],'attributes':_0x143c0c[_0xece4('0x1b')],'include':_0x143c0c[_0xece4('0x18')]?_['map'](_0x143c0c['include'],function(_0x361fdd){return{'model':db[_0x361fdd[_0xece4('0x1a')]],'as':_0x361fdd['as'],'attributes':_0x361fdd['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x5654cf){logger['info'](_0xece4('0x1e'),_0x552ba2);logger[_0xece4('0xf')](_0xece4('0x1e'),_0x552ba2,JSON[_0xece4('0x11')](_0x5654cf));_0x1f87e4(_0x5654cf);})[_0xece4('0x1d')](function(_0x1ed10a){logger[_0xece4('0x12')]('ShowDynamics365Account',_0x1ed10a[_0xece4('0x14')],_0x552ba2);_0x5b4b3d(_0x54adcb[_0xece4('0x12')](0x1f4,_0x1ed10a['message']));});});};