-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f48fb22
commit 7b5c55e
Showing
11 changed files
with
255 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using LibPostalApi.Models; | ||
using LibPostalNet; | ||
|
||
namespace LibPostalApi.ExtensionMethods; | ||
|
||
public static class MappingExtensions | ||
{ | ||
public static void MapValuesTo(this ExpandOptions dto, AddressExpansionOptions domain) | ||
{ | ||
if (dto.Languages is { Length: > 0 }) | ||
{ | ||
domain.Languages = dto.Languages; | ||
} | ||
if (dto.AddressComponents != null) | ||
{ | ||
domain.AddressComponents = (AddressComponents)dto.AddressComponents; | ||
} | ||
if (dto.LatinAscii.HasValue) | ||
{ | ||
domain.LatinAscii = dto.LatinAscii.Value; | ||
} | ||
if (dto.Transliterate.HasValue) | ||
{ | ||
domain.Transliterate = dto.Transliterate.Value; | ||
} | ||
if (dto.StripAccents.HasValue) | ||
{ | ||
domain.StripAccents = dto.StripAccents.Value; | ||
} | ||
if (dto.Decompose.HasValue) | ||
{ | ||
domain.Decompose = dto.Decompose.Value; | ||
} | ||
if (dto.Lowercase.HasValue) | ||
{ | ||
domain.Lowercase = dto.Lowercase.Value; | ||
} | ||
if (dto.TrimString.HasValue) | ||
{ | ||
domain.TrimString = dto.TrimString.Value; | ||
} | ||
if (dto.DropParentheticals.HasValue) | ||
{ | ||
domain.DropParentheticals = dto.DropParentheticals.Value; | ||
} | ||
if (dto.ReplaceNumericHyphens.HasValue) | ||
{ | ||
domain.ReplaceNumericHyphens = dto.ReplaceNumericHyphens.Value; | ||
} | ||
if (dto.DeleteNumericHyphens.HasValue) | ||
{ | ||
domain.DeleteNumericHyphens = dto.DeleteNumericHyphens.Value; | ||
} | ||
if (dto.SplitAlphaFromNumeric.HasValue) | ||
{ | ||
domain.SplitAlphaFromNumeric = dto.SplitAlphaFromNumeric.Value; | ||
} | ||
if (dto.ReplaceWordHyphens.HasValue) | ||
{ | ||
domain.ReplaceWordHyphens = dto.ReplaceWordHyphens.Value; | ||
} | ||
if (dto.DeleteWordHyphens.HasValue) | ||
{ | ||
domain.DeleteWordHyphens = dto.DeleteWordHyphens.Value; | ||
} | ||
if (dto.DeleteFinalPeriods.HasValue) | ||
{ | ||
domain.DeleteFinalPeriods = dto.DeleteFinalPeriods.Value; | ||
} | ||
if (dto.DeleteAcronymPeriods.HasValue) | ||
{ | ||
domain.DeleteAcronymPeriods = dto.DeleteAcronymPeriods.Value; | ||
} | ||
if (dto.DropEnglishPossessives.HasValue) | ||
{ | ||
domain.DropEnglishPossessives = dto.DropEnglishPossessives.Value; | ||
} | ||
if (dto.DeleteApostrophes.HasValue) | ||
{ | ||
domain.DeleteApostrophes = dto.DeleteApostrophes.Value; | ||
} | ||
if (dto.ExpandNumex.HasValue) | ||
{ | ||
domain.ExpandNumex = dto.ExpandNumex.Value; | ||
} | ||
if (dto.RomanNumerals.HasValue) | ||
{ | ||
domain.RomanNumerals = dto.RomanNumerals.Value; | ||
} | ||
} | ||
|
||
public static void MapValuesTo(this ParseOptions dto, AddressParserOptions domain) | ||
{ | ||
if (!string.IsNullOrEmpty(dto.Country)) | ||
{ | ||
domain.Country = dto.Country.Trim(); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(dto.Language)) | ||
{ | ||
domain.Language = dto.Language.Trim(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
using LibPostalNet; | ||
using LibPostalApi.Models; | ||
using LibPostalNet; | ||
|
||
namespace LibPostalApi.Interfaces; | ||
|
||
public interface ILibPostalService | ||
{ | ||
AddressParserResponse ParseAddress(string address); | ||
AddressExpansionResponse ExpandAddress(string address); | ||
(AddressParserResponse[]? Results, int Successes, int Failures) ParseAddress(List<string> addresses, ParseOptions? dtoOptions); | ||
(AddressExpansionResponse[]? Results, int Successes, int Failures) ExpandAddress(List<string> addresses, ExpandOptions? dtoOptions); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,31 @@ | ||
using LibPostalNet; | ||
|
||
namespace LibPostalApi.Models; | ||
public record ParseAddressesRequest(List<string> Addresses); | ||
public record ExpandAddressesRequest(List<string> Addresses); | ||
public record ExpandAddressesResponse(List<AddressExpansionResponse> ParseResults); | ||
public record ParseAddressesResponse(List<AddressParserResponse> ParseResults); | ||
public record ParseAddressesRequest(List<string>? Addresses, ParseOptions? ParseOptions); | ||
public record ExpandAddressesRequest(List<string>? Addresses, ExpandOptions? ExpandOptions); | ||
public record ExpandAddressesResponse(AddressExpansionResponse[]? ParseResults, int AddressesReceived, int SuccessfullyParsedCount, int UnsuccessfullyParsedCount); | ||
public record ParseAddressesResponse(AddressParserResponse[]? ParseResults, int AddressesReceived, int SuccessfullyExpandCount, int UnsuccessfullyExpandedCount); | ||
public record ParseOptions(string? Country, string? Language); | ||
|
||
public record ExpandOptions( | ||
string[]? Languages, | ||
int? AddressComponents, | ||
bool? LatinAscii, | ||
bool? Transliterate, | ||
bool? StripAccents, | ||
bool? Decompose, | ||
bool? Lowercase, | ||
bool? TrimString, | ||
bool? DropParentheticals, | ||
bool? ReplaceNumericHyphens, | ||
bool? DeleteNumericHyphens, | ||
bool? SplitAlphaFromNumeric, | ||
bool? ReplaceWordHyphens, | ||
bool? DeleteWordHyphens, | ||
bool? DeleteFinalPeriods, | ||
bool? DeleteAcronymPeriods, | ||
bool? DropEnglishPossessives, | ||
bool? DeleteApostrophes, | ||
bool? ExpandNumex, | ||
bool? RomanNumerals | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.