534709d4dae044cdd8a67926ad60ad510229bb0b
[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 _0xa2ef=['error','code','message','catch','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./openchannelAccount.socket','register','request','then','info','OpenchannelAccount,\x20%s,\x20%s','request\x20sent','OpenchannelAccount,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x4ff09b,_0x53f67d){var _0x3f5c2e=function(_0x124592){while(--_0x124592){_0x4ff09b['push'](_0x4ff09b['shift']());}};_0x3f5c2e(++_0x53f67d);}(_0xa2ef,0x1f1));var _0xfa2e=function(_0xfe328a,_0x40602a){_0xfe328a=_0xfe328a-0x0;var _0x54d9a4=_0xa2ef[_0xfe328a];return _0x54d9a4;};'use strict';var _=require(_0xfa2e('0x0'));var util=require(_0xfa2e('0x1'));var moment=require(_0xfa2e('0x2'));var BPromise=require('bluebird');var rs=require(_0xfa2e('0x3'));var fs=require('fs');var Redis=require(_0xfa2e('0x4'));var db=require(_0xfa2e('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xfa2e('0x6'))(_0xfa2e('0x7'));var config=require(_0xfa2e('0x8'));var jayson=require(_0xfa2e('0x9'));var client=jayson[_0xfa2e('0xa')][_0xfa2e('0xb')]({'port':0x232a});config[_0xfa2e('0xc')]=_[_0xfa2e('0xd')](config['redis'],{'host':_0xfa2e('0xe'),'port':0x18eb});var socket=require(_0xfa2e('0xf'))(new Redis(config['redis']));require(_0xfa2e('0x10'))[_0xfa2e('0x11')](socket);function respondWithRpcPromise(_0x30e00d,_0x518b5c,_0x504c4b){return new BPromise(function(_0x3d32e7,_0x4b1b23){return client[_0xfa2e('0x12')](_0x30e00d,_0x504c4b)[_0xfa2e('0x13')](function(_0x10208c){logger[_0xfa2e('0x14')](_0xfa2e('0x15'),_0x518b5c,_0xfa2e('0x16'));logger['debug'](_0xfa2e('0x17'),_0x518b5c,_0xfa2e('0x16'),JSON[_0xfa2e('0x18')](_0x10208c));if(_0x10208c[_0xfa2e('0x19')]){if(_0x10208c[_0xfa2e('0x19')][_0xfa2e('0x1a')]===0x1f4){logger[_0xfa2e('0x19')]('OpenchannelAccount,\x20%s,\x20%s',_0x518b5c,_0x10208c['error'][_0xfa2e('0x1b')]);return _0x4b1b23(_0x10208c['error'][_0xfa2e('0x1b')]);}logger['error']('OpenchannelAccount,\x20%s,\x20%s',_0x518b5c,_0x10208c['error'][_0xfa2e('0x1b')]);return _0x3d32e7(_0x10208c['error'][_0xfa2e('0x1b')]);}else{logger[_0xfa2e('0x14')](_0xfa2e('0x15'),_0x518b5c,_0xfa2e('0x16'));_0x3d32e7(_0x10208c['result'][_0xfa2e('0x1b')]);}})[_0xfa2e('0x1c')](function(_0x5ca040){logger[_0xfa2e('0x19')](_0xfa2e('0x15'),_0x518b5c,_0x5ca040);_0x4b1b23(_0x5ca040);});});}