Skip to content

Commit

Permalink
adding stamps and refactoring some of the fedex
Browse files Browse the repository at this point in the history
  • Loading branch information
kdcllc committed Apr 5, 2022
1 parent a3be198 commit ef5376b
Show file tree
Hide file tree
Showing 67 changed files with 2,252 additions and 1,151 deletions.
35 changes: 33 additions & 2 deletions EasyKeys.Shipping.sln
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyKeys.Shipping.Usps.Rate
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyKeys.Shipping.Usps.Abstractions", "src\EasyKeys.Shipping.Usps.Abstractions\EasyKeys.Shipping.Usps.Abstractions.csproj", "{43B95498-1D1F-4884-AE14-9001D0A6FA4E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyKeys.Shipping.Usps.Tracking", "src\EasyKeys.Shipping.Usps.Tracking\EasyKeys.Shipping.Usps.Tracking.csproj", "{75549EDC-66EF-4BDB-BED6-AC26E6DF1630}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyKeys.Shipping.Usps.Tracking", "src\EasyKeys.Shipping.Usps.Tracking\EasyKeys.Shipping.Usps.Tracking.csproj", "{75549EDC-66EF-4BDB-BED6-AC26E6DF1630}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Stamps", "Stamps", "{C8221B09-84F2-4A06-A6CA-7E89238E5EB2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyKeys.Shipping.Stamps.Abstractions", "src\EasyKeys.Shipping.Stamps.Abstractions\EasyKeys.Shipping.Stamps.Abstractions.csproj", "{5686FBAB-91C3-4211-A460-E6C9903E0CE3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyKeys.Shipping.Stamps.Abstractions", "src\EasyKeys.Shipping.Stamps.Abstractions\EasyKeys.Shipping.Stamps.Abstractions.csproj", "{5686FBAB-91C3-4211-A460-E6C9903E0CE3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyKeys.Shipping.Stamps.Rates", "src\EasyKeys.Shipping.Stamps.Rates\EasyKeys.Shipping.Stamps.Rates.csproj", "{4144A7BF-97F9-42AE-843B-68ADDA54C661}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyKeys.Shipping.Stamps.Console", "src\EasyKeys.Shipping.Stamps.Console\EasyKeys.Shipping.Stamps.Console.csproj", "{DAFA0110-5502-4778-8372-714A19143178}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -224,6 +229,30 @@ Global
{5686FBAB-91C3-4211-A460-E6C9903E0CE3}.Release|x64.Build.0 = Release|Any CPU
{5686FBAB-91C3-4211-A460-E6C9903E0CE3}.Release|x86.ActiveCfg = Release|Any CPU
{5686FBAB-91C3-4211-A460-E6C9903E0CE3}.Release|x86.Build.0 = Release|Any CPU
{4144A7BF-97F9-42AE-843B-68ADDA54C661}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4144A7BF-97F9-42AE-843B-68ADDA54C661}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4144A7BF-97F9-42AE-843B-68ADDA54C661}.Debug|x64.ActiveCfg = Debug|Any CPU
{4144A7BF-97F9-42AE-843B-68ADDA54C661}.Debug|x64.Build.0 = Debug|Any CPU
{4144A7BF-97F9-42AE-843B-68ADDA54C661}.Debug|x86.ActiveCfg = Debug|Any CPU
{4144A7BF-97F9-42AE-843B-68ADDA54C661}.Debug|x86.Build.0 = Debug|Any CPU
{4144A7BF-97F9-42AE-843B-68ADDA54C661}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4144A7BF-97F9-42AE-843B-68ADDA54C661}.Release|Any CPU.Build.0 = Release|Any CPU
{4144A7BF-97F9-42AE-843B-68ADDA54C661}.Release|x64.ActiveCfg = Release|Any CPU
{4144A7BF-97F9-42AE-843B-68ADDA54C661}.Release|x64.Build.0 = Release|Any CPU
{4144A7BF-97F9-42AE-843B-68ADDA54C661}.Release|x86.ActiveCfg = Release|Any CPU
{4144A7BF-97F9-42AE-843B-68ADDA54C661}.Release|x86.Build.0 = Release|Any CPU
{DAFA0110-5502-4778-8372-714A19143178}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DAFA0110-5502-4778-8372-714A19143178}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DAFA0110-5502-4778-8372-714A19143178}.Debug|x64.ActiveCfg = Debug|Any CPU
{DAFA0110-5502-4778-8372-714A19143178}.Debug|x64.Build.0 = Debug|Any CPU
{DAFA0110-5502-4778-8372-714A19143178}.Debug|x86.ActiveCfg = Debug|Any CPU
{DAFA0110-5502-4778-8372-714A19143178}.Debug|x86.Build.0 = Debug|Any CPU
{DAFA0110-5502-4778-8372-714A19143178}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DAFA0110-5502-4778-8372-714A19143178}.Release|Any CPU.Build.0 = Release|Any CPU
{DAFA0110-5502-4778-8372-714A19143178}.Release|x64.ActiveCfg = Release|Any CPU
{DAFA0110-5502-4778-8372-714A19143178}.Release|x64.Build.0 = Release|Any CPU
{DAFA0110-5502-4778-8372-714A19143178}.Release|x86.ActiveCfg = Release|Any CPU
{DAFA0110-5502-4778-8372-714A19143178}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -245,6 +274,8 @@ Global
{75549EDC-66EF-4BDB-BED6-AC26E6DF1630} = {8820A422-5EB7-4291-9F01-00B9BBA4302E}
{C8221B09-84F2-4A06-A6CA-7E89238E5EB2} = {BCBBDD1A-FF30-41E8-B7C1-9BB2A441FF83}
{5686FBAB-91C3-4211-A460-E6C9903E0CE3} = {C8221B09-84F2-4A06-A6CA-7E89238E5EB2}
{4144A7BF-97F9-42AE-843B-68ADDA54C661} = {C8221B09-84F2-4A06-A6CA-7E89238E5EB2}
{DAFA0110-5502-4778-8372-714A19143178} = {C8221B09-84F2-4A06-A6CA-7E89238E5EB2}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0FBE81B8-162F-4342-BABD-0FFFD0C99331}
Expand Down
10 changes: 5 additions & 5 deletions build/dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<PackageReference Update="Microsoft.Azure.Cosmos.Table" Version="1.0.8" />
<PackageReference Update="Microsoft.Azure.ServiceBus" Version="5.1.0" />
<PackageReference Update="Microsoft.Azure.Storage.Blob" Version="11.2.2" />
<PackageReference Update="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.11.*" />
<PackageReference Update="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.15.*" />
<PackageReference Update="Microsoft.CSharp" Version="4.8.1" />
<PackageReference Update="System.Drawing.Common" Version="4.8.1" />
</ItemGroup>
Expand All @@ -56,16 +56,16 @@
</ItemGroup>

