75e713df872ceb054e7c840a7916c06232176bbf
[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 _0xd372=['rpc','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','register','then','info','OpenchannelAccount,\x20%s,\x20%s','debug','OpenchannelAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x2125f0,_0x2f23b9){var _0x12d6eb=function(_0x7a43ea){while(--_0x7a43ea){_0x2125f0['push'](_0x2125f0['shift']());}};_0x12d6eb(++_0x2f23b9);}(_0xd372,0x1a9));var _0x2d37=function(_0x146c37,_0x16482e){_0x146c37=_0x146c37-0x0;var _0x32c8df=_0xd372[_0x146c37];return _0x32c8df;};'use strict';var _=require('lodash');var util=require(_0x2d37('0x0'));var moment=require(_0x2d37('0x1'));var BPromise=require('bluebird');var rs=require(_0x2d37('0x2'));var fs=require('fs');var Redis=require(_0x2d37('0x3'));var db=require(_0x2d37('0x4'))['db'];var utils=require(_0x2d37('0x5'));var logger=require(_0x2d37('0x6'))(_0x2d37('0x7'));var config=require('../../config/environment');var jayson=require(_0x2d37('0x8'));var client=jayson[_0x2d37('0x9')][_0x2d37('0xa')]({'port':0x232a});config['redis']=_[_0x2d37('0xb')](config[_0x2d37('0xc')],{'host':_0x2d37('0xd'),'port':0x18eb});var socket=require(_0x2d37('0xe'))(new Redis(config['redis']));require('./openchannelAccount.socket')[_0x2d37('0xf')](socket);function respondWithRpcPromise(_0x392717,_0x5ec2c8,_0x13e1fb){return new BPromise(function(_0x4b0467,_0x14eb49){return client['request'](_0x392717,_0x13e1fb)[_0x2d37('0x10')](function(_0x44578a){logger[_0x2d37('0x11')](_0x2d37('0x12'),_0x5ec2c8,'request\x20sent');logger[_0x2d37('0x13')](_0x2d37('0x14'),_0x5ec2c8,_0x2d37('0x15'),JSON[_0x2d37('0x16')](_0x44578a));if(_0x44578a[_0x2d37('0x17')]){if(_0x44578a[_0x2d37('0x17')][_0x2d37('0x18')]===0x1f4){logger[_0x2d37('0x17')](_0x2d37('0x12'),_0x5ec2c8,_0x44578a['error'][_0x2d37('0x19')]);return _0x14eb49(_0x44578a[_0x2d37('0x17')][_0x2d37('0x19')]);}logger[_0x2d37('0x17')](_0x2d37('0x12'),_0x5ec2c8,_0x44578a[_0x2d37('0x17')][_0x2d37('0x19')]);return _0x4b0467(_0x44578a['error'][_0x2d37('0x19')]);}else{logger[_0x2d37('0x11')](_0x2d37('0x12'),_0x5ec2c8,_0x2d37('0x15'));_0x4b0467(_0x44578a['result'][_0x2d37('0x19')]);}})[_0x2d37('0x1a')](function(_0xd84b50){logger[_0x2d37('0x17')](_0x2d37('0x12'),_0x5ec2c8,_0xd84b50);_0x14eb49(_0xd84b50);});});}