07b728341b5c187e9a18507ba47fda7393712b30
[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 _0xce0f=['catch','ShowSquareOdbc','SquareOdbc','options','raw','where','attributes','map','model','include','debug','lodash','util','moment','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','request\x20sent','SquareOdbc,\x20%s,\x20%s,\x20%s','stringify','error','code','SquareOdbc,\x20%s,\x20%s','message','result'];(function(_0x18d8fd,_0x1e86d1){var _0x1c7ba7=function(_0x2690e7){while(--_0x2690e7){_0x18d8fd['push'](_0x18d8fd['shift']());}};_0x1c7ba7(++_0x1e86d1);}(_0xce0f,0x15f));var _0xfce0=function(_0x8e8e6a,_0x5080ea){_0x8e8e6a=_0x8e8e6a-0x0;var _0x2a6d8a=_0xce0f[_0x8e8e6a];return _0x2a6d8a;};'use strict';var _=require(_0xfce0('0x0'));var util=require(_0xfce0('0x1'));var moment=require(_0xfce0('0x2'));var BPromise=require('bluebird');var rs=require(_0xfce0('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xfce0('0x4'))['db'];var utils=require(_0xfce0('0x5'));var logger=require(_0xfce0('0x6'))(_0xfce0('0x7'));var config=require(_0xfce0('0x8'));var jayson=require(_0xfce0('0x9'));var client=jayson[_0xfce0('0xa')][_0xfce0('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x286a01,_0x131714,_0x2ff7e4){return new BPromise(function(_0x1ae9e3,_0x2477b9){return client[_0xfce0('0xc')](_0x286a01,_0x2ff7e4)[_0xfce0('0xd')](function(_0x570ff3){logger[_0xfce0('0xe')]('SquareOdbc,\x20%s,\x20%s',_0x131714,_0xfce0('0xf'));logger['debug'](_0xfce0('0x10'),_0x131714,'request\x20sent',JSON[_0xfce0('0x11')](_0x570ff3));if(_0x570ff3[_0xfce0('0x12')]){if(_0x570ff3['error'][_0xfce0('0x13')]===0x1f4){logger[_0xfce0('0x12')](_0xfce0('0x14'),_0x131714,_0x570ff3[_0xfce0('0x12')][_0xfce0('0x15')]);return _0x2477b9(_0x570ff3[_0xfce0('0x12')]['message']);}logger[_0xfce0('0x12')](_0xfce0('0x14'),_0x131714,_0x570ff3[_0xfce0('0x12')][_0xfce0('0x15')]);return _0x1ae9e3(_0x570ff3[_0xfce0('0x12')]['message']);}else{logger['info'](_0xfce0('0x14'),_0x131714,'request\x20sent');_0x1ae9e3(_0x570ff3[_0xfce0('0x16')]['message']);}})[_0xfce0('0x17')](function(_0x1fb181){logger[_0xfce0('0x12')](_0xfce0('0x14'),_0x131714,_0x1fb181);_0x2477b9(_0x1fb181);});});}exports[_0xfce0('0x18')]=function(_0x359147){var _0x588215=this;return new Promise(function(_0x272954,_0x8e8cee){return db[_0xfce0('0x19')]['find']({'raw':_0x359147[_0xfce0('0x1a')]?_0x359147[_0xfce0('0x1a')][_0xfce0('0x1b')]===undefined?!![]:![]:!![],'where':_0x359147[_0xfce0('0x1a')]?_0x359147[_0xfce0('0x1a')][_0xfce0('0x1c')]||null:null,'attributes':_0x359147['options']?_0x359147[_0xfce0('0x1a')][_0xfce0('0x1d')]||null:null,'include':_0x359147['options']?_0x359147[_0xfce0('0x1a')]['include']?_[_0xfce0('0x1e')](_0x359147[_0xfce0('0x1a')]['include'],function(_0x4642d0){return{'model':db[_0x4642d0[_0xfce0('0x1f')]],'as':_0x4642d0['as'],'attributes':_0x4642d0[_0xfce0('0x1d')],'include':_0x4642d0[_0xfce0('0x20')]?_[_0xfce0('0x1e')](_0x4642d0['include'],function(_0x3714f2){return{'model':db[_0x3714f2['model']],'as':_0x3714f2['as'],'attributes':_0x3714f2['attributes'],'include':_0x3714f2[_0xfce0('0x20')]?_[_0xfce0('0x1e')](_0x3714f2['include'],function(_0x437e98){return{'model':db[_0x437e98[_0xfce0('0x1f')]],'as':_0x437e98['as'],'attributes':_0x437e98[_0xfce0('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xfce0('0xd')](function(_0x1cefa3){logger[_0xfce0('0xe')]('ShowSquareOdbc',_0x359147);logger[_0xfce0('0x21')](_0xfce0('0x18'),_0x359147,JSON['stringify'](_0x1cefa3));_0x272954(_0x1cefa3);})['catch'](function(_0x316504){logger[_0xfce0('0x12')]('ShowSquareOdbc',_0x316504[_0xfce0('0x15')],_0x359147);_0x8e8cee(_0x588215['error'](0x1f4,_0x316504[_0xfce0('0x15')]));});});};