Fill out tracking location from a city lookup sometimes (just see comments)

master
Skylar Ittner 2 years ago
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
* so the API can return a more complete response.
*/
public $STATELESS_CITIES = [
public const STATELESS_CITIES = [
"LOS ANGELES" => "CA",
"NEW YORK" => "NY"
];
@ -81,8 +81,8 @@ class Tracking_USPS {
* Fill in state from list above when it's missing from the API response
*/
if ($current_location->state == "" && $current_location->zip == "") {
if (in_array(strtoupper($current_location->city), $STATELESS_CITIES)) {
$current_location->state = $STATELESS_CITIES[$current_location->city];
if (array_key_exists(strtoupper($current_location->city), self::STATELESS_CITIES)) {
$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
*/
if ($location->state == "" && $location->zip == "") {
if (in_array(strtoupper($location->city), $STATELESS_CITIES)) {
$location->state = $STATELESS_CITIES[$location->city];
if (array_key_exists(strtoupper($location->city), self::STATELESS_CITIES)) {
$location->state = self::STATELESS_CITIES[$location->city];
}
}
if ((empty($history->EventDate) || empty($history->EventTime)) && $i < count($trackinfo->TrackDetail) - 1) {

Loading…
Cancel
Save