@@ 40-49 (lines=10) @@ | ||
37 | * @param $zip |
|
38 | * @return \SimpleXMLElement |
|
39 | */ |
|
40 | public static function cityState(int $zip): object |
|
41 | { |
|
42 | $CityState = new \SimpleXMLElement("<CityStateLookupRequest></CityStateLookupRequest>"); |
|
43 | $CityState->addAttribute('USERID', self::$USPSuser); |
|
44 | $ZipCode = $CityState->addChild('ZipCode'); |
|
45 | $ZipCode->addAttribute('ID', '0'); |
|
46 | $ZipCode->addChild('Zip5',$zip); |
|
47 | $url = self::$service . 'CityStateLookup&XML=' . $CityState->asXML(); |
|
48 | return simplexml_load_file($url); |
|
49 | } |
|
50 | ||
51 | /** |
|
52 | * Mulitple city and state lookup |
@@ 14-22 (lines=9) @@ | ||
11 | * @param $trackingnumber |
|
12 | * @return \SimpleXMLElement |
|
13 | */ |
|
14 | public static function track(string $trackingnumber): object |
|
15 | { |
|
16 | $track = new \SimpleXMLElement("<TrackRequest></TrackRequest>"); |
|
17 | $track->addAttribute('USERID', self::$USPSuser); |
|
18 | $pack = $track->addChild('TrackID'); |
|
19 | $pack->addAttribute('ID', $trackingnumber); |
|
20 | $url = self::$service . 'TrackV2&XML=' . $track->asXML(); |
|
21 | return simplexml_load_file($url); |
|
22 | } |
|
23 | ||
24 | /** |
|
25 | * Tracking more than one package by USPS Tracking number array |
|
@@ 29-39 (lines=11) @@ | ||
26 | * @param $trackingarray (Array) |
|
27 | * @return \SimpleXMLElement |
|
28 | */ |
|
29 | public static function trackMultiple(array $trackingarray): object |
|
30 | { |
|
31 | $track = new \SimpleXMLElement("<TrackRequest></TrackRequest>"); |
|
32 | $track->addAttribute('USERID', self::$USPSuser); |
|
33 | foreach($trackingarray as $trackingnumber){ |
|
34 | $pack = $track->addChild('TrackID'); |
|
35 | $pack->addAttribute('ID', $trackingnumber); |
|
36 | } |
|
37 | $url = self::$service . 'TrackV2&XML=' . $track->asXML(); |
|
38 | return simplexml_load_file($url); |
|
39 | } |
|
40 | } |
|
41 |