0549aa8952ec0576795199dcfc781a6545fc9f15
[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 _0xa478=['moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','defaults','socket.io-emitter','./openchannelAccount.socket','register','request','info','OpenchannelAccount,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','lodash','util'];(function(_0x410b81,_0x871c4b){var _0x17e81e=function(_0x1106ac){while(--_0x1106ac){_0x410b81['push'](_0x410b81['shift']());}};_0x17e81e(++_0x871c4b);}(_0xa478,0x136));var _0x8a47=function(_0x333714,_0x3370ac){_0x333714=_0x333714-0x0;var _0x4c211e=_0xa478[_0x333714];return _0x4c211e;};'use strict';var _=require(_0x8a47('0x0'));var util=require(_0x8a47('0x1'));var moment=require(_0x8a47('0x2'));var BPromise=require(_0x8a47('0x3'));var rs=require(_0x8a47('0x4'));var fs=require('fs');var Redis=require(_0x8a47('0x5'));var db=require(_0x8a47('0x6'))['db'];var utils=require(_0x8a47('0x7'));var logger=require(_0x8a47('0x8'))(_0x8a47('0x9'));var config=require(_0x8a47('0xa'));var jayson=require(_0x8a47('0xb'));var client=jayson['client'][_0x8a47('0xc')]({'port':0x232a});config[_0x8a47('0xd')]=_[_0x8a47('0xe')](config[_0x8a47('0xd')],{'host':'localhost','port':0x18eb});var socket=require(_0x8a47('0xf'))(new Redis(config['redis']));require(_0x8a47('0x10'))[_0x8a47('0x11')](socket);function respondWithRpcPromise(_0x3a6cc4,_0x574c96,_0xe65646){return new BPromise(function(_0x230a11,_0x493d7b){return client[_0x8a47('0x12')](_0x3a6cc4,_0xe65646)['then'](function(_0x39da50){logger[_0x8a47('0x13')](_0x8a47('0x14'),_0x574c96,'request\x20sent');logger['debug']('OpenchannelAccount,\x20%s,\x20%s,\x20%s',_0x574c96,_0x8a47('0x15'),JSON[_0x8a47('0x16')](_0x39da50));if(_0x39da50['error']){if(_0x39da50[_0x8a47('0x17')][_0x8a47('0x18')]===0x1f4){logger[_0x8a47('0x17')](_0x8a47('0x14'),_0x574c96,_0x39da50[_0x8a47('0x17')][_0x8a47('0x19')]);return _0x493d7b(_0x39da50[_0x8a47('0x17')][_0x8a47('0x19')]);}logger[_0x8a47('0x17')](_0x8a47('0x14'),_0x574c96,_0x39da50[_0x8a47('0x17')][_0x8a47('0x19')]);return _0x230a11(_0x39da50[_0x8a47('0x17')]['message']);}else{logger[_0x8a47('0x13')](_0x8a47('0x14'),_0x574c96,_0x8a47('0x15'));_0x230a11(_0x39da50['result'][_0x8a47('0x19')]);}})['catch'](function(_0x538ed2){logger[_0x8a47('0x17')](_0x8a47('0x14'),_0x574c96,_0x538ed2);_0x493d7b(_0x538ed2);});});}