Get the cities from a zipCode

REST: GET /xdsl/eligibility/cities
@param zipCode [required] The zipCode of the city
@deprecated
4878
public ArrayList<OvhCity> eligibility_cities_GET(String zipCode) throws IOException {
		String qPath = "/xdsl/eligibility/cities";
		StringBuilder sb = path(qPath);
		query(sb, "zipCode", zipCode);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, t2);
	}
382906
protected function fetchZipCodeAddress()
    {
        $address = $this->parsedXML['consultaCEPResponse']['return'];
        $zipcode = preg_replace('/^([0-9]{5})([0-9]{3})$/', '${1}-${2}', $address['cep']);
        $complement = $this->getComplement($address);

        return [
            'zipcode' => $zipcode,
            'street' => $address['end'],
            'complement' => $complement,
            'district' => $address['bairro'],
            'city' => $address['cidade'],
            'uf' => $address['uf'],
        ];
    }
987903
public static function validate($zipcode, $country = null)
    {
        $zipcode = trim($zipcode);
        $country = trim($country);
        if (empty($zipcode) || empty($country)) {
            return false;
        }

        $country = strtoupper($country);
        if (!isset(self::$patterns[$country])) {
            throw new \InvalidArgumentException("ERROR: The zipcode validator for $country does not exists yet: feel free to add it.");
        }

        return (bool) preg_match('/^('.self::$patterns[$country].')$/', $zipcode);
    }
78164
public static Optional<String[]> lookup(long code) {
        String[] desc = DESCRIPTIONS.get(code & 0xFFFF0000);

        return Optional.ofNullable(desc);
    }
147229
@java.lang.Deprecated
  public java.util.Map<java.lang.String, com.google.cloud.redis.v1.ZoneMetadata>
      getAvailableZones() {
    return getAvailableZonesMap();
  }
1257752
def rental_report(self, address, zipcode, format_type="json"):
        

        # only json is supported by rental report.
        query_params = {
            "format": format_type,
            "address": address,
            "zipcode": zipcode
        }

        return self._api_client.fetch_synchronous("property/rental_report", query_params)
974630
public ArrayList<OvhStreet> eligibility_streets_GET(String inseeCode, String partialName) throws IOException {
		String qPath = "/xdsl/eligibility/streets";
		StringBuilder sb = path(qPath);
		query(sb, "inseeCode", inseeCode);
		query(sb, "partialName", partialName);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, t6);
	}
1132675
public function getCoordinates(
        ?string $street = null,
        ?string $streetNumber = null,
        ?string $city = null,
        ?string $zip = null,
        ?string $country = null
    ): Coordinates {
        $items = [];
        $variables = [$street, $streetNumber, $city, $zip, $country];
        foreach ($variables as $variable) {
            if (empty($variable)) {
                continue;
            }

            $items[] = $variable;
        }

        $results = $this->doCall(array(
            'address' => implode(' ', $items),
            'sensor' => 'false'
        ));

        if (!array_key_exists(0, $results)) {
            throw Exception::noCoordinatesFoundforAddress($variables);
        }

        return new Coordinates(
            $results[0]->geometry->location->lat,
            $results[0]->geometry->location->lng
        );
    }
833308
@Bean
	@ConditionalOnMissingBean
	@Deprecated
	BytesEncoder<Span> spanBytesEncoder(ZipkinProperties zipkinProperties) {
		return zipkinProperties.getEncoder();
	}
628404
function parseGoogleGeocodes(response) {
  // the result has a results property that is an array
  // there may be more than one result when the address is ambiguous
  // for pragmatic reasons, only use the first result
  // if the result does not have a zip code, then assume the user
  // did not provide a valid address

  var result = response.results[0]
    , zipComponent = findAddressComponent(result.address_components, 'postal_code')
    , simple = {}
    ;

  simple.zip5 = zipComponent ? zipComponent.short_name : null;
  simple.address = result.formatted_address.replace(/,\s*USA/, '');
  simple.localAddress = getLocalAddress(result) || simple.address;
  simple.location = result.geometry.location;
  return simple;
}
482852
public function geocode( $postal_code ) {
    // Validate ZIP code.
    if ( false == static::validate_postal_code( $postal_code ) ) {
      throw new GeocodingException( 'ZIP code value is invalid: ' . $postal_code );
    }

    // Delegate geocoding to underlying provider.
    return $this->getGeocodingProvider()->geocode( $postal_code );
  }
610236
def address(self, street, city=None, state=None, zipcode=None, **kwargs):
        ''''''
        fields = {
            'street': street,
            'city': city,
            'state': state,
            'zip': zipcode,
        }

        return self._fetch('address', fields, **kwargs)
