Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdditionalInfo ¶
type AdditionalInfo struct {
// Delivery point code
DeliveryPoint string
// Carrier route code
CarrierRoute string
// DPV (Delivery Point Validation) confirmation indicator
DPVConfirmation string
// DPVCMRA (Commercial Mail Receiving Agency) indicator
DPVCMRA string
// Business flag
Business string
// Central delivery flag
CentralDeliveryPoint string
// Vacant flag
Vacant string
}
AdditionalInfo contains additional address information
type Address ¶
type Address struct {
// Firm/business name at the address
Firm string
// Street address (primary line)
StreetAddress string
// Abbreviated street address
StreetAddressAbbreviation string
// Secondary address (apartment, suite, etc.)
SecondaryAddress string
// City name
City string
// Abbreviated city name
CityAbbreviation string
// Two-letter state code
State string
// 5-digit ZIP code
ZIPCode string
// 4-digit ZIP+4 extension
ZIPPlus4 string
// Urbanization code (Puerto Rico addresses)
Urbanization string
}
Address represents a canonicalized USPS address
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides address validation using the USPS API
func NewClient ¶
NewClient creates a new USPS address validation client The config must contain ClientID and ClientSecret from the USPS developer portal
func (*Client) ValidateAddress ¶
ValidateAddress validates and canonicalizes an address Returns an array of validation results (typically one, but may be multiple for ambiguous addresses)
type Config ¶
type Config struct {
// ClientID is the OAuth2 client ID from USPS developer portal
ClientID string
// ClientSecret is the OAuth2 client secret from USPS developer portal
ClientSecret string
// ServerURL is the USPS API server URL (optional, defaults to production)
// Production: https://apis.usps.com/addresses/v3
// Testing: https://apis-tem.usps.com/addresses/v3
ServerURL string
// TokenURL is the OAuth2 token endpoint (optional, defaults to production)
// Production: https://apis.usps.com/oauth2/v3/token
// Testing: https://apis-tem.usps.com/oauth2/v3/token
TokenURL string
LogLevel string
}
Config contains the USPS API credentials
type Correction ¶
type Correction struct {
Code string
Text string
// UserMessage provides a user-friendly explanation of the correction
// This is derived from the correction code and DPV confirmation
UserMessage string
}
Correction indicates how to improve the address input
type Error ¶
type Error struct {
Status string
Code string
Title string
Detail string
Source *ErrorSource
}
Error represents a USPS API error
type ErrorSource ¶
ErrorSource identifies the source of an error
type ValidationResult ¶
type ValidationResult struct {
// The canonicalized address
Address Address
// Codes indicating how to improve the address
Corrections []Correction
// Codes indicating match quality
Matches []Match
// Warning messages
Warnings []string
// Additional information about the address
AdditionalInfo *AdditionalInfo
}
ValidationResult contains the results of address validation
Directories
¶
| Path | Synopsis |
|---|---|
|
Package uspsinternal provides primitives to interact with the openapi HTTP API.
|
Package uspsinternal provides primitives to interact with the openapi HTTP API. |