58ee258f6104b1ccef2dc5afd616d97b824f9363
[motion2.git] / server / api / smsApplication / smsApplication.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 _0xaf60=['ioredis','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','debug','request\x20sent','error','code','message','info','SmsApplication,\x20%s,\x20%s','lodash','util','moment'];(function(_0x405bf8,_0xd91549){var _0x41f0d2=function(_0x489efd){while(--_0x489efd){_0x405bf8['push'](_0x405bf8['shift']());}};_0x41f0d2(++_0xd91549);}(_0xaf60,0x82));var _0x0af6=function(_0x46aff0,_0x122890){_0x46aff0=_0x46aff0-0x0;var _0x9d78cf=_0xaf60[_0x46aff0];return _0x9d78cf;};'use strict';var _=require(_0x0af6('0x0'));var util=require(_0x0af6('0x1'));var moment=require(_0x0af6('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0af6('0x3'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x0af6('0x4'))(_0x0af6('0x5'));var config=require(_0x0af6('0x6'));var jayson=require(_0x0af6('0x7'));var client=jayson[_0x0af6('0x8')][_0x0af6('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x2eb218,_0x52c997,_0x376979){return new BPromise(function(_0x28d620,_0x525bcc){return client[_0x0af6('0xa')](_0x2eb218,_0x376979)[_0x0af6('0xb')](function(_0xe9d01a){logger['info']('SmsApplication,\x20%s,\x20%s',_0x52c997,'request\x20sent');logger[_0x0af6('0xc')]('SmsApplication,\x20%s,\x20%s,\x20%s',_0x52c997,_0x0af6('0xd'),JSON['stringify'](_0xe9d01a));if(_0xe9d01a['error']){if(_0xe9d01a[_0x0af6('0xe')][_0x0af6('0xf')]===0x1f4){logger[_0x0af6('0xe')]('SmsApplication,\x20%s,\x20%s',_0x52c997,_0xe9d01a[_0x0af6('0xe')][_0x0af6('0x10')]);return _0x525bcc(_0xe9d01a[_0x0af6('0xe')]['message']);}logger[_0x0af6('0xe')]('SmsApplication,\x20%s,\x20%s',_0x52c997,_0xe9d01a[_0x0af6('0xe')]['message']);return _0x28d620(_0xe9d01a[_0x0af6('0xe')][_0x0af6('0x10')]);}else{logger[_0x0af6('0x11')](_0x0af6('0x12'),_0x52c997,'request\x20sent');_0x28d620(_0xe9d01a['result']['message']);}})['catch'](function(_0x4d5936){logger[_0x0af6('0xe')](_0x0af6('0x12'),_0x52c997,_0x4d5936);_0x525bcc(_0x4d5936);});});}