예제 #1
0
        private EzeResult exit()
        {
            Console.WriteLine("...exiting");
            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.EXIT)
                                .Build();

            this.send(apiInput);
            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());
                if (result.getEventName() != EventName.EXIT)
                {
                    continue;
                }
                if ((result.getStatus().ToString() == ApiOutput.Types.ResultStatus.FAILURE.ToString()))
                {
                    EzeEvent("Initialization succesful", new EventArgs());
                    return(result);;
                }
                break;
            }
            return(result);
        }
예제 #2
0
        private EzeResult login(LoginMode mode, string userName, string passkey)
        {
            Console.WriteLine("...Login User <" + mode + ":" + userName + ":" + passkey + ">");

            LoginInput loginInput = LoginInput.CreateBuilder()
                                    .SetLoginMode(MapLoginMode(mode))
                                    .SetUsername(userName)
                                    .SetPasskey(passkey).Build();

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.LOGIN)
                                .SetMsgData(loginInput.ToByteString()).Build();

            this.send(apiInput);

            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());
                if (result.getEventName() != EventName.LOGIN)
                {
                    continue;
                }
                if ((result.getStatus().ToString() == com.eze.ezecli.ApiOutput.Types.ResultStatus.FAILURE.ToString()))
                {
                    throw new EzeException("Login failed. " + result.ToString());
                }
                break;
            }
            Console.WriteLine("2......" + result);
            return(result);
        }
예제 #3
0
        /// <summary>
        /// Makes the HTTP request to a service
        /// </summary>
        /// <typeparam name="I">Type of input objects</typeparam>
        /// <param name="uri">URI of the service deployed</param>
        /// <param name="key">API Key of the service deployed</param>
        /// <param name="input">The objects to be sent in the request</param>
        /// <returns>A generic object, depending on the service return.</returns>
        public static async Task <I> MakeRequest <I>(String uri, string key, ApiInput <T> input) where I : class, new()
        {
            I returnValue = null;

            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", key);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.BaseAddress = new Uri(uri);

                String content = Newtonsoft.Json.JsonConvert.SerializeObject(input);

                var request = new HttpRequestMessage(HttpMethod.Post, string.Empty);
                request.Content = new StringContent(content);
                request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                HttpResponseMessage response = client.SendAsync(request).Result;

                if (response.IsSuccessStatusCode)
                {
                    string result = await response.Content.ReadAsStringAsync();

                    result      = result.Replace("\"", String.Empty).Replace("\\", String.Empty);
                    returnValue = Newtonsoft.Json.JsonConvert.DeserializeObject <I>(result);
                }
            }

            return(returnValue);
        }
예제 #4
0
        private EzeResult logout()
        {
            Console.WriteLine("...logging out");

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.LOGOUT)
                                .Build();

            this.send(apiInput);
            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());
                if (result.getEventName() != EventName.LOGOUT)
                {
                    continue;
                }
                if ((result.getStatus().ToString() == ApiOutput.Types.ResultStatus.FAILURE.ToString()))
                {
                    Console.WriteLine("Error logout");
                }
                else
                {
                    Console.WriteLine(" logout success");
                    break;
                }
            }
            return(result);
        }
예제 #5
0
        /**
         * Method attaches a signature (captured) from the UI to a successfully executed transaction
         */
        public EzeResult attachSignature(string txnId, ImageType imageType, ByteString imageData, int height, int width, double tipAmount)
        {
            Console.Error.WriteLine("...attachSignature <" + txnId + ">");

            SignatureInput signatureInput = SignatureInput.CreateBuilder()
                                            .SetTxnId(txnId)
                                            .SetImageType(MapImageType(imageType))
                                            .SetImageBytes(imageData)
                                            .SetHeight(height)
                                            .SetWidth(width)
                                            .SetTipAmount(tipAmount)
                                            .Build();

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.ATTACH_SIGNATURE)
                                .SetMsgData(signatureInput.ToByteString()).Build();

            this.send(apiInput);
            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());
                if (result.getEventName() == EventName.ATTACH_SIGNATURE)
                {
                    break;
                }
            }
            return(result);
        }
