Built motion from commit 10af8726.|2.6.34
[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 _0xdbe0=['ShowDynamics365Account','find','lodash','util','moment','bluebird','ioredis','../../config/utils','rpc','../../config/environment','client','http','then','info','Dynamics365Account,\x20%s,\x20%s','request\x20sent','Dynamics365Account,\x20%s,\x20%s,\x20%s','error','code','message','catch','GetDynamics365Account','findAll','options','raw','where','attributes','model','include','map','debug','stringify'];(function(_0x1528d7,_0x50578b){var _0x3173d5=function(_0x4ce466){while(--_0x4ce466){_0x1528d7['push'](_0x1528d7['shift']());}};_0x3173d5(++_0x50578b);}(_0xdbe0,0x122));var _0x0dbe=function(_0x3b08c4,_0x10bfb1){_0x3b08c4=_0x3b08c4-0x0;var _0x392cf8=_0xdbe0[_0x3b08c4];return _0x392cf8;};'use strict';var _=require(_0x0dbe('0x0'));var util=require(_0x0dbe('0x1'));var moment=require(_0x0dbe('0x2'));var BPromise=require(_0x0dbe('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0dbe('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x0dbe('0x5'));var logger=require('../../config/logger')(_0x0dbe('0x6'));var config=require(_0x0dbe('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x0dbe('0x8')][_0x0dbe('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x1b2f0f,_0x7d88da,_0x554038){return new BPromise(function(_0x15eaf2,_0x520f2c){return client['request'](_0x1b2f0f,_0x554038)[_0x0dbe('0xa')](function(_0x43d865){logger[_0x0dbe('0xb')](_0x0dbe('0xc'),_0x7d88da,_0x0dbe('0xd'));logger['debug'](_0x0dbe('0xe'),_0x7d88da,_0x0dbe('0xd'),JSON['stringify'](_0x43d865));if(_0x43d865[_0x0dbe('0xf')]){if(_0x43d865[_0x0dbe('0xf')][_0x0dbe('0x10')]===0x1f4){logger['error'](_0x0dbe('0xc'),_0x7d88da,_0x43d865['error'][_0x0dbe('0x11')]);return _0x520f2c(_0x43d865[_0x0dbe('0xf')][_0x0dbe('0x11')]);}logger[_0x0dbe('0xf')](_0x0dbe('0xc'),_0x7d88da,_0x43d865[_0x0dbe('0xf')][_0x0dbe('0x11')]);return _0x15eaf2(_0x43d865[_0x0dbe('0xf')]['message']);}else{logger['info'](_0x0dbe('0xc'),_0x7d88da,_0x0dbe('0xd'));_0x15eaf2(_0x43d865['result'][_0x0dbe('0x11')]);}})[_0x0dbe('0x12')](function(_0xccd24b){logger['error']('Dynamics365Account,\x20%s,\x20%s',_0x7d88da,_0xccd24b);_0x520f2c(_0xccd24b);});});}exports[_0x0dbe('0x13')]=function(_0x93afc5){var _0x37f2f4=this;return new Promise(function(_0x323074,_0x1e52a0){return db['Dynamics365Account'][_0x0dbe('0x14')]({'raw':_0x93afc5[_0x0dbe('0x15')]?_0x93afc5[_0x0dbe('0x15')][_0x0dbe('0x16')]===undefined?!![]:![]:!![],'where':_0x93afc5[_0x0dbe('0x15')]?_0x93afc5['options'][_0x0dbe('0x17')]||null:null,'attributes':_0x93afc5[_0x0dbe('0x15')]?_0x93afc5['options'][_0x0dbe('0x18')]||null:null,'limit':_0x93afc5[_0x0dbe('0x15')]?_0x93afc5[_0x0dbe('0x15')]['limit']||null:null,'include':_0x93afc5[_0x0dbe('0x15')]?_0x93afc5['options']['include']?_['map'](_0x93afc5[_0x0dbe('0x15')]['include'],function(_0x485db3){return{'model':db[_0x485db3[_0x0dbe('0x19')]],'as':_0x485db3['as'],'attributes':_0x485db3[_0x0dbe('0x18')],'include':_0x485db3[_0x0dbe('0x1a')]?_[_0x0dbe('0x1b')](_0x485db3['include'],function(_0x8428be){return{'model':db[_0x8428be[_0x0dbe('0x19')]],'as':_0x8428be['as'],'attributes':_0x8428be['attributes'],'include':_0x8428be[_0x0dbe('0x1a')]?_[_0x0dbe('0x1b')](_0x8428be[_0x0dbe('0x1a')],function(_0x55af8f){return{'model':db[_0x55af8f[_0x0dbe('0x19')]],'as':_0x55af8f['as'],'attributes':_0x55af8f[_0x0dbe('0x18')]};}):[]};}):[]};}):[]:[]})[_0x0dbe('0xa')](function(_0x115843){logger['info']('GetDynamics365Account',_0x93afc5);logger[_0x0dbe('0x1c')](_0x0dbe('0x13'),_0x93afc5,JSON[_0x0dbe('0x1d')](_0x115843));_0x323074(_0x115843);})[_0x0dbe('0x12')](function(_0x53d40b){logger[_0x0dbe('0xf')]('GetDynamics365Account',_0x53d40b[_0x0dbe('0x11')],_0x93afc5);_0x1e52a0(_0x37f2f4['error'](0x1f4,_0x53d40b[_0x0dbe('0x11')]));});});};exports[_0x0dbe('0x1e')]=function(_0x708257){var _0x3c4861=this;return new Promise(function(_0x1f0941,_0x442a16){return db['Dynamics365Account'][_0x0dbe('0x1f')]({'raw':_0x708257[_0x0dbe('0x15')]?_0x708257[_0x0dbe('0x15')][_0x0dbe('0x16')]===undefined?!![]:![]:!![],'where':_0x708257[_0x0dbe('0x15')]?_0x708257['options'][_0x0dbe('0x17')]||null:null,'attributes':_0x708257[_0x0dbe('0x15')]?_0x708257[_0x0dbe('0x15')]['attributes']||null:null,'include':_0x708257[_0x0dbe('0x15')]?_0x708257[_0x0dbe('0x15')][_0x0dbe('0x1a')]?_[_0x0dbe('0x1b')](_0x708257[_0x0dbe('0x15')][_0x0dbe('0x1a')],function(_0x1f60e9){return{'model':db[_0x1f60e9[_0x0dbe('0x19')]],'as':_0x1f60e9['as'],'attributes':_0x1f60e9[_0x0dbe('0x18')],'include':_0x1f60e9[_0x0dbe('0x1a')]?_['map'](_0x1f60e9[_0x0dbe('0x1a')],function(_0x443220){return{'model':db[_0x443220[_0x0dbe('0x19')]],'as':_0x443220['as'],'attributes':_0x443220[_0x0dbe('0x18')],'include':_0x443220[_0x0dbe('0x1a')]?_[_0x0dbe('0x1b')](_0x443220['include'],function(_0x10cb5b){return{'model':db[_0x10cb5b[_0x0dbe('0x19')]],'as':_0x10cb5b['as'],'attributes':_0x10cb5b[_0x0dbe('0x18')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2f65f4){logger['info'](_0x0dbe('0x1e'),_0x708257);logger[_0x0dbe('0x1c')](_0x0dbe('0x1e'),_0x708257,JSON[_0x0dbe('0x1d')](_0x2f65f4));_0x1f0941(_0x2f65f4);})['catch'](function(_0x37db52){logger['error']('ShowDynamics365Account',_0x37db52[_0x0dbe('0x11')],_0x708257);_0x442a16(_0x3c4861[_0x0dbe('0xf')](0x1f4,_0x37db52[_0x0dbe('0x11')]));});});};