Built motion from commit f7863d46.|2.5.41
[motion2.git] / server / api / squareOdbc / squareOdbc.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 _0x5665=['util','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','client','http','request','then','info','SquareOdbc,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','SquareOdbc','options','raw','where','attributes','map','model','include','ShowSquareOdbc','lodash'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x5665,0xd8));var _0x5566=function(_0x24f3c2,_0x33f20a){_0x24f3c2=_0x24f3c2-0x0;var _0x1e42ec=_0x5665[_0x24f3c2];return _0x1e42ec;};'use strict';var _=require(_0x5566('0x0'));var util=require(_0x5566('0x1'));var moment=require('moment');var BPromise=require(_0x5566('0x2'));var rs=require(_0x5566('0x3'));var fs=require('fs');var Redis=require(_0x5566('0x4'));var db=require(_0x5566('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x5566('0x6'))('rpc');var config=require(_0x5566('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x5566('0x8')][_0x5566('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x2995eb,_0x2f9f64,_0x5e894b){return new BPromise(function(_0xbef79a,_0x19afb9){return client[_0x5566('0xa')](_0x2995eb,_0x5e894b)[_0x5566('0xb')](function(_0xbd6dc3){logger[_0x5566('0xc')](_0x5566('0xd'),_0x2f9f64,_0x5566('0xe'));logger[_0x5566('0xf')]('SquareOdbc,\x20%s,\x20%s,\x20%s',_0x2f9f64,_0x5566('0xe'),JSON[_0x5566('0x10')](_0xbd6dc3));if(_0xbd6dc3[_0x5566('0x11')]){if(_0xbd6dc3[_0x5566('0x11')][_0x5566('0x12')]===0x1f4){logger[_0x5566('0x11')]('SquareOdbc,\x20%s,\x20%s',_0x2f9f64,_0xbd6dc3[_0x5566('0x11')][_0x5566('0x13')]);return _0x19afb9(_0xbd6dc3[_0x5566('0x11')][_0x5566('0x13')]);}logger[_0x5566('0x11')]('SquareOdbc,\x20%s,\x20%s',_0x2f9f64,_0xbd6dc3[_0x5566('0x11')][_0x5566('0x13')]);return _0xbef79a(_0xbd6dc3[_0x5566('0x11')][_0x5566('0x13')]);}else{logger[_0x5566('0xc')](_0x5566('0xd'),_0x2f9f64,_0x5566('0xe'));_0xbef79a(_0xbd6dc3[_0x5566('0x14')][_0x5566('0x13')]);}})[_0x5566('0x15')](function(_0x57a528){logger[_0x5566('0x11')](_0x5566('0xd'),_0x2f9f64,_0x57a528);_0x19afb9(_0x57a528);});});}exports['ShowSquareOdbc']=function(_0x265614){var _0x2a7e61=this;return new Promise(function(_0x5bbd47,_0x4ea1cf){return db[_0x5566('0x16')]['find']({'raw':_0x265614[_0x5566('0x17')]?_0x265614[_0x5566('0x17')][_0x5566('0x18')]===undefined?!![]:![]:!![],'where':_0x265614['options']?_0x265614[_0x5566('0x17')][_0x5566('0x19')]||null:null,'attributes':_0x265614['options']?_0x265614[_0x5566('0x17')][_0x5566('0x1a')]||null:null,'include':_0x265614[_0x5566('0x17')]?_0x265614[_0x5566('0x17')]['include']?_[_0x5566('0x1b')](_0x265614[_0x5566('0x17')]['include'],function(_0x1b55b9){return{'model':db[_0x1b55b9[_0x5566('0x1c')]],'as':_0x1b55b9['as'],'attributes':_0x1b55b9['attributes'],'include':_0x1b55b9[_0x5566('0x1d')]?_[_0x5566('0x1b')](_0x1b55b9[_0x5566('0x1d')],function(_0x41df7a){return{'model':db[_0x41df7a[_0x5566('0x1c')]],'as':_0x41df7a['as'],'attributes':_0x41df7a['attributes'],'include':_0x41df7a[_0x5566('0x1d')]?_['map'](_0x41df7a[_0x5566('0x1d')],function(_0x1631c6){return{'model':db[_0x1631c6[_0x5566('0x1c')]],'as':_0x1631c6['as'],'attributes':_0x1631c6[_0x5566('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x5566('0xb')](function(_0x332890){logger[_0x5566('0xc')]('ShowSquareOdbc',_0x265614);logger[_0x5566('0xf')](_0x5566('0x1e'),_0x265614,JSON[_0x5566('0x10')](_0x332890));_0x5bbd47(_0x332890);})[_0x5566('0x15')](function(_0x5b77aa){logger[_0x5566('0x11')](_0x5566('0x1e'),_0x5b77aa[_0x5566('0x13')],_0x265614);_0x4ea1cf(_0x2a7e61['error'](0x1f4,_0x5b77aa[_0x5566('0x13')]));});});};