예제 #6
0
        /*  public EzeResult takePayment(PaymentType type, double amount, PaymentOptions options)
         * {
         *            EzeResult result = null;
         *            Console.WriteLine("...Take Payment <"+type.ToString()+",amount="+amount+","+">");
         *            TxnInput.Types.TxnType txnType = TxnInput.Types.TxnType.CARD_PRE_AUTH;
         *
         *    switch(type)
         *    {
         *            case PaymentType.CARD:
         *        {
         *            txnType = TxnInput.Types.TxnType.CARD_AUTH;
         *                        break;
         *        }
         *                case PaymentType.CASH:
         *        {
         *                        txnType = TxnInput.Types.TxnType.CASH;
         *                        break;
         *        }
         *                case PaymentType.CHEQUE:
         *        {
         *                        txnType = TxnInput.Types.TxnType.CHEQUE;
         *                        break;
         *        }
         *                default:
         *        {
         *                        txnType = TxnInput.Types.TxnType.CARD_PRE_AUTH;
         *            break;
         *        }
         *            }
         *
         *    if (amount <= 0) throw new EzeException("Amount is 0 or negative");
         *            if (txnType == TxnInput.Types.TxnType.CHEQUE)
         *    {
         *                    if ((null == options) ||
         *                            (null == options.getChequeNo()) || (options.getChequeNo().Length == 0) ||
         *                            (null == options.getBankCode()) || (options.getBankCode().Length == 0) ||
         *                            (null == options.getChequeDate()))
         *        {
         *                throw new EzeException("Cheque details not passed for a Cheque transaction");
         *                    }
         *            }
         *
         *            TxnInput tInput = TxnInput.CreateBuilder()
         *
         *                            .SetTxnType(txnType)
         *                            .SetAmount(amount)
         *                            .Build();
         *
         *            if (null != options) {
         *                    if (null != options.getOrderId()) tInput = TxnInput.CreateBuilder(tInput).SetOrderId(options.getOrderId()).Build();
         *                    if (null != options.getReceiptType()) tInput = TxnInput.CreateBuilder(tInput).SetReceiptType(options.getReceiptType()).Build();
         *                    if (null != options.getChequeNo()) tInput = TxnInput.CreateBuilder(tInput).SetChequeNumber(options.getChequeNo()).Build();
         *                    if (null != options.getBankCode()) tInput = TxnInput.CreateBuilder(tInput).SetBankCode(options.getBankCode()).Build();
         *                    if (null != options.getChequeDate()) tInput = TxnInput.CreateBuilder(tInput).SetChequeDate(options.getChequeDate().ToString()).Build();
         *            }
         *
         *            ApiInput apiInput = ApiInput.CreateBuilder()
         *                            .SetMsgType(ApiInput.Types.MessageType.TXN)
         *                            .SetMsgData(tInput.ToByteString()).Build();
         *
         *            this.send(apiInput);
         *
         *            while (true)
         *    {
         *                    result = this.getResult(this.receive());
         *
         *        if (result.getEventName() == EventName.TAKE_PAYMENT)
         *        {
         *            if (result.getStatus() == Status.SUCCESS) EzeEvent("Payment Successful", new EventArgs());
         *            else EzeEvent("Payment Failed", new EventArgs());
         *            break;
         *        }
         *            }
         *
         *    return result;
         *    } */

        public EzeResult sendReceipt(string txnId, string mobileNo, String email)
        {
            Console.Error.WriteLine("...sendReceipt <" + txnId + ">");

            ForwardReceiptInput receiptInput = ForwardReceiptInput.CreateBuilder()
                                               .SetTxnId(txnId)
                                               .SetCustomerMobile(mobileNo)
                                               .SetCustomerEmail(email).Build();

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.FORWARD_RECEIPT)
                                .SetMsgData(receiptInput.ToByteString()).Build();

            this.send(apiInput);
            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());
                if (result.getEventName() == EventName.SEND_RECEIPT)
                {
                    break;
                }
            }

            return(result);
        }
