99from pydantic import Field
1010
1111from tracking .models import (
12- DeleteCourierConnectionsByIdResponse ,
1312 GetCourierConnectionsResponse ,
14- GetCourierConnectionsByIdResponse ,
1513 PostCourierConnectionsRequest ,
1614 PostCourierConnectionsResponse ,
15+ GetCourierConnectionsByIdResponse ,
1716 PutCourierConnectionsByIdRequest ,
1817 PutCourierConnectionsByIdResponse ,
18+ DeleteCourierConnectionsByIdResponse ,
1919)
2020from tracking .request import ApiClient , validate_params
2121
2222
2323class CourierConnectionApi (ApiClient ):
2424 """CourierConnectionApi api implements"""
2525
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-07/courier-connections/{ courier_connection_id } "
42-
43- result = self ._request ("DELETE" , url = url , ** kwargs )
44- return DeleteCourierConnectionsByIdResponse ().from_dict (result )
45-
4626 @validate_params
4727 def get_courier_connections (self , ** kwargs ) -> GetCourierConnectionsResponse :
4828 """
@@ -60,6 +40,7 @@ def get_courier_connections(self, **kwargs) -> GetCourierConnectionsResponse:
6040 **limit**: str. Number of courier connections each page contain. (Default: 100, Max: 200)
6141 """
6242 url = "/tracking/2025-07/courier-connections"
43+
6344 params_keys = {
6445 "courier_slug" ,
6546 "cursor" ,
@@ -68,20 +49,15 @@ def get_courier_connections(self, **kwargs) -> GetCourierConnectionsResponse:
6849 params = {key : kwargs .pop (key ) for key in params_keys if key in kwargs }
6950
7051 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- )
52+ return GetCourierConnectionsResponse .model_validate (result )
7753
7854 @validate_params
79- def get_courier_connections_by_id (
80- self , courier_connection_id : Annotated [ str , Field ( min_length = 1 ) ], ** kwargs
81- ) -> GetCourierConnectionsByIdResponse :
55+ def post_courier_connections (
56+ self , post_courier_connections_request : Union [ PostCourierConnectionsRequest , dict ], ** kwargs
57+ ) -> PostCourierConnectionsResponse :
8258 """
83- Get courier connection results of a single courier connection.
84- :param courier_connection_id: str.
59+
60+ :param post_courier_connections_request:
8561 :param kwargs:
8662 request options:
8763 **headers** (dict): support custom headers.
@@ -90,18 +66,23 @@ def get_courier_connections_by_id(
9066 a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
9167 (which will disable verification).
9268 """
93- url = f "/tracking/2025-07/courier-connections/ { courier_connection_id } "
69+ url = "/tracking/2025-07/courier-connections"
9470
95- result = self ._request ("GET" , url = url , ** kwargs )
96- return GetCourierConnectionsByIdResponse ().from_dict (result )
71+ body = post_courier_connections_request
72+ if not isinstance (body , dict ):
73+ body = post_courier_connections_request .model_dump (exclude_none = True , mode = "json" )
74+ body = json .dumps (body )
75+
76+ result = self ._request ("POST" , url = url , body = body , ** kwargs )
77+ return PostCourierConnectionsResponse .model_validate (result )
9778
9879 @validate_params
99- def post_courier_connections (
100- self , post_courier_connections_request : Union [ PostCourierConnectionsRequest , dict ], ** kwargs
101- ) -> PostCourierConnectionsResponse :
80+ def get_courier_connections_by_id (
81+ self , id : Annotated [ str , Field ( min_length = 1 ) ], ** kwargs
82+ ) -> GetCourierConnectionsByIdResponse :
10283 """
103-
104- :param post_courier_connections_request:
84+ Get courier connection results of a single courier connection.
85+ :param id: str.
10586 :param kwargs:
10687 request options:
10788 **headers** (dict): support custom headers.
@@ -110,26 +91,21 @@ def post_courier_connections(
11091 a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
11192 (which will disable verification).
11293 """
113- url = "/tracking/2025-07/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 )
94+ url = f"/tracking/2025-07/courier-connections/{ id } "
11995
120- result = self ._request ("POST " , url = url , body = body , ** kwargs )
121- return PostCourierConnectionsResponse (). from_dict (result )
96+ result = self ._request ("GET " , url = url , ** kwargs )
97+ return GetCourierConnectionsByIdResponse . model_validate (result )
12298
12399 @validate_params
124100 def put_courier_connections_by_id (
125101 self ,
126- courier_connection_id : Annotated [str , Field (min_length = 1 )],
102+ id : Annotated [str , Field (min_length = 1 )],
127103 put_courier_connections_by_id_request : Union [PutCourierConnectionsByIdRequest , dict ],
128104 ** kwargs ,
129105 ) -> PutCourierConnectionsByIdResponse :
130106 """
131107 Update a courier connection.
132- :param courier_connection_id : str.
108+ :param id : str.
133109 :param put_courier_connections_by_id_request:
134110 :param kwargs:
135111 request options:
@@ -139,12 +115,32 @@ def put_courier_connections_by_id(
139115 a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
140116 (which will disable verification).
141117 """
142- url = f"/tracking/2025-07/courier-connections/{ courier_connection_id } "
118+ url = f"/tracking/2025-07/courier-connections/{ id } "
143119
144120 body = put_courier_connections_by_id_request
145121 if not isinstance (body , dict ):
146- body = put_courier_connections_by_id_request .model_dump (exclude_none = True )
122+ body = put_courier_connections_by_id_request .model_dump (exclude_none = True , mode = "json" )
147123 body = json .dumps (body )
148124
149125 result = self ._request ("PATCH" , url = url , body = body , ** kwargs )
150- return PutCourierConnectionsByIdResponse ().from_dict (result )
126+ return PutCourierConnectionsByIdResponse .model_validate (result )
127+
128+ @validate_params
129+ def delete_courier_connections_by_id (
130+ self , id : Annotated [str , Field (min_length = 1 )], ** kwargs
131+ ) -> DeleteCourierConnectionsByIdResponse :
132+ """
133+ Delete a courier connection.
134+ :param id: str.
135+ :param kwargs:
136+ request options:
137+ **headers** (dict): support custom headers.
138+ **verify** bool|str|SSLContext: SSL certificates (a.k.a CA bundle) used to
139+ verify the identity of requested hosts. Either `True` (default CA bundle),
140+ a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
141+ (which will disable verification).
142+ """
143+ url = f"/tracking/2025-07/courier-connections/{ id } "
144+
145+ result = self ._request ("DELETE" , url = url , ** kwargs )
146+ return DeleteCourierConnectionsByIdResponse .model_validate (result )
0 commit comments