forked from VinceG/USPS-php-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
USPSAddressVerify.php
47 lines (46 loc) · 1.14 KB
/
USPSAddressVerify.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
47
<?php
/**
* Load required classes
*/
require_once('USPSBase.php');
require_once('USPSAddress.php');
/**
* USPS Address Verify Class
* used to verify an address is valid
* @since 1.0
* @author Vincent Gabriel
*/
class USPSAddressVerify extends USPSBase {
/**
* @var string - the api version used for this type of call
*/
protected $apiVersion = 'Verify';
/**
* @var array - list of all addresses added so far
*/
protected $addresses = array();
/**
* Perform the API call to verify the address
* @return string
*/
public function verify() {
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());
}
}