예제 #7
0
        public HttpResponseMessage ImageProcessing([FromBody] ApiInput apiInput)
        {
            try
            {
                //if (!IsAuthorised(out errorMessage))
                //    return Request.CreateErrorResponse(HttpStatusCode.Unauthorized, errorMessage);

                if (!ModelState.IsValid)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
                }

                apiManager = new APIManager(token);

                string useragent = string.Empty;

                if (Request.Headers.UserAgent != null)
                {
                    useragent = Convert.ToString(Request.Headers.UserAgent);
                }

                AppServiceApi.Models.AppraisalOutput appraisalOutput = apiManager.processImageLatLon(apiInput.imageBase64, apiInput.latitude, apiInput.longitude, apiInput.deviceId, useragent);

                return(Request.CreateResponse(HttpStatusCode.OK, appraisalOutput));
            }
            catch (Exception ex)
            {
                ErrorAsync(ex, Request.RequestUri.AbsoluteUri.ToString());
                return(Request.CreateResponse(HttpStatusCode.BadRequest, new { message = "Bad Request" }));
            }
        }
예제 #8
0
        public HttpResponseMessage ImageProcessing([FromBody] ApiInput apiInput)
        {
            try
            {
                if (!IsAuthorised(out errorMessage))
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, errorMessage));
                }

                if (!ModelState.IsValid)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
                }

                apiManager = new APIManager(token);
                AppServiceApi.Models.AppraisalOutput appraisalOutput = apiManager.processImageLatLon(apiInput.imageBase64, apiInput.latitude, apiInput.longitude);

                return(Request.CreateResponse(HttpStatusCode.OK, appraisalOutput));
            }
            catch (Exception ex)
            {
                ErrorAsync(ex, Request.RequestUri.AbsoluteUri.ToString());
                return(Request.CreateResponse(HttpStatusCode.BadRequest, new { message = "Bad Request" }));
            }
        }
예제 #9
0
        public EzeResult getTransaction(String txId)
        {
            Console.WriteLine("Fetching transaction details for " + txId);
            TxnDetailsInput txnInput = TxnDetailsInput.CreateBuilder().SetTxnId(txId).Build();
            ApiInput        input    = ApiInput.CreateBuilder().SetMsgType(ApiInput.Types.MessageType.TXN_DETAILS).SetMsgData(txnInput.ToByteString()).Build();

            this.send(input);
            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());

                if (result.getEventName() == EventName.TRANSACTION_DETAILS)
                {
                    if (result.getStatus() == Status.SUCCESS)
                    {
                        EzeEvent("Fetching Transaction Successful", new EventArgs());
                    }
                    else
                    {
                        EzeEvent("Fetching Transaction Details Failed", new EventArgs());
                    }
                    break;
                }
            }

            return(result);
        }
예제 #10
0
파일: Program.cs 프로젝트: mawah/CloudAI
 /// <summary>
 /// Async call to hit the actual endpoint.
 /// </summary>
 /// <param name="input"></param>
 /// <returns>Data to be sent to the experiment endpoint.</returns>
 private static async Task ExecuteExpermimentEndpoint(ApiInput <ManufacturingInput> input)
 {
     foreach (ManufacturingInput minput in input.DataRequest)
     {
         Console.WriteLine("Device {0} in payload", minput.DeviceId);
     }
     Program.Results = await MLRequestApi <ManufacturingInput> .MakeRequest <List <Double> >(APIUri, APIKey, input);
 }
예제 #11
0
        public EzeResult voidTransaction(String txnId)
        {
            Console.WriteLine("Void....");
            VoidTxnInput voidTaxInput = VoidTxnInput.CreateBuilder().SetTxnId(txnId).Build();
            ApiInput     apiInput     = ApiInput.CreateBuilder().SetMsgType(ApiInput.Types.MessageType.VOID_TXN).SetMsgData(voidTaxInput.ToByteString()).Build();

            this.send(apiInput);
            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());
                if (result.getEventName() == EventName.VOID_PAYMENT)
                {
                    Console.WriteLine(result);
                    break;
                }
            }
            return(result);
        }
