42d0b713b984f3e770943ddd5f4f8d66cc066fd5
[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 _0x82c6=['options','where','attributes','include','map','model','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','jayson/promise','client','http','then','SquareOdbc,\x20%s,\x20%s','debug','error','code','message','info','request\x20sent','result','catch','ShowSquareOdbc','SquareOdbc'];(function(_0x21aec3,_0x5c97e9){var _0x288bbc=function(_0x2283fe){while(--_0x2283fe){_0x21aec3['push'](_0x21aec3['shift']());}};_0x288bbc(++_0x5c97e9);}(_0x82c6,0xd8));var _0x682c=function(_0x298ed3,_0x4ab5e1){_0x298ed3=_0x298ed3-0x0;var _0x5aad28=_0x82c6[_0x298ed3];return _0x5aad28;};'use strict';var _=require(_0x682c('0x0'));var util=require(_0x682c('0x1'));var moment=require(_0x682c('0x2'));var BPromise=require(_0x682c('0x3'));var rs=require(_0x682c('0x4'));var fs=require('fs');var Redis=require(_0x682c('0x5'));var db=require(_0x682c('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x682c('0x7'))(_0x682c('0x8'));var config=require('../../config/environment');var jayson=require(_0x682c('0x9'));var client=jayson[_0x682c('0xa')][_0x682c('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x5d9d8e,_0x1b76da,_0x44aed1){return new BPromise(function(_0x14add6,_0x5b5646){return client['request'](_0x5d9d8e,_0x44aed1)[_0x682c('0xc')](function(_0x401e69){logger['info'](_0x682c('0xd'),_0x1b76da,'request\x20sent');logger[_0x682c('0xe')]('SquareOdbc,\x20%s,\x20%s,\x20%s',_0x1b76da,'request\x20sent',JSON['stringify'](_0x401e69));if(_0x401e69['error']){if(_0x401e69[_0x682c('0xf')][_0x682c('0x10')]===0x1f4){logger[_0x682c('0xf')](_0x682c('0xd'),_0x1b76da,_0x401e69[_0x682c('0xf')][_0x682c('0x11')]);return _0x5b5646(_0x401e69['error']['message']);}logger[_0x682c('0xf')]('SquareOdbc,\x20%s,\x20%s',_0x1b76da,_0x401e69[_0x682c('0xf')][_0x682c('0x11')]);return _0x14add6(_0x401e69[_0x682c('0xf')][_0x682c('0x11')]);}else{logger[_0x682c('0x12')]('SquareOdbc,\x20%s,\x20%s',_0x1b76da,_0x682c('0x13'));_0x14add6(_0x401e69[_0x682c('0x14')][_0x682c('0x11')]);}})[_0x682c('0x15')](function(_0x560e3c){logger[_0x682c('0xf')](_0x682c('0xd'),_0x1b76da,_0x560e3c);_0x5b5646(_0x560e3c);});});}exports[_0x682c('0x16')]=function(_0xa9edd6){var _0x16d16a=this;return new Promise(function(_0x2d9542,_0x1ed65b){return db[_0x682c('0x17')]['find']({'raw':_0xa9edd6[_0x682c('0x18')]?_0xa9edd6[_0x682c('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0xa9edd6[_0x682c('0x18')]?_0xa9edd6[_0x682c('0x18')][_0x682c('0x19')]||null:null,'attributes':_0xa9edd6[_0x682c('0x18')]?_0xa9edd6[_0x682c('0x18')][_0x682c('0x1a')]||null:null,'include':_0xa9edd6[_0x682c('0x18')]?_0xa9edd6[_0x682c('0x18')][_0x682c('0x1b')]?_[_0x682c('0x1c')](_0xa9edd6['options'][_0x682c('0x1b')],function(_0x2d6fce){return{'model':db[_0x2d6fce[_0x682c('0x1d')]],'as':_0x2d6fce['as'],'attributes':_0x2d6fce[_0x682c('0x1a')],'include':_0x2d6fce[_0x682c('0x1b')]?_[_0x682c('0x1c')](_0x2d6fce[_0x682c('0x1b')],function(_0xed8604){return{'model':db[_0xed8604[_0x682c('0x1d')]],'as':_0xed8604['as'],'attributes':_0xed8604[_0x682c('0x1a')],'include':_0xed8604['include']?_[_0x682c('0x1c')](_0xed8604['include'],function(_0x505aec){return{'model':db[_0x505aec[_0x682c('0x1d')]],'as':_0x505aec['as'],'attributes':_0x505aec[_0x682c('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x682c('0xc')](function(_0x2fcd52){logger[_0x682c('0x12')](_0x682c('0x16'),_0xa9edd6);logger[_0x682c('0xe')]('ShowSquareOdbc',_0xa9edd6,JSON['stringify'](_0x2fcd52));_0x2d9542(_0x2fcd52);})[_0x682c('0x15')](function(_0x3ae7bc){logger['error'](_0x682c('0x16'),_0x3ae7bc[_0x682c('0x11')],_0xa9edd6);_0x1ed65b(_0x16d16a['error'](0x1f4,_0x3ae7bc['message']));});});};