HEX
Server: Apache/2.4.41 (Amazon) OpenSSL/1.0.2k-fips PHP/5.6.40
System: Linux ip-172-31-40-18 4.14.146-93.123.amzn1.x86_64 #1 SMP Tue Sep 24 00:45:23 UTC 2019 x86_64
User: apache (48)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: /var/www/html/pmw24/pmw_live_testing/app/vendor/vinceg/usps-php-api/src/CityStateLookup.php
<?php

namespace USPS;

/*
 * USPS City/State lookup
 * used to find a city/state by a zipcode lookup
 * @since 1.0
 * @author Vincent Gabriel
 */
class CityStateLookup extends USPSBase
{
    /**
     * @var string - the api version used for this type of call
     */
    protected $apiVersion = 'CityStateLookup';
    /**
     * @var array - list of all addresses added so far
     */
    protected $addresses = [];

    /**
     * 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 zip zip code to the stack.
     *
     * @param string $zip5 - zip code 5 integers
     * @param string $zip4 - optional 4 integers zip code
     * @param string $id   the address unique id
     *
     * @return void
     */
    public function addZipCode($zip5, $zip4 = '', $id = null)
    {
        $packageId = $id !== null ? $id : ((count($this->addresses) + 1));
        $zipCodes = ['Zip5' => $zip5];
        if ($zip4) {
            $zipCodes['Zip4'] = $zip4;
        }
        $this->addresses['ZipCode'][] = array_merge(['@attributes' => ['ID' => $packageId]], $zipCodes);
    }
}