53ab0db6d87a1d9b3ae9f7d596e1806a953dee5a
[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 _0x6bf2=['message','Dynamics365Account,\x20%s,\x20%s','info','result','catch','GetDynamics365Account','Dynamics365Account','findAll','options','where','attributes','limit','map','include','model','find','raw','ShowDynamics365Account','lodash','util','moment','ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','request','then','request\x20sent','debug','stringify','error','code'];(function(_0x1facfa,_0x1acf7d){var _0x9ec701=function(_0x115e37){while(--_0x115e37){_0x1facfa['push'](_0x1facfa['shift']());}};_0x9ec701(++_0x1acf7d);}(_0x6bf2,0x14d));var _0x26bf=function(_0x254d2e,_0x55f425){_0x254d2e=_0x254d2e-0x0;var _0x4faec4=_0x6bf2[_0x254d2e];return _0x4faec4;};'use strict';var _=require(_0x26bf('0x0'));var util=require(_0x26bf('0x1'));var moment=require(_0x26bf('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x26bf('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x26bf('0x4'));var logger=require(_0x26bf('0x5'))('rpc');var config=require(_0x26bf('0x6'));var jayson=require(_0x26bf('0x7'));var client=jayson[_0x26bf('0x8')][_0x26bf('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x1427fb,_0x2b5a72,_0x5b3565){return new BPromise(function(_0x333432,_0x51c435){return client[_0x26bf('0xa')](_0x1427fb,_0x5b3565)[_0x26bf('0xb')](function(_0xa31449){logger['info']('Dynamics365Account,\x20%s,\x20%s',_0x2b5a72,_0x26bf('0xc'));logger[_0x26bf('0xd')]('Dynamics365Account,\x20%s,\x20%s,\x20%s',_0x2b5a72,'request\x20sent',JSON[_0x26bf('0xe')](_0xa31449));if(_0xa31449[_0x26bf('0xf')]){if(_0xa31449[_0x26bf('0xf')][_0x26bf('0x10')]===0x1f4){logger['error']('Dynamics365Account,\x20%s,\x20%s',_0x2b5a72,_0xa31449['error']['message']);return _0x51c435(_0xa31449[_0x26bf('0xf')][_0x26bf('0x11')]);}logger[_0x26bf('0xf')](_0x26bf('0x12'),_0x2b5a72,_0xa31449[_0x26bf('0xf')][_0x26bf('0x11')]);return _0x333432(_0xa31449[_0x26bf('0xf')][_0x26bf('0x11')]);}else{logger[_0x26bf('0x13')](_0x26bf('0x12'),_0x2b5a72,_0x26bf('0xc'));_0x333432(_0xa31449[_0x26bf('0x14')][_0x26bf('0x11')]);}})[_0x26bf('0x15')](function(_0x3265b5){logger[_0x26bf('0xf')](_0x26bf('0x12'),_0x2b5a72,_0x3265b5);_0x51c435(_0x3265b5);});});}exports[_0x26bf('0x16')]=function(_0x2cc1da){var _0x4c89a1=this;return new Promise(function(_0x3c83a0,_0x4e30fa){return db[_0x26bf('0x17')][_0x26bf('0x18')]({'raw':_0x2cc1da[_0x26bf('0x19')]?_0x2cc1da[_0x26bf('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x2cc1da[_0x26bf('0x19')]?_0x2cc1da['options'][_0x26bf('0x1a')]||null:null,'attributes':_0x2cc1da['options']?_0x2cc1da[_0x26bf('0x19')][_0x26bf('0x1b')]||null:null,'limit':_0x2cc1da['options']?_0x2cc1da[_0x26bf('0x19')][_0x26bf('0x1c')]||null:null,'include':_0x2cc1da[_0x26bf('0x19')]?_0x2cc1da[_0x26bf('0x19')]['include']?_[_0x26bf('0x1d')](_0x2cc1da['options'][_0x26bf('0x1e')],function(_0xc5d48a){return{'model':db[_0xc5d48a['model']],'as':_0xc5d48a['as'],'attributes':_0xc5d48a[_0x26bf('0x1b')],'include':_0xc5d48a[_0x26bf('0x1e')]?_[_0x26bf('0x1d')](_0xc5d48a[_0x26bf('0x1e')],function(_0x59c39b){return{'model':db[_0x59c39b['model']],'as':_0x59c39b['as'],'attributes':_0x59c39b[_0x26bf('0x1b')],'include':_0x59c39b['include']?_[_0x26bf('0x1d')](_0x59c39b[_0x26bf('0x1e')],function(_0x3c77e5){return{'model':db[_0x3c77e5[_0x26bf('0x1f')]],'as':_0x3c77e5['as'],'attributes':_0x3c77e5[_0x26bf('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x26bf('0xb')](function(_0x5e795d){logger[_0x26bf('0x13')](_0x26bf('0x16'),_0x2cc1da);logger['debug'](_0x26bf('0x16'),_0x2cc1da,JSON[_0x26bf('0xe')](_0x5e795d));_0x3c83a0(_0x5e795d);})[_0x26bf('0x15')](function(_0x4e4765){logger[_0x26bf('0xf')]('GetDynamics365Account',_0x4e4765[_0x26bf('0x11')],_0x2cc1da);_0x4e30fa(_0x4c89a1[_0x26bf('0xf')](0x1f4,_0x4e4765['message']));});});};exports['ShowDynamics365Account']=function(_0x23276a){var _0x2302fe=this;return new Promise(function(_0x237833,_0x40591d){return db[_0x26bf('0x17')][_0x26bf('0x20')]({'raw':_0x23276a[_0x26bf('0x19')]?_0x23276a['options'][_0x26bf('0x21')]===undefined?!![]:![]:!![],'where':_0x23276a[_0x26bf('0x19')]?_0x23276a[_0x26bf('0x19')][_0x26bf('0x1a')]||null:null,'attributes':_0x23276a[_0x26bf('0x19')]?_0x23276a[_0x26bf('0x19')][_0x26bf('0x1b')]||null:null,'include':_0x23276a['options']?_0x23276a[_0x26bf('0x19')][_0x26bf('0x1e')]?_['map'](_0x23276a[_0x26bf('0x19')]['include'],function(_0x39f592){return{'model':db[_0x39f592[_0x26bf('0x1f')]],'as':_0x39f592['as'],'attributes':_0x39f592['attributes'],'include':_0x39f592['include']?_[_0x26bf('0x1d')](_0x39f592[_0x26bf('0x1e')],function(_0x52e3fc){return{'model':db[_0x52e3fc['model']],'as':_0x52e3fc['as'],'attributes':_0x52e3fc['attributes'],'include':_0x52e3fc[_0x26bf('0x1e')]?_[_0x26bf('0x1d')](_0x52e3fc[_0x26bf('0x1e')],function(_0x302d8b){return{'model':db[_0x302d8b[_0x26bf('0x1f')]],'as':_0x302d8b['as'],'attributes':_0x302d8b[_0x26bf('0x1b')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x8b5afe){logger[_0x26bf('0x13')](_0x26bf('0x22'),_0x23276a);logger[_0x26bf('0xd')](_0x26bf('0x22'),_0x23276a,JSON[_0x26bf('0xe')](_0x8b5afe));_0x237833(_0x8b5afe);})[_0x26bf('0x15')](function(_0x423d8a){logger[_0x26bf('0xf')]('ShowDynamics365Account',_0x423d8a[_0x26bf('0x11')],_0x23276a);_0x40591d(_0x2302fe[_0x26bf('0xf')](0x1f4,_0x423d8a[_0x26bf('0x11')]));});});};