Built motion from commit 44b1f254.|2.6.26
[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 _0x8017=['GetDynamics365Account','Dynamics365Account','findAll','options','where','attributes','limit','map','include','model','catch','ShowDynamics365Account','raw','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','request','then','info','Dynamics365Account,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','result'];(function(_0x4ed507,_0x5a4c79){var _0x285d74=function(_0x5f1084){while(--_0x5f1084){_0x4ed507['push'](_0x4ed507['shift']());}};_0x285d74(++_0x5a4c79);}(_0x8017,0x99));var _0x7801=function(_0x1bd323,_0x1c16ab){_0x1bd323=_0x1bd323-0x0;var _0x13097b=_0x8017[_0x1bd323];return _0x13097b;};'use strict';var _=require('lodash');var util=require(_0x7801('0x0'));var moment=require(_0x7801('0x1'));var BPromise=require(_0x7801('0x2'));var rs=require(_0x7801('0x3'));var fs=require('fs');var Redis=require(_0x7801('0x4'));var db=require(_0x7801('0x5'))['db'];var utils=require(_0x7801('0x6'));var logger=require('../../config/logger')(_0x7801('0x7'));var config=require(_0x7801('0x8'));var jayson=require(_0x7801('0x9'));var client=jayson[_0x7801('0xa')][_0x7801('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x36552c,_0x29e707,_0x3495ae){return new BPromise(function(_0x7c32b3,_0x3654e2){return client[_0x7801('0xc')](_0x36552c,_0x3495ae)[_0x7801('0xd')](function(_0x3c57ce){logger[_0x7801('0xe')](_0x7801('0xf'),_0x29e707,_0x7801('0x10'));logger[_0x7801('0x11')]('Dynamics365Account,\x20%s,\x20%s,\x20%s',_0x29e707,_0x7801('0x10'),JSON[_0x7801('0x12')](_0x3c57ce));if(_0x3c57ce[_0x7801('0x13')]){if(_0x3c57ce['error']['code']===0x1f4){logger['error'](_0x7801('0xf'),_0x29e707,_0x3c57ce[_0x7801('0x13')]['message']);return _0x3654e2(_0x3c57ce[_0x7801('0x13')][_0x7801('0x14')]);}logger[_0x7801('0x13')](_0x7801('0xf'),_0x29e707,_0x3c57ce['error'][_0x7801('0x14')]);return _0x7c32b3(_0x3c57ce[_0x7801('0x13')][_0x7801('0x14')]);}else{logger[_0x7801('0xe')](_0x7801('0xf'),_0x29e707,_0x7801('0x10'));_0x7c32b3(_0x3c57ce[_0x7801('0x15')][_0x7801('0x14')]);}})['catch'](function(_0x2707a3){logger['error'](_0x7801('0xf'),_0x29e707,_0x2707a3);_0x3654e2(_0x2707a3);});});}exports[_0x7801('0x16')]=function(_0x53366a){var _0x51bf00=this;return new Promise(function(_0x13750b,_0x578799){return db[_0x7801('0x17')][_0x7801('0x18')]({'raw':_0x53366a[_0x7801('0x19')]?_0x53366a[_0x7801('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x53366a[_0x7801('0x19')]?_0x53366a[_0x7801('0x19')][_0x7801('0x1a')]||null:null,'attributes':_0x53366a['options']?_0x53366a[_0x7801('0x19')][_0x7801('0x1b')]||null:null,'limit':_0x53366a['options']?_0x53366a[_0x7801('0x19')][_0x7801('0x1c')]||null:null,'include':_0x53366a[_0x7801('0x19')]?_0x53366a[_0x7801('0x19')]['include']?_[_0x7801('0x1d')](_0x53366a[_0x7801('0x19')][_0x7801('0x1e')],function(_0x6e8b6f){return{'model':db[_0x6e8b6f['model']],'as':_0x6e8b6f['as'],'attributes':_0x6e8b6f[_0x7801('0x1b')],'include':_0x6e8b6f['include']?_[_0x7801('0x1d')](_0x6e8b6f[_0x7801('0x1e')],function(_0x11866d){return{'model':db[_0x11866d[_0x7801('0x1f')]],'as':_0x11866d['as'],'attributes':_0x11866d['attributes'],'include':_0x11866d[_0x7801('0x1e')]?_[_0x7801('0x1d')](_0x11866d['include'],function(_0x4fdf7e){return{'model':db[_0x4fdf7e[_0x7801('0x1f')]],'as':_0x4fdf7e['as'],'attributes':_0x4fdf7e[_0x7801('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x7801('0xd')](function(_0x40908e){logger['info'](_0x7801('0x16'),_0x53366a);logger['debug']('GetDynamics365Account',_0x53366a,JSON[_0x7801('0x12')](_0x40908e));_0x13750b(_0x40908e);})[_0x7801('0x20')](function(_0x560e71){logger[_0x7801('0x13')](_0x7801('0x16'),_0x560e71[_0x7801('0x14')],_0x53366a);_0x578799(_0x51bf00[_0x7801('0x13')](0x1f4,_0x560e71[_0x7801('0x14')]));});});};exports[_0x7801('0x21')]=function(_0x35e156){var _0x3ab1c8=this;return new Promise(function(_0x33cb88,_0x521060){return db[_0x7801('0x17')]['find']({'raw':_0x35e156[_0x7801('0x19')]?_0x35e156[_0x7801('0x19')][_0x7801('0x22')]===undefined?!![]:![]:!![],'where':_0x35e156[_0x7801('0x19')]?_0x35e156[_0x7801('0x19')][_0x7801('0x1a')]||null:null,'attributes':_0x35e156[_0x7801('0x19')]?_0x35e156[_0x7801('0x19')]['attributes']||null:null,'include':_0x35e156[_0x7801('0x19')]?_0x35e156['options'][_0x7801('0x1e')]?_[_0x7801('0x1d')](_0x35e156[_0x7801('0x19')][_0x7801('0x1e')],function(_0x1545e5){return{'model':db[_0x1545e5[_0x7801('0x1f')]],'as':_0x1545e5['as'],'attributes':_0x1545e5[_0x7801('0x1b')],'include':_0x1545e5[_0x7801('0x1e')]?_[_0x7801('0x1d')](_0x1545e5[_0x7801('0x1e')],function(_0x13254f){return{'model':db[_0x13254f[_0x7801('0x1f')]],'as':_0x13254f['as'],'attributes':_0x13254f[_0x7801('0x1b')],'include':_0x13254f[_0x7801('0x1e')]?_['map'](_0x13254f[_0x7801('0x1e')],function(_0x4a2aa2){return{'model':db[_0x4a2aa2[_0x7801('0x1f')]],'as':_0x4a2aa2['as'],'attributes':_0x4a2aa2[_0x7801('0x1b')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x3f9b2d){logger[_0x7801('0xe')](_0x7801('0x21'),_0x35e156);logger[_0x7801('0x11')](_0x7801('0x21'),_0x35e156,JSON[_0x7801('0x12')](_0x3f9b2d));_0x33cb88(_0x3f9b2d);})['catch'](function(_0x2b162d){logger[_0x7801('0x13')](_0x7801('0x21'),_0x2b162d[_0x7801('0x14')],_0x35e156);_0x521060(_0x3ab1c8[_0x7801('0x13')](0x1f4,_0x2b162d['message']));});});};