forked from VinceG/USPS-php-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
USPSZipCodeLookup.php
46 lines (46 loc) · 1.14 KB
/
USPSZipCodeLookup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* Load required classes
*/
require_once('USPSBase.php');
require_once('USPSAddress.php');
/**
* USPS Zip code lookup by city/state
* used to find a zip code by city/state lookup
* @since 1.0
* @author Vincent Gabriel
*/
class USPSZipCodeLookup extends USPSBase {
/**
* @var string - the api version used for this type of call
*/
protected $apiVersion = 'ZipCodeLookup';
/**
* @var array - list of all addresses added so far
*/
protected $addresses = array();
/**
* Perform the API call
* @return string
*/
public function lookup() {
return $this->doRequest();
}
/**
* returns array of all addresses added so far
* @return array
*/
public function getPostFields() {
return $this->addresses;
}
/**
* Add Address to the stack
* @param USPSAddress object $data
* @param string $id the address unique id
* @return void
*/
public function addAddress(USPSAddress $data, $id=null) {
$packageId = $id !== null ? $id : ((count($this->addresses)+1));
$this->addresses['Address'][] = array_merge(array('@attributes' => array('ID' => $packageId)), $data->getAddressInfo());
}
}