Built motion from commit a679711e.|2.6.15
[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 _0xc524=['jayson/promise','http','request','then','SquareOdbc,\x20%s,\x20%s','request\x20sent','debug','SquareOdbc,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','options','where','attributes','include','map','model','ShowSquareOdbc','moment','bluebird','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment'];(function(_0x55cf47,_0x3d037b){var _0x42bf2b=function(_0x2edd84){while(--_0x2edd84){_0x55cf47['push'](_0x55cf47['shift']());}};_0x42bf2b(++_0x3d037b);}(_0xc524,0xfe));var _0x4c52=function(_0x459da7,_0xcab10d){_0x459da7=_0x459da7-0x0;var _0x580207=_0xc524[_0x459da7];return _0x580207;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x4c52('0x0'));var BPromise=require(_0x4c52('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x4c52('0x2'));var db=require(_0x4c52('0x3'))['db'];var utils=require(_0x4c52('0x4'));var logger=require('../../config/logger')(_0x4c52('0x5'));var config=require(_0x4c52('0x6'));var jayson=require(_0x4c52('0x7'));var client=jayson['client'][_0x4c52('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x167bbf,_0x399ef1,_0x574682){return new BPromise(function(_0x5a0ab8,_0x3c6cfe){return client[_0x4c52('0x9')](_0x167bbf,_0x574682)[_0x4c52('0xa')](function(_0x1852ed){logger['info'](_0x4c52('0xb'),_0x399ef1,_0x4c52('0xc'));logger[_0x4c52('0xd')](_0x4c52('0xe'),_0x399ef1,_0x4c52('0xc'),JSON[_0x4c52('0xf')](_0x1852ed));if(_0x1852ed['error']){if(_0x1852ed[_0x4c52('0x10')][_0x4c52('0x11')]===0x1f4){logger['error'](_0x4c52('0xb'),_0x399ef1,_0x1852ed[_0x4c52('0x10')][_0x4c52('0x12')]);return _0x3c6cfe(_0x1852ed['error'][_0x4c52('0x12')]);}logger[_0x4c52('0x10')]('SquareOdbc,\x20%s,\x20%s',_0x399ef1,_0x1852ed[_0x4c52('0x10')][_0x4c52('0x12')]);return _0x5a0ab8(_0x1852ed[_0x4c52('0x10')]['message']);}else{logger[_0x4c52('0x13')](_0x4c52('0xb'),_0x399ef1,_0x4c52('0xc'));_0x5a0ab8(_0x1852ed[_0x4c52('0x14')][_0x4c52('0x12')]);}})[_0x4c52('0x15')](function(_0x389464){logger[_0x4c52('0x10')](_0x4c52('0xb'),_0x399ef1,_0x389464);_0x3c6cfe(_0x389464);});});}exports['ShowSquareOdbc']=function(_0xc992c9){var _0x3ef071=this;return new Promise(function(_0x19bd4b,_0x48ab9d){return db['SquareOdbc']['find']({'raw':_0xc992c9['options']?_0xc992c9[_0x4c52('0x16')]['raw']===undefined?!![]:![]:!![],'where':_0xc992c9['options']?_0xc992c9[_0x4c52('0x16')][_0x4c52('0x17')]||null:null,'attributes':_0xc992c9[_0x4c52('0x16')]?_0xc992c9[_0x4c52('0x16')][_0x4c52('0x18')]||null:null,'include':_0xc992c9[_0x4c52('0x16')]?_0xc992c9[_0x4c52('0x16')][_0x4c52('0x19')]?_['map'](_0xc992c9[_0x4c52('0x16')]['include'],function(_0x52039d){return{'model':db[_0x52039d['model']],'as':_0x52039d['as'],'attributes':_0x52039d[_0x4c52('0x18')],'include':_0x52039d[_0x4c52('0x19')]?_[_0x4c52('0x1a')](_0x52039d['include'],function(_0x2a5e5b){return{'model':db[_0x2a5e5b[_0x4c52('0x1b')]],'as':_0x2a5e5b['as'],'attributes':_0x2a5e5b[_0x4c52('0x18')],'include':_0x2a5e5b[_0x4c52('0x19')]?_['map'](_0x2a5e5b[_0x4c52('0x19')],function(_0x4b23f8){return{'model':db[_0x4b23f8['model']],'as':_0x4b23f8['as'],'attributes':_0x4b23f8[_0x4c52('0x18')]};}):[]};}):[]};}):[]:[]})[_0x4c52('0xa')](function(_0x5c0378){logger[_0x4c52('0x13')](_0x4c52('0x1c'),_0xc992c9);logger[_0x4c52('0xd')](_0x4c52('0x1c'),_0xc992c9,JSON[_0x4c52('0xf')](_0x5c0378));_0x19bd4b(_0x5c0378);})[_0x4c52('0x15')](function(_0x5da9a1){logger[_0x4c52('0x10')](_0x4c52('0x1c'),_0x5da9a1[_0x4c52('0x12')],_0xc992c9);_0x48ab9d(_0x3ef071['error'](0x1f4,_0x5da9a1[_0x4c52('0x12')]));});});};