Skip to content

Commit

Permalink
move to composer package
Browse files Browse the repository at this point in the history
  • Loading branch information
reddingwebpro committed Sep 20, 2023
1 parent 951a7a1 commit 090679b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# USPS Address Validator v2 Changelog

## New Features

* Updated to use the very latest API v3 from USPS

## Breaking changes

* The minimum required PHP version changed from PHP 5 to PHP 7.4

## Thanks
To contributors, be it with PRs, reporting issues or supporting otherwise.

21 changes: 21 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "reddingwebdev/usps_zip_code",
"description": "This class will take a normalized USA address and return the 5 digit zip code",
"minimum-stability": "stable",
"license": "GPL-3.0-or-later",
"authors": [
{
"name": "Jason Olson"
}
],
"require": {
"php": ">=7.4",
"ext-curl": "*"

},
"autoload": {
"psr-4": {
"RedWebDev\\usps_address_validation\\": "src"
}
}
}
5 changes: 2 additions & 3 deletions example.php → demo/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
// example code shown below:

require('USPS.php');
use RedWebDev\USPS;

$uspsZip = new USPS('Consumer Key','Consumer Secret'); // insert your api key from USPS
$uspsZip = new RedWebDev\uspszipcode('Consumer Key','Consumer Secret'); // insert your api key from USPS

$address = '1600 Amphitheatre Parkway'; // address line is required
$city = 'Mountain View';
$state = 'CA'; //looking for the two character state

$zipcode = $uspsZip->getNormalized($address, $city, $state);
$zipcode = $uspsZip->getZipCode($address, $city, $state);

echo "Zip Code: " . $zipcode;
4 changes: 2 additions & 2 deletions USPS.php → src/usps_zipcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace RedWebDev;

class USPS
class uspszipcode
{

private string $key;
Expand Down Expand Up @@ -53,7 +53,7 @@ private function getOauthV3Token(): string
return $data['access_token'];
}

public function getNormalized($address, $city, $state): ?int
public function getZipCode($address, $city, $state): ?int
{
$token = $this->getOauthV3Token();
$authorization = "Authorization: Bearer ".$token;
Expand Down

0 comments on commit 090679b

Please sign in to comment.