Skip to content

Commit 7d832dc

Browse files
committed
Update DEV or PROD modes
1 parent 7688e8d commit 7d832dc

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ $address = [
3939
];
4040

4141
echo '<pre>';
42-
print_r(AddressValidation::setAddress($address)->validate($client_id, $client_secret));
42+
print_r(AddressValidation::setAddress($address)->validate($client_id, $client_secret)); // For Dev Api
43+
print_r(AddressValidation::setAddress($address)->setMode('PROD')->validate($client_id, $client_secret)); // For Prod Api
4344
echo '</pre>';
4445
die();
4546

demo/validate-address.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
require_once('./vendor/autoload.php');
66

7-
$client_id = "xxxxxxxxxxxxxx";
8-
$client_secret = "xxxxxxxxxxxxxxxx";
7+
$client_id = "xxxxxxxxxxxxxxxx"; // UPS Client ID
8+
$client_secret = "xxxxxxxxxxxxxxx"; // UPS Client Secret
99

10+
// Address to be validated
1011
$address = [
1112
"AddressLine" => [
1213
"785 GODDARD CT"
@@ -18,6 +19,7 @@
1819
];
1920

2021
echo '<pre>';
21-
print_r(AddressValidation::setAddress($address)->validate($client_id, $client_secret));
22+
print_r(AddressValidation::setAddress($address)->validate($client_id, $client_secret)); // For Dev Api
23+
print_r(AddressValidation::setAddress($address)->setMode('PROD')->validate($client_id, $client_secret)); // For Prod Api
2224
echo '</pre>';
23-
die();
25+
die();

src/AddressValidation.php

+10
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,14 @@ private function _getAddresses(Array $candidates)
114114

115115
return $addresses;
116116
}
117+
118+
/**
119+
* Set Mode
120+
* @param string DEV|PROD
121+
*/
122+
public function setMode(String $mode)
123+
{
124+
parent::setMode($mode);
125+
return $this;
126+
}
117127
}

src/Auth.php

+2
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ public function setMode(String $mode)
7171
{
7272
if ($mode === 'PROD') {
7373
$this->_mode = $mode;
74+
return $mode;
7475
}
7576

7677
$this->_mode = 'DEV';
78+
return $mode;
7779
}
7880

7981
/**

0 commit comments

Comments
 (0)