Built motion from commit 753c950e.|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 _0x02de=['SquareOdbc,\x20%s,\x20%s','request\x20sent','debug','SquareOdbc,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','ShowSquareOdbc','options','raw','where','attributes','include','map','model','lodash','util','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','then','info'];(function(_0x184d50,_0x1b1c64){var _0x56e8e5=function(_0xda0ea9){while(--_0xda0ea9){_0x184d50['push'](_0x184d50['shift']());}};_0x56e8e5(++_0x1b1c64);}(_0x02de,0x92));var _0xe02d=function(_0x318331,_0xf58c63){_0x318331=_0x318331-0x0;var _0x1679a5=_0x02de[_0x318331];return _0x1679a5;};'use strict';var _=require(_0xe02d('0x0'));var util=require(_0xe02d('0x1'));var moment=require(_0xe02d('0x2'));var BPromise=require(_0xe02d('0x3'));var rs=require(_0xe02d('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xe02d('0x5'));var logger=require(_0xe02d('0x6'))(_0xe02d('0x7'));var config=require('../../config/environment');var jayson=require(_0xe02d('0x8'));var client=jayson[_0xe02d('0x9')][_0xe02d('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x4d0493,_0x280523,_0x351e4a){return new BPromise(function(_0x166296,_0x7a6a61){return client[_0xe02d('0xb')](_0x4d0493,_0x351e4a)[_0xe02d('0xc')](function(_0x18f8ed){logger[_0xe02d('0xd')](_0xe02d('0xe'),_0x280523,_0xe02d('0xf'));logger[_0xe02d('0x10')](_0xe02d('0x11'),_0x280523,_0xe02d('0xf'),JSON[_0xe02d('0x12')](_0x18f8ed));if(_0x18f8ed['error']){if(_0x18f8ed[_0xe02d('0x13')][_0xe02d('0x14')]===0x1f4){logger[_0xe02d('0x13')](_0xe02d('0xe'),_0x280523,_0x18f8ed[_0xe02d('0x13')][_0xe02d('0x15')]);return _0x7a6a61(_0x18f8ed['error'][_0xe02d('0x15')]);}logger[_0xe02d('0x13')](_0xe02d('0xe'),_0x280523,_0x18f8ed['error'][_0xe02d('0x15')]);return _0x166296(_0x18f8ed[_0xe02d('0x13')][_0xe02d('0x15')]);}else{logger[_0xe02d('0xd')](_0xe02d('0xe'),_0x280523,_0xe02d('0xf'));_0x166296(_0x18f8ed[_0xe02d('0x16')][_0xe02d('0x15')]);}})[_0xe02d('0x17')](function(_0x5529bc){logger[_0xe02d('0x13')](_0xe02d('0xe'),_0x280523,_0x5529bc);_0x7a6a61(_0x5529bc);});});}exports[_0xe02d('0x18')]=function(_0x11a920){var _0x23ac5a=this;return new Promise(function(_0x262eb0,_0x480076){return db['SquareOdbc']['find']({'raw':_0x11a920[_0xe02d('0x19')]?_0x11a920['options'][_0xe02d('0x1a')]===undefined?!![]:![]:!![],'where':_0x11a920[_0xe02d('0x19')]?_0x11a920[_0xe02d('0x19')][_0xe02d('0x1b')]||null:null,'attributes':_0x11a920[_0xe02d('0x19')]?_0x11a920[_0xe02d('0x19')][_0xe02d('0x1c')]||null:null,'include':_0x11a920[_0xe02d('0x19')]?_0x11a920['options'][_0xe02d('0x1d')]?_[_0xe02d('0x1e')](_0x11a920[_0xe02d('0x19')]['include'],function(_0x31fee2){return{'model':db[_0x31fee2['model']],'as':_0x31fee2['as'],'attributes':_0x31fee2[_0xe02d('0x1c')],'include':_0x31fee2[_0xe02d('0x1d')]?_['map'](_0x31fee2[_0xe02d('0x1d')],function(_0x5774e1){return{'model':db[_0x5774e1[_0xe02d('0x1f')]],'as':_0x5774e1['as'],'attributes':_0x5774e1[_0xe02d('0x1c')],'include':_0x5774e1[_0xe02d('0x1d')]?_[_0xe02d('0x1e')](_0x5774e1['include'],function(_0x2bda3e){return{'model':db[_0x2bda3e['model']],'as':_0x2bda3e['as'],'attributes':_0x2bda3e[_0xe02d('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x152a46){logger[_0xe02d('0xd')](_0xe02d('0x18'),_0x11a920);logger[_0xe02d('0x10')](_0xe02d('0x18'),_0x11a920,JSON[_0xe02d('0x12')](_0x152a46));_0x262eb0(_0x152a46);})[_0xe02d('0x17')](function(_0x5e60bf){logger[_0xe02d('0x13')](_0xe02d('0x18'),_0x5e60bf[_0xe02d('0x15')],_0x11a920);_0x480076(_0x23ac5a[_0xe02d('0x13')](0x1f4,_0x5e60bf[_0xe02d('0x15')]));});});};