Built motion from commit 96f8de6d.|2.6.3
[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 _0x5f66=['ShowSquareOdbc','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','request','then','request\x20sent','debug','SquareOdbc,\x20%s,\x20%s,\x20%s','stringify','error','code','SquareOdbc,\x20%s,\x20%s','message','info','result','catch','SquareOdbc','options','raw','where','map','include','model','attributes'];(function(_0x381dfb,_0x51d3e2){var _0xf0a07=function(_0x16b767){while(--_0x16b767){_0x381dfb['push'](_0x381dfb['shift']());}};_0xf0a07(++_0x51d3e2);}(_0x5f66,0xe1));var _0x65f6=function(_0x278e3c,_0x1c9cfd){_0x278e3c=_0x278e3c-0x0;var _0x3e2d9b=_0x5f66[_0x278e3c];return _0x3e2d9b;};'use strict';var _=require('lodash');var util=require(_0x65f6('0x0'));var moment=require(_0x65f6('0x1'));var BPromise=require(_0x65f6('0x2'));var rs=require(_0x65f6('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x65f6('0x4'))['db'];var utils=require(_0x65f6('0x5'));var logger=require(_0x65f6('0x6'))('rpc');var config=require(_0x65f6('0x7'));var jayson=require(_0x65f6('0x8'));var client=jayson[_0x65f6('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x3713f4,_0x20206a,_0x346c55){return new BPromise(function(_0x53d747,_0x5515cd){return client[_0x65f6('0xa')](_0x3713f4,_0x346c55)[_0x65f6('0xb')](function(_0x573e00){logger['info']('SquareOdbc,\x20%s,\x20%s',_0x20206a,_0x65f6('0xc'));logger[_0x65f6('0xd')](_0x65f6('0xe'),_0x20206a,_0x65f6('0xc'),JSON[_0x65f6('0xf')](_0x573e00));if(_0x573e00[_0x65f6('0x10')]){if(_0x573e00[_0x65f6('0x10')][_0x65f6('0x11')]===0x1f4){logger[_0x65f6('0x10')](_0x65f6('0x12'),_0x20206a,_0x573e00[_0x65f6('0x10')][_0x65f6('0x13')]);return _0x5515cd(_0x573e00[_0x65f6('0x10')][_0x65f6('0x13')]);}logger[_0x65f6('0x10')](_0x65f6('0x12'),_0x20206a,_0x573e00['error'][_0x65f6('0x13')]);return _0x53d747(_0x573e00[_0x65f6('0x10')]['message']);}else{logger[_0x65f6('0x14')](_0x65f6('0x12'),_0x20206a,_0x65f6('0xc'));_0x53d747(_0x573e00[_0x65f6('0x15')]['message']);}})[_0x65f6('0x16')](function(_0x3211a4){logger[_0x65f6('0x10')](_0x65f6('0x12'),_0x20206a,_0x3211a4);_0x5515cd(_0x3211a4);});});}exports['ShowSquareOdbc']=function(_0x5c5bdc){var _0xca2e13=this;return new Promise(function(_0x2d08b5,_0x2aa7f5){return db[_0x65f6('0x17')]['find']({'raw':_0x5c5bdc[_0x65f6('0x18')]?_0x5c5bdc[_0x65f6('0x18')][_0x65f6('0x19')]===undefined?!![]:![]:!![],'where':_0x5c5bdc[_0x65f6('0x18')]?_0x5c5bdc[_0x65f6('0x18')][_0x65f6('0x1a')]||null:null,'attributes':_0x5c5bdc['options']?_0x5c5bdc[_0x65f6('0x18')]['attributes']||null:null,'include':_0x5c5bdc[_0x65f6('0x18')]?_0x5c5bdc[_0x65f6('0x18')]['include']?_[_0x65f6('0x1b')](_0x5c5bdc[_0x65f6('0x18')][_0x65f6('0x1c')],function(_0xc2b1fe){return{'model':db[_0xc2b1fe[_0x65f6('0x1d')]],'as':_0xc2b1fe['as'],'attributes':_0xc2b1fe[_0x65f6('0x1e')],'include':_0xc2b1fe['include']?_[_0x65f6('0x1b')](_0xc2b1fe[_0x65f6('0x1c')],function(_0x324cf9){return{'model':db[_0x324cf9[_0x65f6('0x1d')]],'as':_0x324cf9['as'],'attributes':_0x324cf9[_0x65f6('0x1e')],'include':_0x324cf9[_0x65f6('0x1c')]?_[_0x65f6('0x1b')](_0x324cf9[_0x65f6('0x1c')],function(_0x4cb3f3){return{'model':db[_0x4cb3f3[_0x65f6('0x1d')]],'as':_0x4cb3f3['as'],'attributes':_0x4cb3f3[_0x65f6('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x65f6('0xb')](function(_0x3dba60){logger[_0x65f6('0x14')](_0x65f6('0x1f'),_0x5c5bdc);logger[_0x65f6('0xd')](_0x65f6('0x1f'),_0x5c5bdc,JSON[_0x65f6('0xf')](_0x3dba60));_0x2d08b5(_0x3dba60);})[_0x65f6('0x16')](function(_0x112191){logger[_0x65f6('0x10')]('ShowSquareOdbc',_0x112191['message'],_0x5c5bdc);_0x2aa7f5(_0xca2e13[_0x65f6('0x10')](0x1f4,_0x112191[_0x65f6('0x13')]));});});};