Skip to content

Commit 9daf0f3

Browse files
authored
Merge pull request #17 from 1415003719/2025-04
support 2025-04 version
2 parents 0ccc240 + 0f0d001 commit 9daf0f3

File tree

157 files changed

+1105
-410
lines changed

Some content is hidden

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

157 files changed

+1105
-410
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v3
1616
- name: Setup Python # Set Python version
17-
uses: actions/setup-python@v4
17+
uses: actions/setup-python@v3
1818
with:
1919
python-version: 3.11
2020

@@ -37,7 +37,7 @@ jobs:
3737
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
3838

3939
- name: Upload artifact
40-
uses: actions/upload-artifact@v4
40+
uses: actions/upload-artifact@v3
4141
with:
4242
name: ${{ steps.get_version.outputs.VERSION }}
4343
path: dist

README.md

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ If you need support using AfterShip products, please contact [email protected]
2222
- [Endpoints](#endpoints)
2323
- [/trackings](#trackings)
2424
- [/couriers](#couriers)
25+
- [/courier-connections](#courier-connections)
2526
- [/estimated-delivery-date](#estimated-delivery-date)
2627
- [Help](#help)
2728
- [License](#license)
@@ -41,6 +42,7 @@ Each SDK version is designed to work with a specific API version. Please refer t
4142

4243
| SDK Version | Supported API Version | Branch |
4344
| ----------- | --------------------- | ------------------------------------------------------------- |
45+
| 6.x.x | 2025-04 | https://github.com/AfterShip/tracking-sdk-python/tree/2025-04 |
4446
| 5.x.x | 2025-01 | https://github.com/AfterShip/tracking-sdk-python/tree/2025-01 |
4547
| 4.x.x | 2024-10 | https://github.com/AfterShip/tracking-sdk-python/tree/2024-10 |
4648
| 3.x.x | 2024-07 | https://github.com/AfterShip/tracking-sdk-python/tree/2024-07 |
@@ -96,7 +98,7 @@ except exceptions.RateLimitExceedError:
9698

9799
## Rate Limiter
98100

99-
See the [Rate Limit](https://www.aftership.com/docs/tracking/2025-01/quickstart/api-quick-start) to understand the AfterShip rate limit policy.
101+
See the [Rate Limit](https://www.aftership.com/docs/tracking/2025-04/quickstart/api-quick-start) to understand the AfterShip rate limit policy.
100102

101103
## Error Handling
102104

@@ -145,6 +147,7 @@ The AfterShip instance has the following properties which are exactly the same a
145147

146148
- courier - Get a list of our supported couriers.
147149
- tracking - Create trackings, update trackings, and get tracking results.
150+
- courier-connection - Create courier connections, update courier connections, and get courier connections results.
148151
- estimated-delivery-date - Get estimated delivery date for your order.
149152

150153

@@ -225,23 +228,57 @@ print(result)
225228
**GET** /couriers
226229

227230
```python
228-
result = sdk.courier.get_user_couriers()
231+
result = sdk.courier.get_couriers()
229232
print(result)
230233
```
231234

232-
**GET** /couriers/all
235+
**POST** /couriers/detect
233236

234237
```python
235-
result = sdk.courier.get_all_couriers()
238+
data = tracking.DetectCourierRequest()
239+
data.tracking_number = "<tracking_number>"
240+
result = sdk.courier.detect_courier(data)
236241
print(result)
237242
```
238243

239-
**POST** /couriers/detect
244+
### /courier-connections
245+
**GET** /courier-connections
240246

241247
```python
242-
data = tracking.DetectCourierRequest()
243-
data.tracking_number = "<tracking_number>"
244-
result = sdk.courier.detect_courier(data)
248+
result = sdk.courier_connection.get_courier_connections()
249+
print(result)
250+
```
251+
252+
**POST** /courier-connections
253+
254+
```python
255+
data = tracking.PostCourierConnectionsRequest()
256+
data.courier_slug = "dhl-api"
257+
data.credentials = {"api_key": "<api_key>"}
258+
result = sdk.courier_connection.post_courier_connections(data)
259+
print(result)
260+
```
261+
262+
**GET** /courier-connections/:id
263+
264+
```python
265+
result = sdk.courier_connection.get_courier_connections_by_id("<courier_connection_id>")
266+
print(result)
267+
```
268+
269+
**PATCH** /courier-connections/:id
270+
271+
```python
272+
data = PutCourierConnectionsByIdRequest()
273+
data.credentials={"api_key": "<api_key>"}
274+
result = sdk.courier_connection.put_courier_connections_by_id("<courier_connection_id>", data)
275+
print(result)
276+
```
277+
278+
**DELETE** /courier-connections/:id
279+
280+
```python
281+
result = sdk.courier_connection.delete_courier_connections_by_id("<courier_connection_id>")
245282
print(result)
246283
```
247284

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "aftership-tracking-sdk"
3-
version = "5.0.1"
3+
version = "6.0.0"
44
description = "The official AfterShip Tracking Python API library"
55
authors = ["AfterShip <[email protected]>"]
66
license = "MIT"

tracking/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
from . import exceptions
1212
from .models import *
1313

14-
__version__ = "5.0.1"
14+
__version__ = "6.0.0"

tracking/api/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66
__all__ = [
77
"CourierApi",
8+
"CourierConnectionApi",
89
"EstimatedDeliveryDateApi",
910
"TrackingApi",
1011
]
1112

1213
from .courier import CourierApi
14+
from .courier_connection import CourierConnectionApi
1315
from .estimated_delivery_date import EstimatedDeliveryDateApi
1416
from .tracking import TrackingApi

tracking/api/courier.py

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
# Do not edit the class manually.
55

66
import json
7-
from typing import Union, Annotated
7+
from typing import Union
88

9-
from pydantic import Field
109

1110
from tracking.models import (
1211
DetectCourierRequest,
1312
DetectCourierResponse,
14-
GetAllCouriersResponse,
15-
GetUserCouriersResponse,
13+
GetCouriersResponse,
1614
)
1715
from tracking.request import ApiClient, validate_params
1816

@@ -35,7 +33,7 @@ def detect_courier(
3533
a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
3634
(which will disable verification).
3735
"""
38-
url = "/tracking/2025-01/couriers/detect"
36+
url = "/tracking/2025-04/couriers/detect"
3937

4038
body = detect_courier_request
4139
if not isinstance(body, dict):
@@ -46,35 +44,26 @@ def detect_courier(
4644
return DetectCourierResponse().from_dict(result)
4745

4846
@validate_params
49-
def get_all_couriers(self, **kwargs) -> GetAllCouriersResponse:
47+
def get_couriers(self, **kwargs) -> GetCouriersResponse:
5048
"""
51-
Return a list of all couriers.
49+
Return a list of couriers.
5250
:param kwargs:
5351
request options:
5452
**headers** (dict): support custom headers.
5553
**verify** bool|str|SSLContext: SSL certificates (a.k.a CA bundle) used to
5654
verify the identity of requested hosts. Either `True` (default CA bundle),
5755
a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
5856
(which will disable verification).
57+
query params:
58+
**active**: bool. get user activated couriers
59+
**slug**: str. Unique courier code Use comma for multiple values. (Example: dhl,ups,usps)
5960
"""
60-
url = "/tracking/2025-01/couriers/all"
61+
url = "/tracking/2025-04/couriers"
62+
params_keys = {
63+
"active",
64+
"slug",
65+
}
66+
params = {key: kwargs.pop(key) for key in params_keys if key in kwargs}
6167

62-
result = self._request("GET", url=url, **kwargs)
63-
return GetAllCouriersResponse().from_dict(result)
64-
65-
@validate_params
66-
def get_user_couriers(self, **kwargs) -> GetUserCouriersResponse:
67-
"""
68-
Return a list of .
69-
:param kwargs:
70-
request options:
71-
**headers** (dict): support custom headers.
72-
**verify** bool|str|SSLContext: SSL certificates (a.k.a CA bundle) used to
73-
verify the identity of requested hosts. Either `True` (default CA bundle),
74-
a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
75-
(which will disable verification).
76-
"""
77-
url = "/tracking/2025-01/couriers"
78-
79-
result = self._request("GET", url=url, **kwargs)
80-
return GetUserCouriersResponse().from_dict(result)
68+
result = self._request("GET", url=url, params=params, **kwargs)
69+
return GetCouriersResponse().from_dict(result)

tracking/api/courier_connection.py

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# coding: utf-8
2+
#
3+
# This code was auto generated by AfterShip SDK Generator.
4+
# Do not edit the class manually.
5+
6+
import json
7+
from typing import Union, Annotated
8+
9+
from pydantic import Field
10+
11+
from tracking.models import (
12+
DeleteCourierConnectionsByIdResponse,
13+
GetCourierConnectionsResponse,
14+
GetCourierConnectionsByIdResponse,
15+
PostCourierConnectionsRequest,
16+
PostCourierConnectionsResponse,
17+
PutCourierConnectionsByIdRequest,
18+
PutCourierConnectionsByIdResponse,
19+
)
20+
from tracking.request import ApiClient, validate_params
21+
22+
23+
class CourierConnectionApi(ApiClient):
24+
"""CourierConnectionApi api implements"""
25+
26+
@validate_params
27+
def delete_courier_connections_by_id(
28+
self, courier_connection_id: Annotated[str, Field(min_length=1)], **kwargs
29+
) -> DeleteCourierConnectionsByIdResponse:
30+
"""
31+
Delete a courier connection.
32+
:param courier_connection_id: str.
33+
:param kwargs:
34+
request options:
35+
**headers** (dict): support custom headers.
36+
**verify** bool|str|SSLContext: SSL certificates (a.k.a CA bundle) used to
37+
verify the identity of requested hosts. Either `True` (default CA bundle),
38+
a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
39+
(which will disable verification).
40+
"""
41+
url = f"/tracking/2025-04/courier-connections/{courier_connection_id}"
42+
43+
result = self._request("DELETE", url=url, **kwargs)
44+
return DeleteCourierConnectionsByIdResponse().from_dict(result)
45+
46+
@validate_params
47+
def get_courier_connections(self, **kwargs) -> GetCourierConnectionsResponse:
48+
"""
49+
Get courier connection results of multiple courier connections.
50+
:param kwargs:
51+
request options:
52+
**headers** (dict): support custom headers.
53+
**verify** bool|str|SSLContext: SSL certificates (a.k.a CA bundle) used to
54+
verify the identity of requested hosts. Either `True` (default CA bundle),
55+
a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
56+
(which will disable verification).
57+
query params:
58+
**courier_slug**: str. Unique courier code.(Example: dhl-api)
59+
**cursor**: str. A string representing the cursor value for the current page of results.
60+
**limit**: str. Number of courier connections each page contain. (Default: 100, Max: 200)
61+
"""
62+
url = "/tracking/2025-04/courier-connections"
63+
params_keys = {
64+
"courier_slug",
65+
"cursor",
66+
"limit",
67+
}
68+
params = {key: kwargs.pop(key) for key in params_keys if key in kwargs}
69+
70+
result = self._request("GET", url=url, params=params, **kwargs)
71+
return GetCourierConnectionsResponse().from_dict(
72+
{
73+
"pagination": result.get("pagination"),
74+
"courier_connections": result.get("courier_connections"),
75+
}
76+
)
77+
78+
@validate_params
79+
def get_courier_connections_by_id(
80+
self, courier_connection_id: Annotated[str, Field(min_length=1)], **kwargs
81+
) -> GetCourierConnectionsByIdResponse:
82+
"""
83+
Get courier connection results of a single courier connection.
84+
:param courier_connection_id: str.
85+
:param kwargs:
86+
request options:
87+
**headers** (dict): support custom headers.
88+
**verify** bool|str|SSLContext: SSL certificates (a.k.a CA bundle) used to
89+
verify the identity of requested hosts. Either `True` (default CA bundle),
90+
a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
91+
(which will disable verification).
92+
"""
93+
url = f"/tracking/2025-04/courier-connections/{courier_connection_id}"
94+
95+
result = self._request("GET", url=url, **kwargs)
96+
return GetCourierConnectionsByIdResponse().from_dict(result)
97+
98+
@validate_params
99+
def post_courier_connections(
100+
self, post_courier_connections_request: Union[PostCourierConnectionsRequest, dict], **kwargs
101+
) -> PostCourierConnectionsResponse:
102+
"""
103+
104+
:param post_courier_connections_request:
105+
:param kwargs:
106+
request options:
107+
**headers** (dict): support custom headers.
108+
**verify** bool|str|SSLContext: SSL certificates (a.k.a CA bundle) used to
109+
verify the identity of requested hosts. Either `True` (default CA bundle),
110+
a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
111+
(which will disable verification).
112+
"""
113+
url = "/tracking/2025-04/courier-connections"
114+
115+
body = post_courier_connections_request
116+
if not isinstance(body, dict):
117+
body = post_courier_connections_request.model_dump(exclude_none=True)
118+
body = json.dumps(body)
119+
120+
result = self._request("POST", url=url, body=body, **kwargs)
121+
return PostCourierConnectionsResponse().from_dict(result)
122+
123+
@validate_params
124+
def put_courier_connections_by_id(
125+
self,
126+
courier_connection_id: Annotated[str, Field(min_length=1)],
127+
put_courier_connections_by_id_request: Union[PutCourierConnectionsByIdRequest, dict],
128+
**kwargs,
129+
) -> PutCourierConnectionsByIdResponse:
130+
"""
131+
Update a courier connection.
132+
:param courier_connection_id: str.
133+
:param put_courier_connections_by_id_request:
134+
:param kwargs:
135+
request options:
136+
**headers** (dict): support custom headers.
137+
**verify** bool|str|SSLContext: SSL certificates (a.k.a CA bundle) used to
138+
verify the identity of requested hosts. Either `True` (default CA bundle),
139+
a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
140+
(which will disable verification).
141+
"""
142+
url = f"/tracking/2025-04/courier-connections/{courier_connection_id}"
143+
144+
body = put_courier_connections_by_id_request
145+
if not isinstance(body, dict):
146+
body = put_courier_connections_by_id_request.model_dump(exclude_none=True)
147+
body = json.dumps(body)
148+
149+
result = self._request("PATCH", url=url, body=body, **kwargs)
150+
return PutCourierConnectionsByIdResponse().from_dict(result)

tracking/api/estimated_delivery_date.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
# Do not edit the class manually.
55

66
import json
7-
from typing import Union, Annotated
7+
from typing import Union
88

9-
from pydantic import Field
109

1110
from tracking.models import (
1211
PredictRequest,
@@ -33,7 +32,7 @@ def predict(self, predict_request: Union[PredictRequest, dict], **kwargs) -> Pre
3332
a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
3433
(which will disable verification).
3534
"""
36-
url = "/tracking/2025-01/estimated-delivery-date/predict"
35+
url = "/tracking/2025-04/estimated-delivery-date/predict"
3736

3837
body = predict_request
3938
if not isinstance(body, dict):
@@ -58,7 +57,7 @@ def predict_batch(
5857
a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
5958
(which will disable verification).
6059
"""
61-
url = "/tracking/2025-01/estimated-delivery-date/predict-batch"
60+
url = "/tracking/2025-04/estimated-delivery-date/predict-batch"
6261

6362
body = predict_batch_request
6463
if not isinstance(body, dict):

0 commit comments

Comments
 (0)