Built motion from commit ab870f9e.|2.5.44
[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 _0x3fec=['ShowSquareOdbc','find','options','include','model','attributes','map','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','debug','SquareOdbc,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','SquareOdbc,\x20%s,\x20%s','message','result','catch'];(function(_0x2bb96b,_0x4352f6){var _0x669d2d=function(_0x38131c){while(--_0x38131c){_0x2bb96b['push'](_0x2bb96b['shift']());}};_0x669d2d(++_0x4352f6);}(_0x3fec,0x167));var _0xc3fe=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x3fec[_0x14add3];return _0x4a174f;};'use strict';var _=require('lodash');var util=require(_0xc3fe('0x0'));var moment=require(_0xc3fe('0x1'));var BPromise=require('bluebird');var rs=require(_0xc3fe('0x2'));var fs=require('fs');var Redis=require(_0xc3fe('0x3'));var db=require(_0xc3fe('0x4'))['db'];var utils=require(_0xc3fe('0x5'));var logger=require(_0xc3fe('0x6'))(_0xc3fe('0x7'));var config=require(_0xc3fe('0x8'));var jayson=require(_0xc3fe('0x9'));var client=jayson[_0xc3fe('0xa')][_0xc3fe('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x59cd71,_0x152d3c,_0x510986){return new BPromise(function(_0x1ba9c0,_0x2d617e){return client[_0xc3fe('0xc')](_0x59cd71,_0x510986)[_0xc3fe('0xd')](function(_0xdb5c60){logger[_0xc3fe('0xe')]('SquareOdbc,\x20%s,\x20%s',_0x152d3c,'request\x20sent');logger[_0xc3fe('0xf')](_0xc3fe('0x10'),_0x152d3c,_0xc3fe('0x11'),JSON[_0xc3fe('0x12')](_0xdb5c60));if(_0xdb5c60[_0xc3fe('0x13')]){if(_0xdb5c60[_0xc3fe('0x13')][_0xc3fe('0x14')]===0x1f4){logger[_0xc3fe('0x13')](_0xc3fe('0x15'),_0x152d3c,_0xdb5c60['error'][_0xc3fe('0x16')]);return _0x2d617e(_0xdb5c60[_0xc3fe('0x13')][_0xc3fe('0x16')]);}logger[_0xc3fe('0x13')](_0xc3fe('0x15'),_0x152d3c,_0xdb5c60[_0xc3fe('0x13')][_0xc3fe('0x16')]);return _0x1ba9c0(_0xdb5c60['error'][_0xc3fe('0x16')]);}else{logger[_0xc3fe('0xe')]('SquareOdbc,\x20%s,\x20%s',_0x152d3c,'request\x20sent');_0x1ba9c0(_0xdb5c60[_0xc3fe('0x17')][_0xc3fe('0x16')]);}})[_0xc3fe('0x18')](function(_0x2ae770){logger[_0xc3fe('0x13')]('SquareOdbc,\x20%s,\x20%s',_0x152d3c,_0x2ae770);_0x2d617e(_0x2ae770);});});}exports[_0xc3fe('0x19')]=function(_0x13e133){var _0x487b55=this;return new Promise(function(_0x64a811,_0x484b8e){return db['SquareOdbc'][_0xc3fe('0x1a')]({'raw':_0x13e133[_0xc3fe('0x1b')]?_0x13e133['options']['raw']===undefined?!![]:![]:!![],'where':_0x13e133['options']?_0x13e133[_0xc3fe('0x1b')]['where']||null:null,'attributes':_0x13e133[_0xc3fe('0x1b')]?_0x13e133[_0xc3fe('0x1b')]['attributes']||null:null,'include':_0x13e133[_0xc3fe('0x1b')]?_0x13e133[_0xc3fe('0x1b')][_0xc3fe('0x1c')]?_['map'](_0x13e133[_0xc3fe('0x1b')]['include'],function(_0x13ec12){return{'model':db[_0x13ec12[_0xc3fe('0x1d')]],'as':_0x13ec12['as'],'attributes':_0x13ec12[_0xc3fe('0x1e')],'include':_0x13ec12[_0xc3fe('0x1c')]?_[_0xc3fe('0x1f')](_0x13ec12[_0xc3fe('0x1c')],function(_0x41206f){return{'model':db[_0x41206f['model']],'as':_0x41206f['as'],'attributes':_0x41206f[_0xc3fe('0x1e')],'include':_0x41206f[_0xc3fe('0x1c')]?_['map'](_0x41206f[_0xc3fe('0x1c')],function(_0x39d809){return{'model':db[_0x39d809[_0xc3fe('0x1d')]],'as':_0x39d809['as'],'attributes':_0x39d809[_0xc3fe('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xc3fe('0xd')](function(_0x43c8b4){logger[_0xc3fe('0xe')](_0xc3fe('0x19'),_0x13e133);logger[_0xc3fe('0xf')](_0xc3fe('0x19'),_0x13e133,JSON[_0xc3fe('0x12')](_0x43c8b4));_0x64a811(_0x43c8b4);})[_0xc3fe('0x18')](function(_0x30fea0){logger[_0xc3fe('0x13')](_0xc3fe('0x19'),_0x30fea0[_0xc3fe('0x16')],_0x13e133);_0x484b8e(_0x487b55[_0xc3fe('0x13')](0x1f4,_0x30fea0[_0xc3fe('0x16')]));});});};