Built motion from commit da617fac.|2.6.6
[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 _0x18ca=['ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','info','SquareOdbc,\x20%s,\x20%s','request\x20sent','debug','SquareOdbc,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','ShowSquareOdbc','find','options','raw','attributes','include','model','map','then','lodash','util','moment','randomstring'];(function(_0x5d4607,_0x6b5e7b){var _0x5e4a86=function(_0x46891a){while(--_0x46891a){_0x5d4607['push'](_0x5d4607['shift']());}};_0x5e4a86(++_0x6b5e7b);}(_0x18ca,0x19c));var _0xa18c=function(_0x1b34da,_0x395ec4){_0x1b34da=_0x1b34da-0x0;var _0x2dcaa=_0x18ca[_0x1b34da];return _0x2dcaa;};'use strict';var _=require(_0xa18c('0x0'));var util=require(_0xa18c('0x1'));var moment=require(_0xa18c('0x2'));var BPromise=require('bluebird');var rs=require(_0xa18c('0x3'));var fs=require('fs');var Redis=require(_0xa18c('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xa18c('0x5'));var logger=require(_0xa18c('0x6'))(_0xa18c('0x7'));var config=require(_0xa18c('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xa18c('0x9')][_0xa18c('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x2ee8fe,_0x42fedb,_0x401152){return new BPromise(function(_0x46804a,_0x5c457d){return client[_0xa18c('0xb')](_0x2ee8fe,_0x401152)['then'](function(_0x594e75){logger[_0xa18c('0xc')](_0xa18c('0xd'),_0x42fedb,_0xa18c('0xe'));logger[_0xa18c('0xf')](_0xa18c('0x10'),_0x42fedb,_0xa18c('0xe'),JSON[_0xa18c('0x11')](_0x594e75));if(_0x594e75['error']){if(_0x594e75[_0xa18c('0x12')][_0xa18c('0x13')]===0x1f4){logger['error'](_0xa18c('0xd'),_0x42fedb,_0x594e75[_0xa18c('0x12')][_0xa18c('0x14')]);return _0x5c457d(_0x594e75['error']['message']);}logger['error']('SquareOdbc,\x20%s,\x20%s',_0x42fedb,_0x594e75[_0xa18c('0x12')][_0xa18c('0x14')]);return _0x46804a(_0x594e75[_0xa18c('0x12')][_0xa18c('0x14')]);}else{logger[_0xa18c('0xc')](_0xa18c('0xd'),_0x42fedb,_0xa18c('0xe'));_0x46804a(_0x594e75[_0xa18c('0x15')][_0xa18c('0x14')]);}})[_0xa18c('0x16')](function(_0x2a3aa6){logger[_0xa18c('0x12')](_0xa18c('0xd'),_0x42fedb,_0x2a3aa6);_0x5c457d(_0x2a3aa6);});});}exports[_0xa18c('0x17')]=function(_0x2660c3){var _0x30cb87=this;return new Promise(function(_0x13227e,_0x26fbe4){return db['SquareOdbc'][_0xa18c('0x18')]({'raw':_0x2660c3[_0xa18c('0x19')]?_0x2660c3[_0xa18c('0x19')][_0xa18c('0x1a')]===undefined?!![]:![]:!![],'where':_0x2660c3[_0xa18c('0x19')]?_0x2660c3[_0xa18c('0x19')]['where']||null:null,'attributes':_0x2660c3['options']?_0x2660c3[_0xa18c('0x19')][_0xa18c('0x1b')]||null:null,'include':_0x2660c3[_0xa18c('0x19')]?_0x2660c3[_0xa18c('0x19')][_0xa18c('0x1c')]?_['map'](_0x2660c3['options'][_0xa18c('0x1c')],function(_0x500549){return{'model':db[_0x500549[_0xa18c('0x1d')]],'as':_0x500549['as'],'attributes':_0x500549[_0xa18c('0x1b')],'include':_0x500549[_0xa18c('0x1c')]?_[_0xa18c('0x1e')](_0x500549[_0xa18c('0x1c')],function(_0x2b09f6){return{'model':db[_0x2b09f6[_0xa18c('0x1d')]],'as':_0x2b09f6['as'],'attributes':_0x2b09f6[_0xa18c('0x1b')],'include':_0x2b09f6[_0xa18c('0x1c')]?_[_0xa18c('0x1e')](_0x2b09f6[_0xa18c('0x1c')],function(_0x1a3cde){return{'model':db[_0x1a3cde['model']],'as':_0x1a3cde['as'],'attributes':_0x1a3cde[_0xa18c('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xa18c('0x1f')](function(_0x566b8f){logger[_0xa18c('0xc')](_0xa18c('0x17'),_0x2660c3);logger[_0xa18c('0xf')](_0xa18c('0x17'),_0x2660c3,JSON[_0xa18c('0x11')](_0x566b8f));_0x13227e(_0x566b8f);})[_0xa18c('0x16')](function(_0xf838f3){logger[_0xa18c('0x12')](_0xa18c('0x17'),_0xf838f3['message'],_0x2660c3);_0x26fbe4(_0x30cb87[_0xa18c('0x12')](0x1f4,_0xf838f3['message']));});});};