79d16a897a05cf2319a491b99c71c04e11c11d8c
[motion2.git] / server / api / saRequest / saRequest.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 _0x55a1=['then','info','SARequest,\x20%s,\x20%s','request\x20sent','SARequest,\x20%s,\x20%s,\x20%s','stringify','code','error','message','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/environment','client','http','request'];(function(_0x176c52,_0x4963f7){var _0x10af34=function(_0x41cb66){while(--_0x41cb66){_0x176c52['push'](_0x176c52['shift']());}};_0x10af34(++_0x4963f7);}(_0x55a1,0x10d));var _0x155a=function(_0x847af4,_0x5a7e17){_0x847af4=_0x847af4-0x0;var _0x43ae3a=_0x55a1[_0x847af4];return _0x43ae3a;};'use strict';var _=require(_0x155a('0x0'));var util=require(_0x155a('0x1'));var moment=require(_0x155a('0x2'));var BPromise=require(_0x155a('0x3'));var rs=require(_0x155a('0x4'));var fs=require('fs');var Redis=require(_0x155a('0x5'));var db=require(_0x155a('0x6'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0x155a('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x155a('0x8')][_0x155a('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x4796a6,_0x15f17d,_0x5bb850){return new BPromise(function(_0x4fda9d,_0x15abc9){return client[_0x155a('0xa')](_0x4796a6,_0x5bb850)[_0x155a('0xb')](function(_0x5d6ced){logger[_0x155a('0xc')](_0x155a('0xd'),_0x15f17d,_0x155a('0xe'));logger['debug'](_0x155a('0xf'),_0x15f17d,_0x155a('0xe'),JSON[_0x155a('0x10')](_0x5d6ced));if(_0x5d6ced['error']){if(_0x5d6ced['error'][_0x155a('0x11')]===0x1f4){logger[_0x155a('0x12')](_0x155a('0xd'),_0x15f17d,_0x5d6ced[_0x155a('0x12')][_0x155a('0x13')]);return _0x15abc9(_0x5d6ced[_0x155a('0x12')][_0x155a('0x13')]);}logger[_0x155a('0x12')](_0x155a('0xd'),_0x15f17d,_0x5d6ced[_0x155a('0x12')][_0x155a('0x13')]);return _0x4fda9d(_0x5d6ced[_0x155a('0x12')][_0x155a('0x13')]);}else{logger[_0x155a('0xc')](_0x155a('0xd'),_0x15f17d,'request\x20sent');_0x4fda9d(_0x5d6ced['result'][_0x155a('0x13')]);}})['catch'](function(_0x35c1b9){logger[_0x155a('0x12')]('SARequest,\x20%s,\x20%s',_0x15f17d,_0x35c1b9);_0x15abc9(_0x35c1b9);});});}