예제 #12
0
        private void send(ApiInput apiInput)
        {
            //Console.Write(apiInput.ToJson());
            byte[] length = new byte[4];

            try {
                length = this.intToBytes(apiInput.SerializedSize);
                //p.StandardInput.Write(length);
                //p.StandardInput.Write(apiInput.ToByteString());
                //p.StandardInput.Flush();
                output.Write(length);
                byte[] arr = apiInput.ToByteArray();
                output.Write(arr);
                //Console.Write(apiInput.ToByteArray());
                output.Flush();
            } catch (InvalidProtocolBufferException e) {
                Console.WriteLine("Parse Error " + e.ToString());
            } catch (IOException e) {
                Console.WriteLine("Error readline " + e.ToString());
            }
        }
예제 #13
0
파일: Program.cs 프로젝트: mawah/CloudAI
        static void Main(string[] args)
        {
            ApiInput <ManufacturingInput> input = new ApiInput <ManufacturingInput>();

            input.DataRequest.Add(new ManufacturingInput()
            {
                DeviceId             = 1,
                OperatingVoltage     = 241.50,
                OperationTemperature = 189.2342,
                Rotation             = 120,
                TimeStamp            = 3,
            });

            ExecuteExpermimentEndpoint(input).Wait();

            foreach (double d in Results)
            {
                Console.WriteLine("Result : {0}", d);
            }
            Console.ReadLine();
        }
예제 #14
0
        private void setServerType(ServerType type)
        {
            Console.WriteLine("...Setting server type to <" + type.ToString() + ">");

            ServerTypeInput serverTypeInput = ServerTypeInput.CreateBuilder()
                                              .SetServertype(MapServerType(type)).Build();

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.SERVER_TYPE)
                                .SetMsgData(serverTypeInput.ToByteString()).Build();

            this.send(apiInput);

            /*
             * EzeResult result = null;
             *
             * while (true)
             * {
             *  result = this.getResult(this.receive());
             *  if (result.getEventName() == EventName.SET_SERVER_TYPE) break;
             * }*/
        }
예제 #15
0
        /// <summary>
        ///
        /// </summary>
        /// <returns>EzeResult - instance </returns>
        public EzeResult prepareDevice()
        {
            Console.WriteLine("...Preparing Device");

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.PREPARE_DEVICE)
                                .Build();

            this.send(apiInput);
            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());
                if (result.getEventName() == EventName.PREPARE_DEVICE)
                {
                    break;
                }
            }
            Console.WriteLine("99: " + result);
            return(result);
        }
예제 #16
0
        public EzeResult getTransactionHistory(string startDate, string endDate)
        {
            Console.Error.WriteLine("...Transaction History < >");

            TxnHistoryInput historyInput = TxnHistoryInput.CreateBuilder().SetStrtDate(startDate).SetEndDate(endDate)
                                           .Build();

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.TXN_HISTORY)
                                .SetMsgData(historyInput.ToByteString()).Build();

            this.send(apiInput);
            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());
                if (result.getEventName() == EventName.HISTORY_RESULT)
                {
                    break;
                }
            }
            return(result);
        }
예제 #17
0
        private void send(ApiInput apiInput)
        {
            //Console.Write(apiInput.ToJson());
            byte[] length = new byte[4];

            try {
                length = this.intToBytes(apiInput.SerializedSize);
                //p.StandardInput.Write(length);
                //p.StandardInput.Write(apiInput.ToByteString());
                //p.StandardInput.Flush();
                output.Write(length);
                byte[] arr = apiInput.ToByteArray();
                output.Write(arr);
                //Console.Write(apiInput.ToByteArray());
                output.Flush();
            } catch (InvalidProtocolBufferException e) {
                Console.WriteLine("Parse Error " + e.ToString());
            } catch (IOException e) {
                Console.WriteLine("Error readline " + e.ToString());
            }
        }
