first commit

This commit is contained in:
Zeeshaun
2026-03-11 11:18:25 -05:00
commit f3cb730f3b
472 changed files with 53651 additions and 0 deletions
@@ -0,0 +1,46 @@
using System.Xml.Linq;
using Microsoft.Extensions.Options;
using Serilog;
using USPS.Configuration;
namespace USPS.Communication
{
public class UspsService : IUspsService
{
private readonly UspsSettings _settings;
public UspsService(
IOptions<UspsSettings> settings)
{
_settings = settings.Value;
}
public async Task<XElement> SendMessage(string request)
{
try
{
var hc = new HttpClient();
var result = await hc.GetAsync(request);
if (result.IsSuccessStatusCode)
{
var resultString = await result.Content.ReadAsStringAsync();
var xdoc = XDocument.Parse(resultString);
XElement xel = XElement.Parse(xdoc.ToString());
return xel;
}
else
{
throw new Exception("Bad status code from USPS");
}
}
catch (Exception e)
{
Log.Debug("{exception}", e.Message);
throw;
}
}
}
}