From d59d3fc5fc7a59e7609adb46e885b523a908db25 Mon Sep 17 00:00:00 2001 From: Kyle West Date: Thu, 29 Sep 2016 14:21:53 +0000 Subject: [PATCH] add origin country code to UPSProvider [closes #52] --- DotNetShipping.Tests/Features/UPSRates.cs | 23 +++++++++++++++++++ .../ShippingProviders/UPSProvider.cs | 1 + 2 files changed, 24 insertions(+) diff --git a/DotNetShipping.Tests/Features/UPSRates.cs b/DotNetShipping.Tests/Features/UPSRates.cs index f6ce759..324225b 100644 --- a/DotNetShipping.Tests/Features/UPSRates.cs +++ b/DotNetShipping.Tests/Features/UPSRates.cs @@ -104,6 +104,29 @@ public void UPS_Returns_Multiple_Rates_When_Using_Valid_Addresses_For_All_Servic } } + [Fact] + public void UPS_Returns_Rates_When_Using_International_Origin_And_Destination_Addresses_For_All_Services() + { + var rateManager = new RateManager(); + rateManager.AddProvider(new UPSProvider(UPSLicenseNumber, UPSUserId, UPSPassword)); + + var response = rateManager.GetRates(InternationalAddress2, InternationalAddress1, Package1); + + Debug.WriteLine(string.Format("Rates returned: {0}", response.Rates.Any() ? response.Rates.Count.ToString() : "0")); + + Assert.NotNull(response); + Assert.NotEmpty(response.Rates); + Assert.Empty(response.ServerErrors); + + foreach (var rate in response.Rates) + { + Assert.NotNull(rate); + Assert.True(rate.TotalCharges > 0); + + Debug.WriteLine(rate.Name + ": " + rate.TotalCharges); + } + } + [Fact] public void UPS_Returns_Rates_When_Using_International_Destination_Addresses_For_All_Services() { diff --git a/DotNetShipping/ShippingProviders/UPSProvider.cs b/DotNetShipping/ShippingProviders/UPSProvider.cs index 8ea3b97..a834b6c 100644 --- a/DotNetShipping/ShippingProviders/UPSProvider.cs +++ b/DotNetShipping/ShippingProviders/UPSProvider.cs @@ -175,6 +175,7 @@ private byte[] BuildRatesRequestMessage() } writer.WriteStartElement("Address"); writer.WriteElementString("PostalCode", Shipment.OriginAddress.PostalCode); + writer.WriteElementString("CountryCode", Shipment.OriginAddress.CountryCode); writer.WriteEndElement(); // writer.WriteEndElement(); // writer.WriteStartElement("ShipTo");