예제 #18
0
 private static void ApiInputSaveMapper(ApiInput apiInput, DbApiInput dbApiInput)
 {
     dbApiInput.Name         = apiInput.Name;
     dbApiInput.DefaultValue = apiInput.DefaultValue;
     dbApiInput.InputType    = apiInput.InputType;
 }
예제 #19
0
        public EzeResult cardTransaction(double amount, PaymentMode mode, OptionalParams options)
        {
            EzeResult result = null;

            Console.WriteLine("...Take Payment <" + mode + ",amount=" + amount + "," + ">");
            TxnInput.Types.TxnType txnType = TxnInput.Types.TxnType.CARD_AUTH;

            if (amount <= 0)
            {
                throw new EzeException("Amount is 0 or negative");
            }

            TxnInput tInput = TxnInput.CreateBuilder()
                              .SetTxnType(txnType)
                              .SetAmount(amount)
                              .Build();

            if (null != options)
            {
                if (null != options.getReference())
                {
                    if (null != options.getReference().getReference1())
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetOrderId(options.getReference().getReference1()).Build();
                    }
                    if (null != options.getReference().getReference2())
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetExternalReference2(options.getReference().getReference2()).Build();
                    }
                    if (null != options.getReference().getReference3())
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetExternalReference3(options.getReference().getReference3()).Build();
                    }
                }
                if (0 != options.getAmountCashback())
                {
                    tInput = TxnInput.CreateBuilder(tInput).SetAmountOther(options.getAmountCashback()).Build();
                }
                //  if (0 != options.getAamountTip()) tInput = TxnInput.CreateBuilder(tInput).Set(options.getBankCode()).Build();
                if (null != options.getCustomer())
                {
                    String mobileNumber = options.getCustomer().getMobileNumber();
                    String emailId      = options.getCustomer().getEmailId();
                    if (null != mobileNumber)
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetCustomerMobile(mobileNumber).Build();
                    }
                    if (null != emailId)
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetCustomerEmail(emailId).Build();
                    }
                }
            }

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.TXN)
                                .SetMsgData(tInput.ToByteString()).Build();

            this.send(apiInput);

            while (true)
            {
                result = this.getResult(this.receive());

                if (result.getEventName() == EventName.TAKE_PAYMENT)
                {
                    if (result.getStatus() == Status.SUCCESS)
                    {
                        EzeEvent("Payment Successful", new EventArgs());
                    }
                    else
                    {
                        EzeEvent("Payment Failed", new EventArgs());
                    }
                    break;
                }
            }

            return(result);
        }
