Built motion from commit 449495f6.|2.6.27
[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 _0xe17f=['moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','http','request','then','info','SquareOdbc,\x20%s,\x20%s','debug','SquareOdbc,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','SquareOdbc','find','options','where','attributes','include','map','model','lodash'];(function(_0x104e21,_0x2ea86f){var _0x605b37=function(_0x580fce){while(--_0x580fce){_0x104e21['push'](_0x104e21['shift']());}};_0x605b37(++_0x2ea86f);}(_0xe17f,0x12b));var _0xfe17=function(_0x57b11d,_0x207df6){_0x57b11d=_0x57b11d-0x0;var _0x3c9c53=_0xe17f[_0x57b11d];return _0x3c9c53;};'use strict';var _=require(_0xfe17('0x0'));var util=require('util');var moment=require(_0xfe17('0x1'));var BPromise=require(_0xfe17('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xfe17('0x3'));var db=require(_0xfe17('0x4'))['db'];var utils=require(_0xfe17('0x5'));var logger=require(_0xfe17('0x6'))(_0xfe17('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0xfe17('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x47f82f,_0x44a568,_0x434f6f){return new BPromise(function(_0x54b97c,_0x317efb){return client[_0xfe17('0x9')](_0x47f82f,_0x434f6f)[_0xfe17('0xa')](function(_0x395cc8){logger[_0xfe17('0xb')](_0xfe17('0xc'),_0x44a568,'request\x20sent');logger[_0xfe17('0xd')](_0xfe17('0xe'),_0x44a568,_0xfe17('0xf'),JSON[_0xfe17('0x10')](_0x395cc8));if(_0x395cc8[_0xfe17('0x11')]){if(_0x395cc8[_0xfe17('0x11')][_0xfe17('0x12')]===0x1f4){logger[_0xfe17('0x11')](_0xfe17('0xc'),_0x44a568,_0x395cc8[_0xfe17('0x11')]['message']);return _0x317efb(_0x395cc8['error'][_0xfe17('0x13')]);}logger['error'](_0xfe17('0xc'),_0x44a568,_0x395cc8[_0xfe17('0x11')][_0xfe17('0x13')]);return _0x54b97c(_0x395cc8['error']['message']);}else{logger[_0xfe17('0xb')](_0xfe17('0xc'),_0x44a568,_0xfe17('0xf'));_0x54b97c(_0x395cc8[_0xfe17('0x14')][_0xfe17('0x13')]);}})[_0xfe17('0x15')](function(_0x56ba40){logger[_0xfe17('0x11')](_0xfe17('0xc'),_0x44a568,_0x56ba40);_0x317efb(_0x56ba40);});});}exports['ShowSquareOdbc']=function(_0xee59ce){var _0x1dfc2f=this;return new Promise(function(_0x3a396e,_0x597ca4){return db[_0xfe17('0x16')][_0xfe17('0x17')]({'raw':_0xee59ce[_0xfe17('0x18')]?_0xee59ce[_0xfe17('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0xee59ce[_0xfe17('0x18')]?_0xee59ce[_0xfe17('0x18')][_0xfe17('0x19')]||null:null,'attributes':_0xee59ce[_0xfe17('0x18')]?_0xee59ce['options'][_0xfe17('0x1a')]||null:null,'include':_0xee59ce['options']?_0xee59ce[_0xfe17('0x18')][_0xfe17('0x1b')]?_[_0xfe17('0x1c')](_0xee59ce[_0xfe17('0x18')][_0xfe17('0x1b')],function(_0x5140d5){return{'model':db[_0x5140d5[_0xfe17('0x1d')]],'as':_0x5140d5['as'],'attributes':_0x5140d5[_0xfe17('0x1a')],'include':_0x5140d5[_0xfe17('0x1b')]?_[_0xfe17('0x1c')](_0x5140d5[_0xfe17('0x1b')],function(_0x5f5332){return{'model':db[_0x5f5332['model']],'as':_0x5f5332['as'],'attributes':_0x5f5332['attributes'],'include':_0x5f5332[_0xfe17('0x1b')]?_[_0xfe17('0x1c')](_0x5f5332[_0xfe17('0x1b')],function(_0x5e5f76){return{'model':db[_0x5e5f76[_0xfe17('0x1d')]],'as':_0x5e5f76['as'],'attributes':_0x5e5f76[_0xfe17('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x38e9b9){logger[_0xfe17('0xb')]('ShowSquareOdbc',_0xee59ce);logger[_0xfe17('0xd')]('ShowSquareOdbc',_0xee59ce,JSON[_0xfe17('0x10')](_0x38e9b9));_0x3a396e(_0x38e9b9);})[_0xfe17('0x15')](function(_0x6c0324){logger[_0xfe17('0x11')]('ShowSquareOdbc',_0x6c0324[_0xfe17('0x13')],_0xee59ce);_0x597ca4(_0x1dfc2f['error'](0x1f4,_0x6c0324['message']));});});};