Built motion from commit f74363e9.|2.6.34
[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 _0x9b92=['map','model','then','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','http','request','info','SquareOdbc,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','ShowSquareOdbc','SquareOdbc','find','options','raw','attributes','include'];(function(_0xb5874e,_0x45e344){var _0x197208=function(_0x21a8e8){while(--_0x21a8e8){_0xb5874e['push'](_0xb5874e['shift']());}};_0x197208(++_0x45e344);}(_0x9b92,0x99));var _0x29b9=function(_0x1a084f,_0x356cff){_0x1a084f=_0x1a084f-0x0;var _0x34a8de=_0x9b92[_0x1a084f];return _0x34a8de;};'use strict';var _=require(_0x29b9('0x0'));var util=require('util');var moment=require(_0x29b9('0x1'));var BPromise=require(_0x29b9('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x29b9('0x3'));var db=require(_0x29b9('0x4'))['db'];var utils=require(_0x29b9('0x5'));var logger=require('../../config/logger')(_0x29b9('0x6'));var config=require(_0x29b9('0x7'));var jayson=require(_0x29b9('0x8'));var client=jayson['client'][_0x29b9('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x37b4cc,_0x35a31d,_0x2005c2){return new BPromise(function(_0x30be05,_0x4636da){return client[_0x29b9('0xa')](_0x37b4cc,_0x2005c2)['then'](function(_0x2174c2){logger[_0x29b9('0xb')](_0x29b9('0xc'),_0x35a31d,_0x29b9('0xd'));logger[_0x29b9('0xe')]('SquareOdbc,\x20%s,\x20%s,\x20%s',_0x35a31d,_0x29b9('0xd'),JSON[_0x29b9('0xf')](_0x2174c2));if(_0x2174c2['error']){if(_0x2174c2[_0x29b9('0x10')][_0x29b9('0x11')]===0x1f4){logger[_0x29b9('0x10')](_0x29b9('0xc'),_0x35a31d,_0x2174c2[_0x29b9('0x10')][_0x29b9('0x12')]);return _0x4636da(_0x2174c2[_0x29b9('0x10')][_0x29b9('0x12')]);}logger['error'](_0x29b9('0xc'),_0x35a31d,_0x2174c2[_0x29b9('0x10')][_0x29b9('0x12')]);return _0x30be05(_0x2174c2[_0x29b9('0x10')][_0x29b9('0x12')]);}else{logger[_0x29b9('0xb')](_0x29b9('0xc'),_0x35a31d,_0x29b9('0xd'));_0x30be05(_0x2174c2[_0x29b9('0x13')][_0x29b9('0x12')]);}})['catch'](function(_0x24a65c){logger[_0x29b9('0x10')]('SquareOdbc,\x20%s,\x20%s',_0x35a31d,_0x24a65c);_0x4636da(_0x24a65c);});});}exports[_0x29b9('0x14')]=function(_0x5406b5){var _0x3bc6c9=this;return new Promise(function(_0x5b815d,_0xbefb33){return db[_0x29b9('0x15')][_0x29b9('0x16')]({'raw':_0x5406b5[_0x29b9('0x17')]?_0x5406b5[_0x29b9('0x17')][_0x29b9('0x18')]===undefined?!![]:![]:!![],'where':_0x5406b5[_0x29b9('0x17')]?_0x5406b5[_0x29b9('0x17')]['where']||null:null,'attributes':_0x5406b5[_0x29b9('0x17')]?_0x5406b5[_0x29b9('0x17')][_0x29b9('0x19')]||null:null,'include':_0x5406b5[_0x29b9('0x17')]?_0x5406b5[_0x29b9('0x17')][_0x29b9('0x1a')]?_[_0x29b9('0x1b')](_0x5406b5[_0x29b9('0x17')]['include'],function(_0x1a1d77){return{'model':db[_0x1a1d77[_0x29b9('0x1c')]],'as':_0x1a1d77['as'],'attributes':_0x1a1d77[_0x29b9('0x19')],'include':_0x1a1d77[_0x29b9('0x1a')]?_[_0x29b9('0x1b')](_0x1a1d77[_0x29b9('0x1a')],function(_0x338815){return{'model':db[_0x338815[_0x29b9('0x1c')]],'as':_0x338815['as'],'attributes':_0x338815[_0x29b9('0x19')],'include':_0x338815[_0x29b9('0x1a')]?_[_0x29b9('0x1b')](_0x338815[_0x29b9('0x1a')],function(_0x3844c4){return{'model':db[_0x3844c4[_0x29b9('0x1c')]],'as':_0x3844c4['as'],'attributes':_0x3844c4[_0x29b9('0x19')]};}):[]};}):[]};}):[]:[]})[_0x29b9('0x1d')](function(_0x4a452c){logger[_0x29b9('0xb')](_0x29b9('0x14'),_0x5406b5);logger[_0x29b9('0xe')](_0x29b9('0x14'),_0x5406b5,JSON['stringify'](_0x4a452c));_0x5b815d(_0x4a452c);})['catch'](function(_0x353300){logger[_0x29b9('0x10')](_0x29b9('0x14'),_0x353300['message'],_0x5406b5);_0xbefb33(_0x3bc6c9[_0x29b9('0x10')](0x1f4,_0x353300[_0x29b9('0x12')]));});});};