예제 #20
0
        public EzeResult chequeTransaction(double amount, Cheque cDetails, OptionalParams options)
        {
            EzeResult result = null;

            Console.WriteLine("...Take Payment By Cash <" + ",amount=" + amount + "," + ">");
            TxnInput.Types.TxnType txnType = TxnInput.Types.TxnType.CHEQUE;

            if (amount <= 0)
            {
                throw new EzeException("Amount is 0 or negative");
            }

            TxnInput tInput = TxnInput.CreateBuilder()
                              .SetTxnType(txnType)
                              .SetAmount(amount)
                              .Build();

            if ((null == cDetails) ||
                (null == cDetails.getChequeNumber()) || (cDetails.getChequeNumber().Length == 0) ||
                (null == cDetails.getChequeDate()) || (cDetails.getChequeDate().Length == 0) ||
                (null == cDetails.getBankName()))
            {
                throw new EzeException("Cheque details not passed for a Cheque transaction");
            }

            if (null != cDetails.getChequeNumber())
            {
                tInput = TxnInput.CreateBuilder(tInput).SetChequeNumber(cDetails.getChequeNumber()).Build();
            }
            if (null != cDetails.getChequeDate())
            {
                tInput = TxnInput.CreateBuilder(tInput).SetChequeDate(cDetails.getChequeDate()).Build();
            }
            if (null != cDetails.getBankCode())
            {
                tInput = TxnInput.CreateBuilder(tInput).SetBankCode(cDetails.getBankCode()).Build();
            }
            //  if (null != cDetails.getBankName()) tInput = TxnInput.CreateBuilder(tInput).SetBankName(cDetails.getBankName()).Build();
            //  if (null != options.getChequeDate()) tInput = TxnInput.CreateBuilder(tInput).SetChequeDate(options.getChequeDate().ToString()).Build();


            if (null != options)
            {
                if (null != options.getReference())
                {
                    if (null != options.getReference().getReference1())
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetOrderId(options.getReference().getReference1()).Build();
                    }
                    if (null != options.getReference().getReference2())
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetExternalReference2(options.getReference().getReference2()).Build();
                    }
                    if (null != options.getReference().getReference3())
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetExternalReference3(options.getReference().getReference3()).Build();
                    }
                }

                if (null != options.getCustomer())
                {
                    String mobileNumber = options.getCustomer().getMobileNumber();
                    String emailId      = options.getCustomer().getEmailId();
                    if (null != mobileNumber)
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetCustomerMobile(mobileNumber).Build();
                    }
                    if (null != emailId)
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetCustomerEmail(emailId).Build();
                    }
                }
            }

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.TXN)
                                .SetMsgData(tInput.ToByteString()).Build();

            this.send(apiInput);

            while (true)
            {
                result = this.getResult(this.receive());

                if (result.getEventName() == EventName.TAKE_PAYMENT)
                {
                    if (result.getStatus() == Status.SUCCESS)
                    {
                        EzeEvent("Payment Successful", new EventArgs());
                    }
                    else
                    {
                        EzeEvent("Payment Failed", new EventArgs());
                    }
                    break;
                }
            }

            return(result);
        }
예제 #21
0
        public HttpResponseMessage Post([FromBodyAttribute] ApiInput input) // id refers to Application Key
        {
            bool isTranslationUpload     = false;
            HttpResponseMessage response = new HttpResponseMessage();
            Response            res      = new Response();

            try
            {
                if (input != null)
                {
                    MongodbConnect mongo = new MongodbConnect(ConfigurationManager.AppSettings["MongoDBName"].ToString());

                    // Validate Application key
                    var validApplication = mongo.GetRecordByApplicationKey(input.ApiAccessKey);

                    if (validApplication != null)
                    {
                        // Upload Text if not Exist
                        if (input.InputText != null)
                        {
                            isTranslationUpload = mongo.uploadText(validApplication.ApplicationID, input.InputText, mongo.GetRecordByApplicationKey(input.ApiAccessKey));
                            response            = Request.CreateResponse(HttpStatusCode.OK);
                            if (isTranslationUpload)
                            {
                                res.Message = "Translation uploaded";
                            }
                            else
                            {
                                res.Message = "No Translation uploaded";
                            }
                            res.Status = "Sucess";
                            res.Result = null;
                        }
                        else
                        {
                            response    = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Translation input text is missing in request");
                            res.Status  = "Failed";
                            res.Message = "Translation input text is missing in request";
                            res.Result  = null;
                        }
                    }
                    else
                    {
                        response    = Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Application Key is unauthorized");
                        res.Status  = "Failed";
                        res.Message = "Application Key is unauthorized";
                        res.Result  = null;
                    }
                }
                else
                {
                    response    = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "HTTP BedRequest. Check your request body and header.");
                    res.Status  = "Failed";
                    res.Message = "HTTP BedRequest. Check your request body and header.";
                    res.Result  = null;
                }
            }
            catch (Exception ex)
            {
                Console.Error.Write(ex.Message);
                response    = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unexpected Error");
                res.Status  = "Failed";
                res.Message = "Unexpected Error";
                res.Result  = null;
            }

            response.Content = new StringContent(JsonConvert.SerializeObject(res, Formatting.Indented), Encoding.UTF8, "application/json");
            return(response);
        }