Built motion from commit e781dc3c.|2.5.42
[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 _0xd37e=['ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','then','info','request\x20sent','stringify','error','code','SquareOdbc,\x20%s,\x20%s','message','result','ShowSquareOdbc','SquareOdbc','find','options','raw','attributes','map','model','include','debug','catch','lodash','util','bluebird','randomstring'];(function(_0x5c62e1,_0x11a8dc){var _0x3d809a=function(_0x188553){while(--_0x188553){_0x5c62e1['push'](_0x5c62e1['shift']());}};_0x3d809a(++_0x11a8dc);}(_0xd37e,0x19c));var _0xed37=function(_0x31b31b,_0x5f044e){_0x31b31b=_0x31b31b-0x0;var _0x2c8fc2=_0xd37e[_0x31b31b];return _0x2c8fc2;};'use strict';var _=require(_0xed37('0x0'));var util=require(_0xed37('0x1'));var moment=require('moment');var BPromise=require(_0xed37('0x2'));var rs=require(_0xed37('0x3'));var fs=require('fs');var Redis=require(_0xed37('0x4'));var db=require(_0xed37('0x5'))['db'];var utils=require(_0xed37('0x6'));var logger=require('../../config/logger')(_0xed37('0x7'));var config=require(_0xed37('0x8'));var jayson=require(_0xed37('0x9'));var client=jayson[_0xed37('0xa')][_0xed37('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x3083b6,_0x73720d,_0x3a4327){return new BPromise(function(_0x1accde,_0x444a9b){return client['request'](_0x3083b6,_0x3a4327)[_0xed37('0xc')](function(_0x976c94){logger[_0xed37('0xd')]('SquareOdbc,\x20%s,\x20%s',_0x73720d,_0xed37('0xe'));logger['debug']('SquareOdbc,\x20%s,\x20%s,\x20%s',_0x73720d,_0xed37('0xe'),JSON[_0xed37('0xf')](_0x976c94));if(_0x976c94[_0xed37('0x10')]){if(_0x976c94[_0xed37('0x10')][_0xed37('0x11')]===0x1f4){logger[_0xed37('0x10')](_0xed37('0x12'),_0x73720d,_0x976c94[_0xed37('0x10')][_0xed37('0x13')]);return _0x444a9b(_0x976c94[_0xed37('0x10')][_0xed37('0x13')]);}logger[_0xed37('0x10')](_0xed37('0x12'),_0x73720d,_0x976c94[_0xed37('0x10')][_0xed37('0x13')]);return _0x1accde(_0x976c94[_0xed37('0x10')][_0xed37('0x13')]);}else{logger[_0xed37('0xd')](_0xed37('0x12'),_0x73720d,_0xed37('0xe'));_0x1accde(_0x976c94[_0xed37('0x14')]['message']);}})['catch'](function(_0x64c553){logger[_0xed37('0x10')]('SquareOdbc,\x20%s,\x20%s',_0x73720d,_0x64c553);_0x444a9b(_0x64c553);});});}exports[_0xed37('0x15')]=function(_0x1a2236){var _0x467079=this;return new Promise(function(_0x5132f9,_0x3e7473){return db[_0xed37('0x16')][_0xed37('0x17')]({'raw':_0x1a2236[_0xed37('0x18')]?_0x1a2236[_0xed37('0x18')][_0xed37('0x19')]===undefined?!![]:![]:!![],'where':_0x1a2236[_0xed37('0x18')]?_0x1a2236[_0xed37('0x18')]['where']||null:null,'attributes':_0x1a2236[_0xed37('0x18')]?_0x1a2236['options'][_0xed37('0x1a')]||null:null,'include':_0x1a2236[_0xed37('0x18')]?_0x1a2236['options']['include']?_[_0xed37('0x1b')](_0x1a2236[_0xed37('0x18')]['include'],function(_0x386453){return{'model':db[_0x386453[_0xed37('0x1c')]],'as':_0x386453['as'],'attributes':_0x386453[_0xed37('0x1a')],'include':_0x386453[_0xed37('0x1d')]?_['map'](_0x386453['include'],function(_0x45825d){return{'model':db[_0x45825d[_0xed37('0x1c')]],'as':_0x45825d['as'],'attributes':_0x45825d['attributes'],'include':_0x45825d['include']?_[_0xed37('0x1b')](_0x45825d[_0xed37('0x1d')],function(_0x53f8cc){return{'model':db[_0x53f8cc[_0xed37('0x1c')]],'as':_0x53f8cc['as'],'attributes':_0x53f8cc[_0xed37('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xed37('0xc')](function(_0x477088){logger[_0xed37('0xd')](_0xed37('0x15'),_0x1a2236);logger[_0xed37('0x1e')](_0xed37('0x15'),_0x1a2236,JSON[_0xed37('0xf')](_0x477088));_0x5132f9(_0x477088);})[_0xed37('0x1f')](function(_0x1214f8){logger[_0xed37('0x10')]('ShowSquareOdbc',_0x1214f8[_0xed37('0x13')],_0x1a2236);_0x3e7473(_0x467079[_0xed37('0x10')](0x1f4,_0x1214f8[_0xed37('0x13')]));});});};