using CustomerOnlineRemit.Common.Model; using CustomerOnlineRemit.Common.Model.Transaction; using Newtonsoft.Json; using System.Text; namespace CustomerOnlineRemit.Business.TPApiHelper { public class APIHelper : IAPIHelper { public async Task GetExRate(ExrateCalculateRequestModel _request) { ExrateResponse _response = new ExrateResponse(); TPResponse _responseTP = new TPResponse(); using (HttpClient client = new HttpClient()) { try { var content = new StringContent(JsonConvert.SerializeObject(_request), Encoding.UTF8, "application/json"); // Send the POST request HttpResponseMessage response = await client.PostAsync("http://77.68.15.91:1083/api/v1/TP/ExRate", content); // Check if the response is successful if (response.IsSuccessStatusCode) { string responseContent = await response.Content.ReadAsStringAsync(); _responseTP = JsonConvert.DeserializeObject(responseContent); if (_responseTP.ResponseCode == "0") { _response = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(_responseTP.Data)); _response.ResponseCode = ResponseHelper.SUCCESS; _response.ResponseMessage = ResponseMessageHelper.SUCCESS; } } else { Console.WriteLine("Error: " + response.ReasonPhrase); } } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } } return _response; } } }