4af1d0f2b4dca05424d73dea267d5096cf183b68
[motion2.git] / server / api / disposition / disposition.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 _0x7582=['catch','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','http','request','then','info','Disposition,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','result'];(function(_0x99f7d8,_0x371819){var _0x1f028a=function(_0x21e990){while(--_0x21e990){_0x99f7d8['push'](_0x99f7d8['shift']());}};_0x1f028a(++_0x371819);}(_0x7582,0x7f));var _0x2758=function(_0x60df74,_0x458e29){_0x60df74=_0x60df74-0x0;var _0x5ee872=_0x7582[_0x60df74];return _0x5ee872;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x2758('0x0'));var BPromise=require(_0x2758('0x1'));var rs=require(_0x2758('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x2758('0x3'))['db'];var utils=require(_0x2758('0x4'));var logger=require('../../config/logger')('rpc');var config=require(_0x2758('0x5'));var jayson=require(_0x2758('0x6'));var client=jayson[_0x2758('0x7')][_0x2758('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x3ec82f,_0x342690,_0x23d54d){return new BPromise(function(_0x37b28f,_0x186d11){return client[_0x2758('0x9')](_0x3ec82f,_0x23d54d)[_0x2758('0xa')](function(_0x323f4f){logger[_0x2758('0xb')](_0x2758('0xc'),_0x342690,'request\x20sent');logger[_0x2758('0xd')]('Disposition,\x20%s,\x20%s,\x20%s',_0x342690,_0x2758('0xe'),JSON[_0x2758('0xf')](_0x323f4f));if(_0x323f4f[_0x2758('0x10')]){if(_0x323f4f[_0x2758('0x10')][_0x2758('0x11')]===0x1f4){logger[_0x2758('0x10')](_0x2758('0xc'),_0x342690,_0x323f4f['error'][_0x2758('0x12')]);return _0x186d11(_0x323f4f[_0x2758('0x10')]['message']);}logger[_0x2758('0x10')](_0x2758('0xc'),_0x342690,_0x323f4f[_0x2758('0x10')][_0x2758('0x12')]);return _0x37b28f(_0x323f4f[_0x2758('0x10')][_0x2758('0x12')]);}else{logger[_0x2758('0xb')](_0x2758('0xc'),_0x342690,'request\x20sent');_0x37b28f(_0x323f4f[_0x2758('0x13')]['message']);}})[_0x2758('0x14')](function(_0x48a6a3){logger[_0x2758('0x10')](_0x2758('0xc'),_0x342690,_0x48a6a3);_0x186d11(_0x48a6a3);});});}