Built motion from commit d1eab355.|2.6.28
[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 _0x752b=['SquareOdbc,\x20%s,\x20%s','result','ShowSquareOdbc','SquareOdbc','find','raw','options','where','attributes','include','map','model','debug','catch','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/environment','client','http','info','request\x20sent','SquareOdbc,\x20%s,\x20%s,\x20%s','stringify','error','code','message'];(function(_0x552d37,_0x564b7a){var _0x5e328a=function(_0x531a9f){while(--_0x531a9f){_0x552d37['push'](_0x552d37['shift']());}};_0x5e328a(++_0x564b7a);}(_0x752b,0x176));var _0xb752=function(_0x52cbd8,_0x31940e){_0x52cbd8=_0x52cbd8-0x0;var _0x34cbf1=_0x752b[_0x52cbd8];return _0x34cbf1;};'use strict';var _=require(_0xb752('0x0'));var util=require('util');var moment=require(_0xb752('0x1'));var BPromise=require(_0xb752('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb752('0x3'));var db=require(_0xb752('0x4'))['db'];var utils=require(_0xb752('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0xb752('0x6'));var jayson=require('jayson/promise');var client=jayson[_0xb752('0x7')][_0xb752('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x2d4f1e,_0x5a1030,_0x185540){return new BPromise(function(_0x404795,_0x2b395a){return client['request'](_0x2d4f1e,_0x185540)['then'](function(_0x51869b){logger[_0xb752('0x9')]('SquareOdbc,\x20%s,\x20%s',_0x5a1030,_0xb752('0xa'));logger['debug'](_0xb752('0xb'),_0x5a1030,_0xb752('0xa'),JSON[_0xb752('0xc')](_0x51869b));if(_0x51869b[_0xb752('0xd')]){if(_0x51869b[_0xb752('0xd')][_0xb752('0xe')]===0x1f4){logger[_0xb752('0xd')]('SquareOdbc,\x20%s,\x20%s',_0x5a1030,_0x51869b['error']['message']);return _0x2b395a(_0x51869b['error'][_0xb752('0xf')]);}logger['error'](_0xb752('0x10'),_0x5a1030,_0x51869b[_0xb752('0xd')][_0xb752('0xf')]);return _0x404795(_0x51869b['error'][_0xb752('0xf')]);}else{logger[_0xb752('0x9')]('SquareOdbc,\x20%s,\x20%s',_0x5a1030,_0xb752('0xa'));_0x404795(_0x51869b[_0xb752('0x11')][_0xb752('0xf')]);}})['catch'](function(_0x29d0e6){logger[_0xb752('0xd')](_0xb752('0x10'),_0x5a1030,_0x29d0e6);_0x2b395a(_0x29d0e6);});});}exports[_0xb752('0x12')]=function(_0x554322){var _0x3bd3eb=this;return new Promise(function(_0x4bf5c9,_0x1a0695){return db[_0xb752('0x13')][_0xb752('0x14')]({'raw':_0x554322['options']?_0x554322['options'][_0xb752('0x15')]===undefined?!![]:![]:!![],'where':_0x554322[_0xb752('0x16')]?_0x554322[_0xb752('0x16')][_0xb752('0x17')]||null:null,'attributes':_0x554322[_0xb752('0x16')]?_0x554322[_0xb752('0x16')][_0xb752('0x18')]||null:null,'include':_0x554322['options']?_0x554322[_0xb752('0x16')][_0xb752('0x19')]?_[_0xb752('0x1a')](_0x554322[_0xb752('0x16')]['include'],function(_0x5f27e1){return{'model':db[_0x5f27e1[_0xb752('0x1b')]],'as':_0x5f27e1['as'],'attributes':_0x5f27e1[_0xb752('0x18')],'include':_0x5f27e1[_0xb752('0x19')]?_[_0xb752('0x1a')](_0x5f27e1[_0xb752('0x19')],function(_0x3be202){return{'model':db[_0x3be202[_0xb752('0x1b')]],'as':_0x3be202['as'],'attributes':_0x3be202[_0xb752('0x18')],'include':_0x3be202['include']?_['map'](_0x3be202[_0xb752('0x19')],function(_0x18e580){return{'model':db[_0x18e580[_0xb752('0x1b')]],'as':_0x18e580['as'],'attributes':_0x18e580[_0xb752('0x18')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x315409){logger[_0xb752('0x9')](_0xb752('0x12'),_0x554322);logger[_0xb752('0x1c')](_0xb752('0x12'),_0x554322,JSON[_0xb752('0xc')](_0x315409));_0x4bf5c9(_0x315409);})[_0xb752('0x1d')](function(_0x342663){logger['error']('ShowSquareOdbc',_0x342663[_0xb752('0xf')],_0x554322);_0x1a0695(_0x3bd3eb['error'](0x1f4,_0x342663[_0xb752('0xf')]));});});};