5092984a907ee1e459bfcd628b44116870964b4e
[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 _0x26f9=['message','result','catch','lodash','util','bluebird','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./openchannelAccount.socket','request','then','OpenchannelAccount,\x20%s,\x20%s','request\x20sent','debug','OpenchannelAccount,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x196f05,_0xda4708){var _0x2d503a=function(_0x151bb1){while(--_0x151bb1){_0x196f05['push'](_0x196f05['shift']());}};_0x2d503a(++_0xda4708);}(_0x26f9,0x16f));var _0x926f=function(_0x3b2421,_0xf30f91){_0x3b2421=_0x3b2421-0x0;var _0x288bde=_0x26f9[_0x3b2421];return _0x288bde;};'use strict';var _=require(_0x926f('0x0'));var util=require(_0x926f('0x1'));var moment=require('moment');var BPromise=require(_0x926f('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x926f('0x3'))['db'];var utils=require(_0x926f('0x4'));var logger=require('../../config/logger')(_0x926f('0x5'));var config=require(_0x926f('0x6'));var jayson=require(_0x926f('0x7'));var client=jayson[_0x926f('0x8')][_0x926f('0x9')]({'port':0x232a});config[_0x926f('0xa')]=_[_0x926f('0xb')](config[_0x926f('0xa')],{'host':_0x926f('0xc'),'port':0x18eb});var socket=require(_0x926f('0xd'))(new Redis(config['redis']));require(_0x926f('0xe'))['register'](socket);function respondWithRpcPromise(_0x12fbd4,_0x43cd93,_0x4f7d2c){return new BPromise(function(_0x3d3802,_0x2ae81c){return client[_0x926f('0xf')](_0x12fbd4,_0x4f7d2c)[_0x926f('0x10')](function(_0x13ef84){logger['info'](_0x926f('0x11'),_0x43cd93,_0x926f('0x12'));logger[_0x926f('0x13')](_0x926f('0x14'),_0x43cd93,_0x926f('0x12'),JSON[_0x926f('0x15')](_0x13ef84));if(_0x13ef84[_0x926f('0x16')]){if(_0x13ef84['error']['code']===0x1f4){logger['error'](_0x926f('0x11'),_0x43cd93,_0x13ef84[_0x926f('0x16')][_0x926f('0x17')]);return _0x2ae81c(_0x13ef84[_0x926f('0x16')]['message']);}logger[_0x926f('0x16')](_0x926f('0x11'),_0x43cd93,_0x13ef84['error'][_0x926f('0x17')]);return _0x3d3802(_0x13ef84['error'][_0x926f('0x17')]);}else{logger['info']('OpenchannelAccount,\x20%s,\x20%s',_0x43cd93,_0x926f('0x12'));_0x3d3802(_0x13ef84[_0x926f('0x18')]['message']);}})[_0x926f('0x19')](function(_0x386498){logger[_0x926f('0x16')]('OpenchannelAccount,\x20%s,\x20%s',_0x43cd93,_0x386498);_0x2ae81c(_0x386498);});});}