4 * Verify valid address with USPS Web API
5 * originally under MIT License
6 * https://packagist.org/packages/binarydata/usps-php-api
9 * @link https://www.open-emr.org
10 * @author Vincent Gabriel
11 * @author stephen waite <stephen.waite@cmsvt.com>
12 * @copyright Copyright (c) 2012 Vincent Gabriel
13 * @copyright Copyright (c) 2022 stephen waite <stephen.waite@cmsvt.com>
14 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
17 namespace OpenEMR\USPS
;
19 use OpenEMR\USPS\USPSBase
;
20 use OpenEMR\USPS\USPSAddress
;
23 * USPS Address Verify Class
24 * used to verify an address is valid
26 * @author Vincent Gabriel
28 class USPSAddressVerify
extends USPSBase
31 * @var string - the api version used for this type of call
33 protected $apiVersion = 'Verify';
35 * @var array - list of all addresses added so far
37 protected $addresses = array();
39 * Perform the API call to verify the address
42 public function verify()
44 return $this->doRequest();
47 * returns array of all addresses added so far
50 public function getPostFields()
52 return $this->addresses
;
55 * Add Address to the stack
56 * @param USPSAddress object $data
57 * @param string $id the address unique id
60 public function addAddress(USPSAddress
$data, $id = null)
62 $packageId = $id !== null ?
$id : ((count($this->addresses
) +
1));
63 $this->addresses
['Address'][] = array_merge(array('@attributes' => array('ID' => $packageId)), $data->getAddressInfo());