1.0.1 • Published 6 months ago
@evokegroup/usps
Library for validating address information with USPS
UspsClient
constructor()
Parameter | Type | Default | Description |
---|
apiUserID | string | | |
apiUrl | string | https://production.shippingapis.com/ShippingAPI.dll | |
Methods
validateAddress()
Parameter | Type | Default | Description |
---|
address1 | string | | |
address2 | string | | |
city | string | | |
state | string | | |
zip5 | string | | |
zip4 | string | | |
returns Promise<ValidateResponse>
import { UpspClient } from '@evokegroup/usps';
const usps = new UspsClient('XXXXXXXXXX');
usps.validateAddress({
address1: '123 Main St',
city: 'Anytown',
state: 'ST',
zip5: '12345'
})
.then((validateResponse) => {
// do something
})
.catch((err) => {
// handle error
});
cityStateLookup()
Parameter | Type | Default | Description |
---|
zip5 | string | | |
returns Promise<Response>
import { UpspClient } from '@evokegroup/usps';
const usps = new UspsClient('XXXXXXXXXX');
usps.cityStateLookup('12345')
.then((Response) => {
// do something
})
.catch((err) => {
// handle error
});
zipCodeLookup()
Parameter | Type | Default | Description |
---|
address1 | string | | |
city | string | | |
state | string | | |
returns Promise<Response>
import { UpspClient } from '@evokegroup/usps';
const usps = new UspsClient('XXXXXXXXXX');
usps.zipCodeLookup({
address1: '123 Main St',
city: 'Anytown',
state: 'ST'
})
.then((Response) => {
// do something
})
.catch((err) => {
// handle error
});
Response
Name | Type | Description |
---|
found | boolean | |
status | Status | |
address | Address | |
error | string | |
ValidateResponse
extends Response
Name | Type | Description |
---|
match | AddressMatch | |
exactMatch | boolean | |
Address
Name | Type | Description |
---|
address1 | string | |
address2 | string | |
city | string | |
state | string | |
zip5 | string | |
zip4 | string | |
AddressMatch
Name | Type | Description |
---|
address1 | boolean | |
address2 | boolean | |
city | boolean | |
state | boolean | |
zip5 | boolean | |
zip4 | boolean | |
Status
'FOUND' | 'ADDRESS_NOT_FOUND' | 'INVALID_CITY' | 'INVALID_STATE' | 'INVALID_ZIP_CODE' | 'ERROR'