365642
function cda_line_address(addressString) {
    var addressObj = {
        "use": "primary home",
        "street_lines": [],
        "city": "",
        "state": "",
        "zip": "",
        "country": "United States" //assume U.S. for now
    };
    var addressArray = addressString.trim().split(',');
    var uppCaseAdrStr = addressString.toUpperCase();
    var foundWord, x, word, tempCityIndex, foundCityIndex, zip, stateAndZip, streetFound;
    if (addressArray.length === 1) {
        var tempArr = addressArray[0].split(' ');
        //this goes from best method to worse

        //check if you can see a number from the last index, which means that's it's likely to be a p.o. box or an address

        // 1. Obtain address from zip code.
        /*
         Also need to consider time complexity here, Notice that it maybe doing
        a retrieval from a rather big object. I think it's okay since documentation
        says that it's better than hashing, which is constant time lookup. May need
        beter method later */
        var addressLine;
        var fiveDigitZip = tempArr[tempArr.length - 1].substring(0, 5);
        if (fiveDigitZip in zipDict && !isNaN(fiveDigitZip)) {
            var foundCity = zipDict[fiveDigitZip][0].trim();
            var foundCityArr = foundCity.split(' ');
            var foundCityMatch = '';
            foundCityIndex = -1;
            for (x = 0; x < foundCityArr.length; x++) {
                tempCityIndex = addressString.toUpperCase().indexOf(foundCityArr[x]);
                if (tempCityIndex > 0) {
                    if (foundCityIndex === -1) {
                        foundCityIndex = tempCityIndex;
                    }
                    foundCityMatch += foundCityArr[x] + ' ';
                }
            }
            foundCityMatch = foundCityMatch.substring(0, foundCityMatch.length - 1);
            if (foundCityIndex >= 1) {
                addressLine = addressString.substring(0, foundCityIndex - 1).trim();
                addressObj.street_lines.push(addressLine);
                /*TODO: foundCIty, which is the city name obtained from looking up the
                zip code table, needs to do something like an longest common substring match
                in case there isn't a 1 to 1 match between the city names of the raw string
                and foundCity. For now I'm just going to take the field in the dictionary. However,
                the more correct approach would be running Ukkonen's algorithm for suffix trees
                to find the longest common substring between the raw string and the value from
                lookup. If the lcs algorithm is implemented correctly it should give O(m+n) time. */
                addressObj.city = foundCityMatch.trim();
                addressObj.zip = tempArr[tempArr.length - 1].trim();
                addressObj.state = tempArr[tempArr.length - 2].trim();
                return addressObj;
            }
        }
        //2. try out commonly found suffixes
        var cityBegIndex, cityEndIndex, zipIndex;
        for (x = tempArr.length - 1; x > 0; x--) {
            word = tempArr[x].toUpperCase();
            if (word in streetSuffix) {
                streetFound = true;
                foundWord = tempArr[x];
                cityBegIndex = addressString.indexOf(foundWord);
                cityEndIndex = cityBegIndex + foundWord.length;
                addressLine = addressString.substring(0, cityEndIndex).trim();
                addressObj.street_lines.push(addressLine);

                //These might not always be the last and second to last, what if there's just state code? need to make changes forthat later.
                addressObj.zip = tempArr[tempArr.length - 1].trim();
                addressObj.state = tempArr[tempArr.length - 2].trim();
                //get city name
                zipIndex = addressString.indexOf(addressObj.zip);
                var stateIndex = addressString.indexOf(addressObj.state);

                addressObj.city = addressString.substring(cityEndIndex, stateIndex).trim();
                return addressObj;
            }
        }

        for (x = tempArr.length - 1; x > 0; x--) {
            word = tempArr[x].toUpperCase();
            if (word in unitDesignators) {
                streetFound = true;
                foundWord = tempArr[x];
                cityBegIndex = addressString.indexOf(foundWord);
                cityEndIndex = cityBegIndex + foundWord.length;
                addressLine = addressString.substring(cityBegIndex, cityEndIndex).trim();
                addressObj.street_lines.push(addressLine);

                //These might not always be the last and second to last
                addressObj.zip = tempArr[tempArr.length - 1].trim();
                addressObj.state = tempArr[tempArr.length - 2].trim();
                //get city name
                zipIndex = addressString.indexOf(addressObj.zip);

                addressObj.city = addressString.substring(cityEndIndex, zipIndex).trim();
                return addressObj;
            }
        }

        return null;
    }

    /*case when there is only one comma, right after the city , ie. 1111 Address Dr Hoosville, VA 11111*/
    else if (addressArray.length === 2) {
        var streetAndCity = addressArray[0].trim();
        stateAndZip = addressArray[1].trim();

        var test = false;
        streetFound = false;
        var street;
        var city;

        //try to figure out street and city, going for fastest computation to slowest

        var streetArray = streetAndCity.split(" ");

        /*the whole point of this code is to find the point where we need to split the
        string */

        //find longest worded us city

        //this is the default breaking point
        var breakPoint = streetAndCity.lastIndexOf(' ');

        //check if you can see a number from the last index, which means that's it's likely to be a p.o. box or an address

        //First, check if the beginning token is a word if it's a word, then it's likely to be a PO box
        if (isNaN(streetArray[0])) {
            for (x = streetArray.length; x > 0; x--) {
                /* NOTE: the > 0 IS NOT A MISTAKE! Address lines usually start with a number so we don't want the loop
                to go all the way through */
                if (!isNaN(streetArray[x])) { //so it is a number
                    streetFound = true;
                    foundWord = streetArray[x];
                    breakPoint = streetAndCity.indexOf(foundWord) + foundWord.length;
                    //console.log(streetAndCity.substring(0, breakPoint));
                }

            }
        }
        //means that we do start with a street number, and need to look for a common suffix
        else {

            /*The stop index is where looping should stop in an address. The reason why
            5 is used is because the longest worded city is 5 words long. */
            //loop only to the 2nd to last word, i.e. 7777 blah blah STOP city, ST 99999
            if (!streetFound) {
                for (x = 0; x < streetArray.length - 1; x++) {
                    word = streetArray[x].toUpperCase();
                    if (word in streetSuffix) {
                        streetFound = true;
                        foundWord = streetArray[x];
                        breakPoint = streetAndCity.indexOf(foundWord) + foundWord.length;
                        break;
                    }
                }
            }

            //go through the string and look up usps C2 suffix address, unit designators
            if (!streetFound) {

                for (x = 0; x > streetArray.length; x++) {
                    word = streetArray[x].toUpperCase();
                    if (word in unitDesignators) {
                        streetFound = true;
                        foundWord = streetArray[x];
                        breakPoint = streetAndCity.indexOf(foundWord) + foundWord.length;
                        test = true;
                        break;
                    }
                }
            }
            //last major option, lookup the 5 letter zip code, then do a match on the address string
            //with the obtained value.
            if (!streetFound) {
                var stateAndZipArr = stateAndZip.split(' ');
                zip = stateAndZipArr[1].trim().substring(0, 5);
                if (zip in zipDict && !isNaN(zip)) {
                    var cityRetrieved = zipDict[zip][0].trim();
                    var cityArr = cityRetrieved.split(" ");
                    var capAdrString = addressString.toUpperCase();
                    var possibleBreakPoint = -1;
                    for (x = 0; x < cityArr.length; x++) {
                        tempCityIndex = addressString.toUpperCase().indexOf(cityArr[x]);
                        if (tempCityIndex > 0) {
                            if (foundCityIndex === -1) {
                                foundCityIndex = tempCityIndex;
                            }

                        }
                    }
                }

            }

        }

        // this step is taken for all procedures, the above code is to find the right point to split the stirng(breakpoint)
        street = streetAndCity.substring(0, breakPoint);
        city = streetAndCity.substring(breakPoint + 1, streetAndCity.length);
        //state and zip are consistent
        stateAndZip = stateAndZip.split(' ');
        var state = stateAndZip[0];
        zip = stateAndZip[1];
        addressObj.street_lines.push(street);
        addressObj.city = city;
        addressObj.state = state;
        addressObj.zip = zip;

        return addressObj;
    }
    /*ie. 1111 Address Dr, Hoosville, VA 11111*/
    else if (addressArray.length === 3) {
        addressObj.street_lines[0] = addressArray[0].trim();
        addressObj.city = addressArray[1].trim();
        stateAndZip = addressArray[2].trim().split(' ');
        addressObj.state = stateAndZip[0];
        addressObj.zip = stateAndZip[1];
        return addressObj;
    }
    return null;
}
161790
public ShippingAddresses getAccountShippingAddresses(final String accountCode) {
        return doGET(Accounts.ACCOUNTS_RESOURCE + "/" + accountCode + ShippingAddresses.SHIPPING_ADDRESSES_RESOURCE,
                ShippingAddresses.class, new QueryParams());
    }
460685
public AddOns getAddOns(final String planCode) {
        return doGET(Plan.PLANS_RESOURCE +
                "/" +
                planCode +
                AddOn.ADDONS_RESOURCE,
                AddOns.class,
                new QueryParams());
    }
468644
def cities(ids, options = {})
      if ids.length > SeveralCitiesClassMethods::LOCATIONS_LIMIT
        raise LocationsLimitExceeded
      end

      url = 'http://api.openweathermap.org/data/2.5/group'
      ids = encode_array ids
      new(options.merge(id: ids)).retrieve url
    end
180631
private function getZoneMemberByCode($code)
    {
        $zoneMember = $this->zoneMemberRepository->findOneBy(['code' => $code]);
        Assert::notNull(
            $zoneMember,
            sprintf('Zone member with code %s does not exist.', $code)
        );

        return $zoneMember;
    }