44 */
55import { Request } from "../lib/request" ;
66import { AftershipError , AfterShipErrorCodes } from "../error" ;
7+ import { PutCourierConnectionsByIdResponse } from "../model/PutCourierConnectionsByIdResponse" ;
78import { DeleteCourierConnectionsByIdResponse } from "../model/DeleteCourierConnectionsByIdResponse" ;
8- import { GetCourierConnectionsQuery } from "../model/GetCourierConnectionsQuery" ;
99import { GetCourierConnectionsResponse } from "../model/GetCourierConnectionsResponse" ;
10+ import { GetCourierConnectionsQuery } from "../model/GetCourierConnectionsQuery" ;
1011import { PostCourierConnectionsRequest } from "../model/PostCourierConnectionsRequest" ;
1112import { PostCourierConnectionsResponse } from "../model/PostCourierConnectionsResponse" ;
12- import { PutCourierConnectionsByIdRequest } from "../model/PutCourierConnectionsByIdRequest" ;
13- import { PutCourierConnectionsByIdResponse } from "../model/PutCourierConnectionsByIdResponse" ;
1413import { GetCourierConnectionsByIdResponse } from "../model/GetCourierConnectionsByIdResponse" ;
14+ import { PutCourierConnectionsByIdRequest } from "../model/PutCourierConnectionsByIdRequest" ;
1515
1616export class CourierConnectionApi {
1717 private readonly request : Request ;
@@ -20,44 +20,19 @@ export class CourierConnectionApi {
2020 this . request = request ;
2121 }
2222
23- /**
24- * Delete a courier connection.
25- */
26- public async deleteCourierConnectionsById (
27- id : string ,
28- headers ?: { [ key : string ] : any } ,
29- ) : Promise < DeleteCourierConnectionsByIdResponse > {
30- if ( ! id ) {
31- throw new AftershipError (
32- "Invalid params: id" ,
33- AfterShipErrorCodes . VALUE_INVALID ,
34- ) ;
35- }
36-
37- return this . request . makeRequest < DeleteCourierConnectionsByIdResponse > ( {
38- url : `/tracking/2025-07/courier-connections/${ id } ` ,
39- method : "DELETE" ,
40- headers,
41- request_legacy_tag : "" ,
42- response_legacy_tag : "" ,
43- is_paging : false ,
44- } ) ;
45- }
4623 /**
4724 * Get courier connection results of multiple courier connections.
4825 */
4926 public async getCourierConnections (
5027 query ?: GetCourierConnectionsQuery ,
5128 headers ?: { [ key : string ] : any } ,
5229 ) : Promise < GetCourierConnectionsResponse > {
30+ const url = `/tracking/2025-07/courier-connections` ;
5331 return this . request . makeRequest < GetCourierConnectionsResponse > ( {
54- url : `/tracking/2025-07/courier-connections` ,
32+ url : url ,
5533 method : "GET" ,
5634 query,
5735 headers,
58- request_legacy_tag : "" ,
59- response_legacy_tag : "courier_connections" ,
60- is_paging : true ,
6136 } ) ;
6237 }
6338 /**
@@ -67,14 +42,32 @@ export class CourierConnectionApi {
6742 body : PostCourierConnectionsRequest ,
6843 headers ?: { [ key : string ] : any } ,
6944 ) : Promise < PostCourierConnectionsResponse > {
45+ const url = `/tracking/2025-07/courier-connections` ;
7046 return this . request . makeRequest < PostCourierConnectionsResponse > ( {
71- url : `/tracking/2025-07/courier-connections` ,
47+ url : url ,
7248 method : "POST" ,
7349 body,
7450 headers,
75- request_legacy_tag : "" ,
76- response_legacy_tag : "" ,
77- is_paging : false ,
51+ } ) ;
52+ }
53+ /**
54+ * Get courier connection results of a single courier connection.
55+ */
56+ public async getCourierConnectionsById (
57+ id : string ,
58+ headers ?: { [ key : string ] : any } ,
59+ ) : Promise < GetCourierConnectionsByIdResponse > {
60+ if ( ! id ) {
61+ throw new AftershipError (
62+ "Invalid params: id" ,
63+ AfterShipErrorCodes . BAD_REQUEST ,
64+ ) ;
65+ }
66+ const url = `/tracking/2025-07/courier-connections/${ id } ` ;
67+ return this . request . makeRequest < GetCourierConnectionsByIdResponse > ( {
68+ url : url ,
69+ method : "GET" ,
70+ headers,
7871 } ) ;
7972 }
8073 /**
@@ -88,41 +81,35 @@ export class CourierConnectionApi {
8881 if ( ! id ) {
8982 throw new AftershipError (
9083 "Invalid params: id" ,
91- AfterShipErrorCodes . VALUE_INVALID ,
84+ AfterShipErrorCodes . BAD_REQUEST ,
9285 ) ;
9386 }
94-
87+ const url = `/tracking/2025-07/courier-connections/ ${ id } ` ;
9588 return this . request . makeRequest < PutCourierConnectionsByIdResponse > ( {
96- url : `/tracking/2025-07/courier-connections/ ${ id } ` ,
89+ url : url ,
9790 method : "PATCH" ,
9891 body,
9992 headers,
100- request_legacy_tag : "" ,
101- response_legacy_tag : "" ,
102- is_paging : false ,
10393 } ) ;
10494 }
10595 /**
106- * Get courier connection results of a single courier connection.
96+ * Delete a courier connection.
10797 */
108- public async getCourierConnectionsById (
98+ public async deleteCourierConnectionsById (
10999 id : string ,
110100 headers ?: { [ key : string ] : any } ,
111- ) : Promise < GetCourierConnectionsByIdResponse > {
101+ ) : Promise < DeleteCourierConnectionsByIdResponse > {
112102 if ( ! id ) {
113103 throw new AftershipError (
114104 "Invalid params: id" ,
115- AfterShipErrorCodes . VALUE_INVALID ,
105+ AfterShipErrorCodes . BAD_REQUEST ,
116106 ) ;
117107 }
118-
119- return this . request . makeRequest < GetCourierConnectionsByIdResponse > ( {
120- url : `/tracking/2025-07/courier-connections/ ${ id } ` ,
121- method : "GET " ,
108+ const url = `/tracking/2025-07/courier-connections/ ${ id } ` ;
109+ return this . request . makeRequest < DeleteCourierConnectionsByIdResponse > ( {
110+ url : url ,
111+ method : "DELETE " ,
122112 headers,
123- request_legacy_tag : "" ,
124- response_legacy_tag : "" ,
125- is_paging : false ,
126113 } ) ;
127114 }
128115}
0 commit comments