CRM_Utils_Address_USPS
in package
Address utilities.
Table of Contents
Constants
- ADDRESS_VALIDATE_ENDPOINT = '/addresses/v3/address'
- Address validation endpoint
- OAUTH_TOKEN_URL = 'https://apis.usps.com/oauth2/v3/token'
- OAuth Token URL
- USPS_API_BASE = 'https://api.usps.com'
- USPS API Base URL
Properties
- $_disabled : bool
- Whether USPS validation should be disabled during import.
- $accessToken : array<string|int, mixed>
- Cached OAuth token
- $tokenExpiry : int
- Token expiration time
Methods
- checkAddress() : bool
- Format address values according to USPS
- disable() : void
- Disable the USPS validation.
- isConfigured() : bool
- Check if the USPS provider is configured and available
- formatAddressForAPI() : array<string|int, mixed>
- Format address values for submission to USPS
- getAccessToken() : string|null
- Get OAuth Access Token
- parseResponse() : array<string|int, mixed>|null
- Parse the USPS API response and format for CiviCRM
Constants
ADDRESS_VALIDATE_ENDPOINT
Address validation endpoint
public
mixed
ADDRESS_VALIDATE_ENDPOINT
= '/addresses/v3/address'
OAUTH_TOKEN_URL
OAuth Token URL
public
mixed
OAUTH_TOKEN_URL
= 'https://apis.usps.com/oauth2/v3/token'
USPS_API_BASE
USPS API Base URL
public
mixed
USPS_API_BASE
= 'https://api.usps.com'
Properties
$_disabled
Whether USPS validation should be disabled during import.
protected
static bool
$_disabled
= \FALSE
$accessToken
Cached OAuth token
protected
static array<string|int, mixed>
$accessToken
= \NULL
$tokenExpiry
Token expiration time
protected
static int
$tokenExpiry
= 0
Methods
checkAddress()
Format address values according to USPS
public
static checkAddress(array<string|int, mixed> &$values) : bool
Parameters
- $values : array<string|int, mixed>
Return values
booldisable()
Disable the USPS validation.
public
static disable([bool $disable = true ]) : void
Parameters
- $disable : bool = true
isConfigured()
Check if the USPS provider is configured and available
public
static isConfigured() : bool
Return values
boolformatAddressForAPI()
Format address values for submission to USPS
protected
static formatAddressForAPI(array<string|int, mixed> $values) : array<string|int, mixed>
Parameters
- $values : array<string|int, mixed>
Return values
array<string|int, mixed>getAccessToken()
Get OAuth Access Token
protected
static getAccessToken() : string|null
Tags
Return values
string|nullparseResponse()
Parse the USPS API response and format for CiviCRM
protected
static parseResponse(array<string|int, mixed> $response, array<string|int, mixed> $originalValues) : array<string|int, mixed>|null
Parameters
- $response : array<string|int, mixed>
- $originalValues : array<string|int, mixed>