Permalink
Browse files

Update URL and functions according to new API docs

In addition to the changes for international postage, Auspost have
also changed the API URL, as described in this document:

http://auspost.com.au/pdfs/pac-api-update-2016.pdf

The testing URL has been removed at the same time.
  • Loading branch information...
chnorton committed Jun 20, 2016
1 parent aa21d85 commit d0c1f7a58a50c715f795eea1d067d5305b16f558
Showing with 22 additions and 28 deletions.
  1. +5 −11 src/Auspost/Postage/PostageClient.php
  2. +17 −17 src/Auspost/Postage/service.json
@@ -34,6 +34,9 @@
*/
class PostageClient extends Client
{
const API_URL = 'https://digitalapi.auspost.com.au';
public static function factory($config = array())
{
if (isset($config['developer_mode']) && is_bool($config['developer_mode'])) {
@@ -42,20 +45,11 @@ public static function factory($config = array())
$developerMode = false;
}
$baseUrl = array(
'https://auspost.com.au',
'https://test.npe.auspost.com.au'
);
// Ignore unnecessary user-specified configuration values
if ($developerMode) {
unset($config['auth_key']);
}
unset($config['base_url']);
$default = array(
'developer_mode' => $developerMode,
'base_url' => $baseUrl[$developerMode],
'base_url' => self::API_URL,
'auth_key' => '28744ed5982391881611cca6cf5c2409'
);
@@ -67,7 +61,7 @@ public static function factory($config = array())
$config = Collection::fromConfig($config, $default, $required);
$client = new self($config->get('base_url'), $config);
$client = new self(self::API_URL, $config);
$client->getConfig()->setPath('request.options/headers/Accept', 'application/json');
$client->getConfig()->setPath('request.options/headers/Auth-Key', $config->get('auth_key'));
@@ -2,39 +2,39 @@
"operations": {
"ListCountries": {
"httpMethod": "GET",
"uri": "api/postage/country"
"uri": "postage/country"
},
"ListDomesticLetterSizes": {
"httpMethod": "GET",
"uri": "api/postage/letter/domestic/size"
"uri": "postage/letter/domestic/size"
},
"ListDomesticLetterThicknesses": {
"httpMethod": "GET",
"uri": "api/postage/letter/domestic/thickness"
"uri": "postage/letter/domestic/thickness"
},
"ListDomesticLetterWeights": {
"httpMethod": "GET",
"uri": "api/postage/letter/domestic/weight"
"uri": "postage/letter/domestic/weight"
},
"ListDomesticParcelSizes": {
"httpMethod": "GET",
"uri": "api/postage/parcel/domestic/size"
"uri": "postage/parcel/domestic/size"
},
"ListDomesticParcelWeights": {
"httpMethod": "GET",
"uri": "api/postage/parcel/domestic/weight"
"uri": "postage/parcel/domestic/weight"
},
"ListInternationalLetterWeights": {
"httpMethod": "GET",
"uri": "api/postage/letter/international/weight"
"uri": "postage/letter/international/weight"
},
"ListInternationalParcelWeights": {
"httpMethod": "GET",
"uri": "api/postage/parcel/international/weight"
"uri": "postage/parcel/international/weight"
},
"ListDomesticLetterServices": {
"httpMethod": "GET",
"uri": "api/postage/letter/domestic/service",
"uri": "postage/letter/domestic/service",
"parameters": {
"length": {
"required": true,
@@ -60,7 +60,7 @@
},
"ListDomesticParcelServices": {
"httpMethod": "GET",
"uri": "api/postage/parcel/domestic/service",
"uri": "postage/parcel/domestic/service",
"parameters": {
"from_postcode": {
"required": true,
@@ -96,7 +96,7 @@
},
"ListInternationalLetterServices": {
"httpMethod": "GET",
"uri": "api/postage/letter/international/service",
"uri": "postage/letter/international/service",
"parameters": {
"country_code": {
"required": true,
@@ -112,7 +112,7 @@
},
"ListInternationalParcelServices": {
"httpMethod": "GET",
"uri": "api/postage/parcel/international/service",
"uri": "postage/parcel/international/service",
"parameters": {
"country_code": {
"required": true,
@@ -128,7 +128,7 @@
},
"SearchPostcode": {
"httpMethod": "GET",
"uri": "api/postcode/search",
"uri": "postcode/search",
"parameters": {
"q": {
"required": true,
@@ -150,7 +150,7 @@
},
"CalculateDomesticLetterPostage": {
"httpMethod": "GET",
"uri": "api/postage/letter/domestic/calculate",
"uri": "postage/letter/domestic/calculate",
"parameters": {
"service_code": {
"required": true,
@@ -181,7 +181,7 @@
},
"CalculateDomesticParcelPostage": {
"httpMethod": "GET",
"uri": "api/postage/parcel/domestic/calculate",
"uri": "postage/parcel/domestic/calculate",
"parameters": {
"from_postcode": {
"required": true,
@@ -237,7 +237,7 @@
},
"CalculateInternationalLetterPostage": {
"httpMethod": "GET",
"uri": "api/postage/letter/international/calculate",
"uri": "postage/letter/international/calculate",
"parameters": {
"country_code": {
"required": true,
@@ -258,7 +258,7 @@
},
"CalculateInternationalParcelPostage": {
"httpMethod": "GET",
"uri": "api/postage/parcel/international/calculate",
"uri": "postage/parcel/international/calculate",
"parameters": {
"country_code": {
"required": true,

0 comments on commit d0c1f7a

Please sign in to comment.