Built motion from commit 85328c08.|2.5.50
[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 _0x4e76=['options','raw','where','include','model','map','attributes','lodash','util','moment','bluebird','ioredis','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','then','info','debug','SquareOdbc,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','SquareOdbc,\x20%s,\x20%s','result','ShowSquareOdbc'];(function(_0x6131cd,_0x4c26a1){var _0x47e916=function(_0x1f2bce){while(--_0x1f2bce){_0x6131cd['push'](_0x6131cd['shift']());}};_0x47e916(++_0x4c26a1);}(_0x4e76,0x1b9));var _0x64e7=function(_0x2360a0,_0x303a69){_0x2360a0=_0x2360a0-0x0;var _0x40055e=_0x4e76[_0x2360a0];return _0x40055e;};'use strict';var _=require(_0x64e7('0x0'));var util=require(_0x64e7('0x1'));var moment=require(_0x64e7('0x2'));var BPromise=require(_0x64e7('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x64e7('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x64e7('0x5'));var logger=require(_0x64e7('0x6'))(_0x64e7('0x7'));var config=require('../../config/environment');var jayson=require(_0x64e7('0x8'));var client=jayson[_0x64e7('0x9')][_0x64e7('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x22c8cb,_0x335252,_0x33d1e2){return new BPromise(function(_0x32779a,_0x248e43){return client[_0x64e7('0xb')](_0x22c8cb,_0x33d1e2)[_0x64e7('0xc')](function(_0x80a939){logger[_0x64e7('0xd')]('SquareOdbc,\x20%s,\x20%s',_0x335252,'request\x20sent');logger[_0x64e7('0xe')](_0x64e7('0xf'),_0x335252,_0x64e7('0x10'),JSON[_0x64e7('0x11')](_0x80a939));if(_0x80a939[_0x64e7('0x12')]){if(_0x80a939[_0x64e7('0x12')][_0x64e7('0x13')]===0x1f4){logger[_0x64e7('0x12')]('SquareOdbc,\x20%s,\x20%s',_0x335252,_0x80a939['error'][_0x64e7('0x14')]);return _0x248e43(_0x80a939[_0x64e7('0x12')][_0x64e7('0x14')]);}logger[_0x64e7('0x12')]('SquareOdbc,\x20%s,\x20%s',_0x335252,_0x80a939['error'][_0x64e7('0x14')]);return _0x32779a(_0x80a939[_0x64e7('0x12')]['message']);}else{logger['info'](_0x64e7('0x15'),_0x335252,'request\x20sent');_0x32779a(_0x80a939[_0x64e7('0x16')]['message']);}})['catch'](function(_0x21a5c2){logger['error']('SquareOdbc,\x20%s,\x20%s',_0x335252,_0x21a5c2);_0x248e43(_0x21a5c2);});});}exports[_0x64e7('0x17')]=function(_0x1d6a57){var _0x16171b=this;return new Promise(function(_0x31c58e,_0x4d4a60){return db['SquareOdbc']['find']({'raw':_0x1d6a57[_0x64e7('0x18')]?_0x1d6a57['options'][_0x64e7('0x19')]===undefined?!![]:![]:!![],'where':_0x1d6a57[_0x64e7('0x18')]?_0x1d6a57[_0x64e7('0x18')][_0x64e7('0x1a')]||null:null,'attributes':_0x1d6a57[_0x64e7('0x18')]?_0x1d6a57['options']['attributes']||null:null,'include':_0x1d6a57['options']?_0x1d6a57[_0x64e7('0x18')][_0x64e7('0x1b')]?_['map'](_0x1d6a57[_0x64e7('0x18')][_0x64e7('0x1b')],function(_0x10657e){return{'model':db[_0x10657e[_0x64e7('0x1c')]],'as':_0x10657e['as'],'attributes':_0x10657e['attributes'],'include':_0x10657e[_0x64e7('0x1b')]?_[_0x64e7('0x1d')](_0x10657e['include'],function(_0x1023bb){return{'model':db[_0x1023bb[_0x64e7('0x1c')]],'as':_0x1023bb['as'],'attributes':_0x1023bb[_0x64e7('0x1e')],'include':_0x1023bb[_0x64e7('0x1b')]?_['map'](_0x1023bb[_0x64e7('0x1b')],function(_0x2ac4d9){return{'model':db[_0x2ac4d9[_0x64e7('0x1c')]],'as':_0x2ac4d9['as'],'attributes':_0x2ac4d9['attributes']};}):[]};}):[]};}):[]:[]})[_0x64e7('0xc')](function(_0x36ad98){logger[_0x64e7('0xd')](_0x64e7('0x17'),_0x1d6a57);logger['debug']('ShowSquareOdbc',_0x1d6a57,JSON[_0x64e7('0x11')](_0x36ad98));_0x31c58e(_0x36ad98);})['catch'](function(_0x2486fb){logger['error']('ShowSquareOdbc',_0x2486fb[_0x64e7('0x14')],_0x1d6a57);_0x4d4a60(_0x16171b[_0x64e7('0x12')](0x1f4,_0x2486fb[_0x64e7('0x14')]));});});};