Skip to content

Commit 27fa8d9

Browse files
authored
Merge pull request #6 from panxl6/2024-07
feat: supporting 2024-07 version.
2 parents abcaadc + 9ed849b commit 27fa8d9

File tree

106 files changed

+6347
-425
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+6347
-425
lines changed

README.md

Lines changed: 73 additions & 101 deletions
Large diffs are not rendered by default.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
}
2424
],
2525
"require": {
26-
"php": ">=8.1.0",
26+
"php": ">=8.0.0",
2727
"guzzlehttp/guzzle": "6.5.8",
2828
"phpseclib/phpseclib": "3.0.37",
2929
"symfony/serializer": "^3.4",

composer.lock

Lines changed: 174 additions & 168 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/API/Courier.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,42 +22,42 @@ public function __construct(Http $httpClient)
2222
/**
2323
* @throws AfterShipError
2424
*/
25-
public function getUserCouriers(
25+
public function getAllCouriers(
2626
array $headers = []
27-
): \Tracking\API\Courier\GetUserCouriersResponse {
27+
): \Tracking\API\Courier\GetAllCouriersResponse {
2828
$options = [
2929
'headers' => $headers,
3030
];
31-
$resp = $this->httpClient->request('GET', sprintf("/tracking/2024-04/couriers"), $options);
32-
$result = $this->parseSingleResource($resp, '', \Tracking\API\Courier\GetUserCouriersResponse::class);
31+
$resp = $this->httpClient->request('GET', sprintf("/tracking/2024-07/couriers/all"), $options);
32+
$result = $this->parseSingleResource($resp, '', \Tracking\API\Courier\GetAllCouriersResponse::class);
3333
return $result;
3434
}
3535
/**
3636
* @throws AfterShipError
3737
*/
38-
public function getAllCouriers(
38+
public function getUserCouriers(
3939
array $headers = []
40-
): \Tracking\API\Courier\GetAllCouriersResponse {
40+
): \Tracking\API\Courier\GetUserCouriersResponse {
4141
$options = [
4242
'headers' => $headers,
4343
];
44-
$resp = $this->httpClient->request('GET', sprintf("/tracking/2024-04/couriers/all"), $options);
45-
$result = $this->parseSingleResource($resp, '', \Tracking\API\Courier\GetAllCouriersResponse::class);
44+
$resp = $this->httpClient->request('GET', sprintf("/tracking/2024-07/couriers"), $options);
45+
$result = $this->parseSingleResource($resp, '', \Tracking\API\Courier\GetUserCouriersResponse::class);
4646
return $result;
4747
}
4848
/**
4949
* @throws AfterShipError
5050
*/
5151
public function detectCourier(
52-
\Tracking\API\Courier\TrackingDetectCourierRequest $body,
52+
\Tracking\API\Courier\DetectCourierRequest $body,
5353
array $headers = []
5454
): \Tracking\API\Courier\DetectCourierResponse {
5555
$options = [
5656
'headers' => $headers,
5757

58-
'json' => ['tracking' => $body->toRequestArray()],
58+
'json' => $body->toRequestArray(),
5959
];
60-
$resp = $this->httpClient->request('POST', sprintf("/tracking/2024-04/couriers/detect"), $options);
60+
$resp = $this->httpClient->request('POST', sprintf("/tracking/2024-07/couriers/detect"), $options);
6161
$result = $this->parseSingleResource($resp, '', \Tracking\API\Courier\DetectCourierResponse::class);
6262
return $result;
6363
}

src/API/Courier/DetectCourierRequest.php

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,51 @@
1010
class DetectCourierRequest extends Base
1111
{
1212
/**
13-
* @var TrackingDetectCourierRequest Detect courier request
13+
* @var string Tracking number of a shipment.
1414
*/
15-
public $tracking;
15+
public $tracking_number;
16+
/**
17+
* @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.
18+
*/
19+
public $slug;
20+
/**
21+
* @var string The postal code of receiver's address. Required by some couriers. Refer to for more details
22+
*/
23+
public $tracking_postal_code;
24+
/**
25+
* @var string Shipping date in `YYYYMMDD` format. Required by some couriers. Refer to for more details
26+
*/
27+
public $tracking_ship_date;
28+
/**
29+
* @var string Account number of the shipper for a specific courier. Required by some couriers. Refer to for more details
30+
*/
31+
public $tracking_account_number;
32+
/**
33+
* @var string Key of the shipment for a specific courier. Required by some couriers. Refer to for more details
34+
*/
35+
public $tracking_key;
36+
/**
37+
* @var string Origin Country/Region of the shipment for a specific courier. Required by some couriers.
38+
*/
39+
public $tracking_origin_country;
40+
/**
41+
* @var string Destination Country/Region of the shipment for a specific courier. Required by some couriers. Refer to for more details
42+
*/
43+
public $tracking_destination_country;
44+
/**
45+
* @var string State of the destination shipping address of the shipment. Required by some couriers.
46+
*/
47+
public $tracking_state;
48+
/**
49+
* @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. (
50+
*/
51+
public $slug_group;
52+
/**
53+
* @var string Enter .
54+
*/
55+
public $origin_country_iso3;
56+
/**
57+
* @var string Enter .
58+
*/
59+
public $destination_country_iso3;
1660
}

src/API/EstimatedDeliveryDate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function predictBatch(
3131

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

0 commit comments

Comments
 (0)