You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.9 KiB
49 lines
1.9 KiB
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<ExrateResponse> 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<TPResponse>(responseContent);
|
|
if (_responseTP.ResponseCode == "0")
|
|
{
|
|
_response = JsonConvert.DeserializeObject<ExrateResponse>(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;
|
|
}
|
|
}
|
|
}
|