<ItemGroup Label="Unit Tests">
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Update="Microsoft.AspNetCore.TestHost" Version="$(NetCoreVersion)" />
<PackageReference Update="Moq" Version="4.16.1" />
<PackageReference Update="Moq" Version="4.17.2" />
<PackageReference Update="xunit" Version="2.4.1" />
<PackageReference Update="xunit.runner.visualstudio" Version="2.4.3" PrivateAssets="All" />
<PackageReference Update="coverlet.collector" Version="3.1.0" PrivateAssets="All" />
<PackageReference Update="coverlet.collector" Version="3.1.2" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Label="SourceLink">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Label="Analyzers">
Expand Down
6 changes: 4 additions & 2 deletions src/EasyKeys.Shipping.Abstractions/AddressExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace EasyKeys.Shipping.Abstractions;
using EasyKeys.Shipping.Abstractions.Models;

namespace EasyKeys.Shipping.Abstractions;

public static class AddressExtensions
{
Expand All @@ -12,7 +14,7 @@ public static string[] GetStreetLines(this Address address)
var streetLines = new List<string>
{
address.StreetLine.Trim(),
address.StreetLine2.Trim()
address?.StreetLine2?.Trim() ?? string.Empty,
};
streetLines = streetLines.Where(l => !string.IsNullOrEmpty(l)).ToList();
return streetLines.Any() ? streetLines.ToArray() : new string[] { string.Empty };
Expand Down
215 changes: 106 additions & 109 deletions src/EasyKeys.Shipping.Abstractions/Models/Address.cs
Original file line number Diff line number Diff line change
@@ -1,138 +1,135 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Globalization;

namespace EasyKeys.Shipping.Abstractions
namespace EasyKeys.Shipping.Abstractions.Models;

public class Address
{
public class Address
public Address()
{
public Address()
{
}
}

public Address(
string city,
string stateOrProvince,
string postalCode,
string countryCode)
: this(string.Empty, string.Empty, city, stateOrProvince, postalCode, countryCode)
{
}
public Address(
string city,
string stateOrProvince,
string postalCode,
string countryCode)
: this(string.Empty, string.Empty, city, stateOrProvince, postalCode, countryCode)
{
}

public Address(
string streetLine,
string city,
string stateOrProvince,
string postalCode,
string countryCode)
: this(streetLine, string.Empty, city, stateOrProvince, postalCode, countryCode)
{
}
public Address(
string streetLine,
string city,
string stateOrProvince,
string postalCode,
string countryCode)
: this(streetLine, string.Empty, city, stateOrProvince, postalCode, countryCode)
{
}

public Address(
string streetLine,
string city,
string stateOrProvince,
string postalCode,
string countryCode,
bool isResidential)
: this(streetLine, string.Empty, city, stateOrProvince, postalCode, countryCode, isResidential)
{
}
public Address(
string streetLine,
string city,
string stateOrProvince,
string postalCode,
string countryCode,
bool isResidential)
: this(streetLine, string.Empty, city, stateOrProvince, postalCode, countryCode, isResidential)
{
}

public Address(
string streetLine,
string streetLine1,
string city,
string stateOrProvince,
string postalCode,
string countryCode,
bool isResidential = false)
{
StreetLine = streetLine;
StreetLine2 = streetLine1;
City = city;
StateOrProvince = stateOrProvince;
PostalCode = postalCode;
CountryCode = countryCode;
IsResidential = isResidential;
}
public Address(
string streetLine,
string streetLine1,
string city,
string stateOrProvince,
string postalCode,
string countryCode,
bool isResidential = false)
{
StreetLine = streetLine;
StreetLine2 = streetLine1;
City = city;
StateOrProvince = stateOrProvince;
PostalCode = postalCode;
CountryCode = countryCode;
IsResidential = isResidential;
}

public string City { get; set; } = string.Empty;
public string City { get; set; } = string.Empty;

public string CountryCode { get; set; } = string.Empty;
public string CountryCode { get; set; } = string.Empty;

public string CountryName { get; set; } = string.Empty;
public string CountryName { get; set; } = string.Empty;

public string StreetLine { get; set; } = string.Empty;
public string StreetLine { get; set; } = string.Empty;

public string StreetLine2 { get; set; } = string.Empty;
public string StreetLine2 { get; set; } = string.Empty;

public string PostalCode { get; set; } = string.Empty;
public string PostalCode { get; set; } = string.Empty;

public string StateOrProvince { get; set; } = string.Empty;
public string StateOrProvince { get; set; } = string.Empty;

public bool IsResidential { get; set; }
public bool IsResidential { get; set; }

public string GetCountryName()
public string GetCountryName()
{
if (!string.IsNullOrEmpty(CountryName))
{
if (!string.IsNullOrEmpty(CountryName))
{
return CountryName;
}

if (string.IsNullOrEmpty(CountryCode))
{
return string.Empty;
}

var countryCode = CountryCode;

// UK = GB United Kingdom
// EI = IE Ireland
// FX = FR France, Metropolitan
if (string.Equals(countryCode, "UK", StringComparison.OrdinalIgnoreCase))
{
countryCode = "GB";
}

if (string.Equals(countryCode, "EI", StringComparison.OrdinalIgnoreCase))
{
countryCode = "IE";
}

if (string.Equals(countryCode, "FX", StringComparison.OrdinalIgnoreCase))
{
countryCode = "FR";
}

try
{
var regionInfo = new RegionInfo(countryCode);
return regionInfo.EnglishName;
}
catch
{
// causes the whole application to crash.
}
return CountryName;
}

if (string.IsNullOrEmpty(CountryCode))
{
return string.Empty;
}

public bool IsCanadaAddress()
var countryCode = CountryCode;

// UK = GB United Kingdom
// EI = IE Ireland
// FX = FR France, Metropolitan
if (string.Equals(countryCode, "UK", StringComparison.OrdinalIgnoreCase))
{
countryCode = "GB";
}

if (string.Equals(countryCode, "EI", StringComparison.OrdinalIgnoreCase))
{
return !string.IsNullOrEmpty(CountryCode) && string.Equals(CountryCode, "CA", StringComparison.OrdinalIgnoreCase);
countryCode = "IE";
}

/// <summary>
/// Returns true if the CountryCode matches US or one of the US territories.
/// </summary>
/// <returns></returns>
public bool IsUnitedStatesAddress()
if (string.Equals(countryCode, "FX", StringComparison.OrdinalIgnoreCase))
{
var usAndTerritories = new List<string> { "AS", "GU", "MP", "PR", "UM", "VI", "US" };
countryCode = "FR";
}

return usAndTerritories.Contains(CountryCode);
try
{
var regionInfo = new RegionInfo(countryCode);
return regionInfo.EnglishName;
}
catch
{
// causes the whole application to crash.
}

return string.Empty;
}

public bool IsCanadaAddress()
{
return !string.IsNullOrEmpty(CountryCode) && string.Equals(CountryCode, "CA", StringComparison.OrdinalIgnoreCase);
}

/// <summary>
/// Returns true if the CountryCode matches US or one of the US territories.
/// </summary>
/// <returns></returns>
public bool IsUnitedStatesAddress()
{
var usAndTerritories = new List<string> { "AS", "GU", "MP", "PR", "UM", "VI", "US" };

return usAndTerritories.Contains(CountryCode);
}
}
19 changes: 0 additions & 19 deletions src/EasyKeys.Shipping.Abstractions/Models/Charges.cs

This file was deleted.

19 changes: 0 additions & 19 deletions src/EasyKeys.Shipping.Abstractions/Models/CollectOnDelivery.cs

This file was deleted.

Loading

0 comments on commit ef5376b

Please sign in to comment.