Fill out tracking location from a city lookup sometimes (just see comments)
This commit is contained in:
parent
d623fb7dfa
commit
0c12465352
@ -6,7 +6,7 @@ class Tracking_USPS {
|
|||||||
* Sometimes the API returns a city but no state or ZIP. This is a lookup table of city => state
|
* Sometimes the API returns a city but no state or ZIP. This is a lookup table of city => state
|
||||||
* so the API can return a more complete response.
|
* so the API can return a more complete response.
|
||||||
*/
|
*/
|
||||||
public $STATELESS_CITIES = [
|
public const STATELESS_CITIES = [
|
||||||
"LOS ANGELES" => "CA",
|
"LOS ANGELES" => "CA",
|
||||||
"NEW YORK" => "NY"
|
"NEW YORK" => "NY"
|
||||||
];
|
];
|
||||||
@ -81,8 +81,8 @@ class Tracking_USPS {
|
|||||||
* Fill in state from list above when it's missing from the API response
|
* Fill in state from list above when it's missing from the API response
|
||||||
*/
|
*/
|
||||||
if ($current_location->state == "" && $current_location->zip == "") {
|
if ($current_location->state == "" && $current_location->zip == "") {
|
||||||
if (in_array(strtoupper($current_location->city), $STATELESS_CITIES)) {
|
if (array_key_exists(strtoupper($current_location->city), self::STATELESS_CITIES)) {
|
||||||
$current_location->state = $STATELESS_CITIES[$current_location->city];
|
$current_location->state = self::STATELESS_CITIES[$current_location->city];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,8 +119,8 @@ class Tracking_USPS {
|
|||||||
* Fill in state from list above when it's missing from the API response
|
* Fill in state from list above when it's missing from the API response
|
||||||
*/
|
*/
|
||||||
if ($location->state == "" && $location->zip == "") {
|
if ($location->state == "" && $location->zip == "") {
|
||||||
if (in_array(strtoupper($location->city), $STATELESS_CITIES)) {
|
if (array_key_exists(strtoupper($location->city), self::STATELESS_CITIES)) {
|
||||||
$location->state = $STATELESS_CITIES[$location->city];
|
$location->state = self::STATELESS_CITIES[$location->city];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((empty($history->EventDate) || empty($history->EventTime)) && $i < count($trackinfo->TrackDetail) - 1) {
|
if ((empty($history->EventDate) || empty($history->EventTime)) && $i < count($trackinfo->TrackDetail) - 1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user