Skip to content

Commit

Permalink
Merge pull request #6 from panxl6/2024-07
Browse files Browse the repository at this point in the history
feat: supporting 2024-07 version.
  • Loading branch information
panxl6 authored Jul 29, 2024
2 parents abcaadc + 9ed849b commit 27fa8d9
Show file tree
Hide file tree
Showing 106 changed files with 6,347 additions and 425 deletions.
174 changes: 73 additions & 101 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
],
"require": {
"php": ">=8.1.0",
"php": ">=8.0.0",
"guzzlehttp/guzzle": "6.5.8",
"phpseclib/phpseclib": "3.0.37",
"symfony/serializer": "^3.4",
Expand Down
342 changes: 174 additions & 168 deletions composer.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions src/API/Courier.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,42 @@ public function __construct(Http $httpClient)
/**
* @throws AfterShipError
*/
public function getUserCouriers(
public function getAllCouriers(
array $headers = []
): \Tracking\API\Courier\GetUserCouriersResponse {
): \Tracking\API\Courier\GetAllCouriersResponse {
$options = [
'headers' => $headers,
];
$resp = $this->httpClient->request('GET', sprintf("/tracking/2024-04/couriers"), $options);
$result = $this->parseSingleResource($resp, '', \Tracking\API\Courier\GetUserCouriersResponse::class);
$resp = $this->httpClient->request('GET', sprintf("/tracking/2024-07/couriers/all"), $options);
$result = $this->parseSingleResource($resp, '', \Tracking\API\Courier\GetAllCouriersResponse::class);
return $result;
}
/**
* @throws AfterShipError
*/
public function getAllCouriers(
public function getUserCouriers(
array $headers = []
): \Tracking\API\Courier\GetAllCouriersResponse {
): \Tracking\API\Courier\GetUserCouriersResponse {
$options = [
'headers' => $headers,
];
$resp = $this->httpClient->request('GET', sprintf("/tracking/2024-04/couriers/all"), $options);
$result = $this->parseSingleResource($resp, '', \Tracking\API\Courier\GetAllCouriersResponse::class);
$resp = $this->httpClient->request('GET', sprintf("/tracking/2024-07/couriers"), $options);
$result = $this->parseSingleResource($resp, '', \Tracking\API\Courier\GetUserCouriersResponse::class);
return $result;
}
/**
* @throws AfterShipError
*/
public function detectCourier(
\Tracking\API\Courier\TrackingDetectCourierRequest $body,
\Tracking\API\Courier\DetectCourierRequest $body,
array $headers = []
): \Tracking\API\Courier\DetectCourierResponse {
$options = [
'headers' => $headers,

'json' => ['tracking' => $body->toRequestArray()],
'json' => $body->toRequestArray(),
];
$resp = $this->httpClient->request('POST', sprintf("/tracking/2024-04/couriers/detect"), $options);
$resp = $this->httpClient->request('POST', sprintf("/tracking/2024-07/couriers/detect"), $options);
$result = $this->parseSingleResource($resp, '', \Tracking\API\Courier\DetectCourierResponse::class);
return $result;
}
Expand Down
48 changes: 46 additions & 2 deletions src/API/Courier/DetectCourierRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,51 @@
class DetectCourierRequest extends Base
{
/**
* @var TrackingDetectCourierRequest Detect courier request
* @var string Tracking number of a shipment.
*/
public $tracking;
public $tracking_number;
/**
* @var array[] If not specified, Aftership will automatically detect the courier based on the tracking number format and your . Use array to input a list of couriers for auto detect. Cannot be used with slug_group at the same time.
*/
public $slug;
/**
* @var string The postal code of receiver's address. Required by some couriers. Refer to for more details
*/
public $tracking_postal_code;
/**
* @var string Shipping date in `YYYYMMDD` format. Required by some couriers. Refer to for more details
*/
public $tracking_ship_date;
/**
* @var string Account number of the shipper for a specific courier. Required by some couriers. Refer to for more details
*/
public $tracking_account_number;
/**
* @var string Key of the shipment for a specific courier. Required by some couriers. Refer to for more details
*/
public $tracking_key;
/**
* @var string Origin Country/Region of the shipment for a specific courier. Required by some couriers.
*/
public $tracking_origin_country;
/**
* @var string Destination Country/Region of the shipment for a specific courier. Required by some couriers. Refer to for more details
*/
public $tracking_destination_country;
/**
* @var string State of the destination shipping address of the shipment. Required by some couriers.
*/
public $tracking_state;
/**
* @var string|null|\Tracking\Model\SlugGroupV1 Slug group is a group of slugs which belong to same courier. For example, when you inpit "fedex-group" as slug_group, AfterShip will detect the tracking with "fedex-uk", "fedex-fims", and other slugs which belong to "fedex". It cannot be used with slug at the same time. (
*/
public $slug_group;
/**
* @var string Enter .
*/
public $origin_country_iso3;
/**
* @var string Enter .
*/
public $destination_country_iso3;
}
2 changes: 1 addition & 1 deletion src/API/EstimatedDeliveryDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function predictBatch(

'json' => $body->toRequestArray(),
];
$resp = $this->httpClient->request('POST', sprintf("/tracking/2024-04/estimated-delivery-date/predict-batch"), $options);
$resp = $this->httpClient->request('POST', sprintf("/tracking/2024-07/estimated-delivery-date/predict-batch"), $options);
$result = $this->parseSingleResource($resp, '', \Tracking\API\EstimatedDeliveryDate\PredictBatchResponse::class);
return $result;
}
Expand Down
Loading

0 comments on commit 27fa8d9

Please sign in to comment.