25bbdacef1e43ba0389cd687efdb4770e1469f83
[motion2.git] / server / api / openchannelAccount / openchannelAccount.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 _0x44a3=['lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','socket.io-emitter','redis','./openchannelAccount.socket','register','request','OpenchannelAccount,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch'];(function(_0xae445b,_0x2e4bd9){var _0x127afe=function(_0x477285){while(--_0x477285){_0xae445b['push'](_0xae445b['shift']());}};_0x127afe(++_0x2e4bd9);}(_0x44a3,0x1a9));var _0x344a=function(_0x3e806a,_0xa4b9fa){_0x3e806a=_0x3e806a-0x0;var _0x477105=_0x44a3[_0x3e806a];return _0x477105;};'use strict';var _=require(_0x344a('0x0'));var util=require(_0x344a('0x1'));var moment=require(_0x344a('0x2'));var BPromise=require(_0x344a('0x3'));var rs=require(_0x344a('0x4'));var fs=require('fs');var Redis=require(_0x344a('0x5'));var db=require(_0x344a('0x6'))['db'];var utils=require(_0x344a('0x7'));var logger=require('../../config/logger')(_0x344a('0x8'));var config=require(_0x344a('0x9'));var jayson=require(_0x344a('0xa'));var client=jayson[_0x344a('0xb')][_0x344a('0xc')]({'port':0x232a});config['redis']=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x344a('0xd'))(new Redis(config[_0x344a('0xe')]));require(_0x344a('0xf'))[_0x344a('0x10')](socket);function respondWithRpcPromise(_0x2afc37,_0x54288d,_0x6e04a9){return new BPromise(function(_0x13588c,_0x559406){return client[_0x344a('0x11')](_0x2afc37,_0x6e04a9)['then'](function(_0x397476){logger['info'](_0x344a('0x12'),_0x54288d,_0x344a('0x13'));logger['debug']('OpenchannelAccount,\x20%s,\x20%s,\x20%s',_0x54288d,_0x344a('0x13'),JSON[_0x344a('0x14')](_0x397476));if(_0x397476[_0x344a('0x15')]){if(_0x397476[_0x344a('0x15')][_0x344a('0x16')]===0x1f4){logger[_0x344a('0x15')]('OpenchannelAccount,\x20%s,\x20%s',_0x54288d,_0x397476[_0x344a('0x15')][_0x344a('0x17')]);return _0x559406(_0x397476[_0x344a('0x15')][_0x344a('0x17')]);}logger['error']('OpenchannelAccount,\x20%s,\x20%s',_0x54288d,_0x397476[_0x344a('0x15')][_0x344a('0x17')]);return _0x13588c(_0x397476[_0x344a('0x15')][_0x344a('0x17')]);}else{logger['info'](_0x344a('0x12'),_0x54288d,_0x344a('0x13'));_0x13588c(_0x397476['result'][_0x344a('0x17')]);}})[_0x344a('0x18')](function(_0x3e936c){logger[_0x344a('0x15')](_0x344a('0x12'),_0x54288d,_0x3e936c);_0x559406(_0x3e936c);});});}