CleanAddressService¶
Implements ICleanAddressService as the layer between SAIF applications and the CorrectAddress web-service program (per its own doc comment, reachable at wsCorrectAddress/clsCAServices.asmx in production), cleansing and standardizing a single mailing address and classifying the vendor's numeric return code and USPS error codes into clean/unmatched/multiple-match outcomes. It extends CleanAddressServiceBase for the shared proxy and disposal behavior.
Purpose¶
- Standardizes a single address (line 1/2, city, state, ZIP, ZIP+4) via the CorrectAddress vendor service, optionally converting to mixed case.
- Classifies the vendor's return code and USPS error codes into
IsAddressClean,IsUnmatched, andHasMultipleMatchesoutcomes. - Computes a POSTNET barcode from the returned ZIP, ZIP+4, delivery point, and check digit.
- Converts arbitrary text to proper case via the vendor service.
Context¶
- Namespace:
SAIF.Services.Utilities.CleanAddress - Assembly/package:
SAIF.Services(packaged inside theSAIF.SAIFCode.CoreNuGet package)
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| CleanAddressService(...) | public CleanAddressService(clsCAServices service) |
Wires the CorrectAddress SOAP proxy into the shared base class, applying its default connection settings. |
| ConvertToProperCase | public string ConvertToProperCase(string value) |
Returns value converted to proper (title) case by the CorrectAddress vendor service, trimmed of surrounding whitespace. |
| CleanAddress | public ICleanedAddress CleanAddress(string addressLine1, string addressLine2, string city, string state, string zip, string zip4, bool mixedCase) |
Sends the address to CorrectAddress for standardization and returns the cleansed address fields, parsed USPS errors, POSTNET barcode, and clean/unmatched/multiple-match classification; on any vendor exception it treats the result as return code -999 rather than propagating the error. |
| IsAddressClean | protected virtual bool IsAddressClean(int returnCode, ICleanAddressErrors errors) |
Returns true when the return code is 1, or -1 without USPS error code "11" (ambiguous match), indicating the address was successfully standardized. |
| IsUnmatched | protected virtual bool IsUnmatched(int returnCode) |
Returns true when the return code is -1, -99, or -999, indicating the vendor could not match the address. |
| HasMultipleMatches | protected virtual bool HasMultipleMatches(int returnCode, ICleanAddressErrors errors) |
Returns true when the address is neither clean nor unmatched, indicating the vendor returned more than one candidate match. |
| GetPostNetBarcode | protected virtual string GetPostNetBarcode(string checkDigit, string zip, string zip4, string deliveryPoint) |
Builds the USPS POSTNET barcode string from ZIP, ZIP+4, delivery-point, and check-digit segments, returning an empty string when the check digit is not a single numeric character. |
| Dispose() | public void Dispose() |
Releases the underlying clsCAServices proxy connection (inherited from CleanAddressServiceBase). |
Behavioral notes¶
CleanAddressdeliberately swallows exceptions from the vendor call and substitutes return code-999("gobble return of dirty data from vendor product") so callers always receive a result object rather than an exception.- The four classification/barcode helper methods are
protected virtual, allowing derived test doubles or specialized subclasses to override CorrectAddress return-code interpretation*.
Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.
Sources¶
- Services/SAIF.Services/Utilities/CleanAddress/CleanAddressService.cs