530833bf9d5e659654b29c81122c8678e93e4f7f
[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 _0xcac2=['SmsApplication,\x20%s,\x20%s,\x20%s','stringify','error','code','SmsApplication,\x20%s,\x20%s','message','result','catch','lodash','util','moment','randomstring','ioredis','../../config/environment','jayson/promise','client','http','request','info','debug'];(function(_0x20dee6,_0x2d3179){var _0x592fd1=function(_0x52eb7c){while(--_0x52eb7c){_0x20dee6['push'](_0x20dee6['shift']());}};_0x592fd1(++_0x2d3179);}(_0xcac2,0x1e8));var _0x2cac=function(_0x3f7c66,_0x1e6bb4){_0x3f7c66=_0x3f7c66-0x0;var _0x6e91e4=_0xcac2[_0x3f7c66];return _0x6e91e4;};'use strict';var _=require(_0x2cac('0x0'));var util=require(_0x2cac('0x1'));var moment=require(_0x2cac('0x2'));var BPromise=require('bluebird');var rs=require(_0x2cac('0x3'));var fs=require('fs');var Redis=require(_0x2cac('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0x2cac('0x5'));var jayson=require(_0x2cac('0x6'));var client=jayson[_0x2cac('0x7')][_0x2cac('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x2f996c,_0x703f11,_0x1920cf){return new BPromise(function(_0x56b4f9,_0x5df249){return client[_0x2cac('0x9')](_0x2f996c,_0x1920cf)['then'](function(_0x361260){logger[_0x2cac('0xa')]('SmsApplication,\x20%s,\x20%s',_0x703f11,'request\x20sent');logger[_0x2cac('0xb')](_0x2cac('0xc'),_0x703f11,'request\x20sent',JSON[_0x2cac('0xd')](_0x361260));if(_0x361260['error']){if(_0x361260[_0x2cac('0xe')][_0x2cac('0xf')]===0x1f4){logger[_0x2cac('0xe')](_0x2cac('0x10'),_0x703f11,_0x361260[_0x2cac('0xe')]['message']);return _0x5df249(_0x361260[_0x2cac('0xe')][_0x2cac('0x11')]);}logger['error'](_0x2cac('0x10'),_0x703f11,_0x361260[_0x2cac('0xe')][_0x2cac('0x11')]);return _0x56b4f9(_0x361260['error'][_0x2cac('0x11')]);}else{logger[_0x2cac('0xa')](_0x2cac('0x10'),_0x703f11,'request\x20sent');_0x56b4f9(_0x361260[_0x2cac('0x12')][_0x2cac('0x11')]);}})[_0x2cac('0x13')](function(_0x4d4646){logger['error'](_0x2cac('0x10'),_0x703f11,_0x4d4646);_0x5df249(_0x4d4646);});});}