@@ -14,14 +14,13 @@ import {
1414} from "@code0-tech/hercules" ;
1515import { getAuthToken } from "../helpers.js" ;
1616import {
17- UpdateParcelWeightRequestData ,
1817 UpdateParcelWeightResponseData ,
1918 UpdateParcelWeightResponseDataSchema ,
2019} from "../data_types/glsUpdateParcelWeight.js" ;
2120
2221@Identifier ( "updateParcelWeight" )
2322@DisplayIcon ( "codezero:gls" )
24- @Signature ( "(data: GLS_UPDATE_PARCEL_WEIGHT_REQUEST_DATA ): GLS_UPDATE_PARCEL_WEIGHT_RESPONSE_DATA" )
23+ @Signature ( "(Weight: number, TrackID?: string, ParcelNumber?: number, ShipmentReference?: string, ShipmentUnitReference?: string, PartnerParcelNumber?: string ): GLS_UPDATE_PARCEL_WEIGHT_RESPONSE_DATA" )
2524@Name ( { code : "en-US" , content : "Update parcel weight" } )
2625@DisplayMessage ( { code : "en-US" , content : "Update parcel weight" } )
2726@Documentation ( {
@@ -33,21 +32,65 @@ import {
3332 content : "Updates the weight of an already-created parcel. Useful when the final weight is only known after packaging." ,
3433} )
3534@Parameter ( {
36- runtimeName : "data" ,
37- name : [ { code : "en-US" , content : "Data" } ] ,
38- description : [ { code : "en-US" , content : "The update parcel weight request data." } ] ,
35+ runtimeName : "Weight" ,
36+ name : [ { code : "en-US" , content : "Weight" } ] ,
37+ description : [ { code : "en-US" , content : "The new weight of the parcel in kilograms. Minimum is 0.1." } ] ,
38+ } )
39+ @Parameter ( {
40+ runtimeName : "TrackID" ,
41+ name : [ { code : "en-US" , content : "Track ID" } ] ,
42+ description : [ { code : "en-US" , content : "The Track ID of the parcel to update. Max length is 8 characters." } ] ,
43+ } )
44+ @Parameter ( {
45+ runtimeName : "ParcelNumber" ,
46+ name : [ { code : "en-US" , content : "Parcel number" } ] ,
47+ description : [ { code : "en-US" , content : "The parcel number of the parcel to update." } ] ,
48+ } )
49+ @Parameter ( {
50+ runtimeName : "ShipmentReference" ,
51+ name : [ { code : "en-US" , content : "Shipment reference" } ] ,
52+ description : [ { code : "en-US" , content : "The shipment reference of the parcel to update. Max length is 40 characters." } ] ,
53+ } )
54+ @Parameter ( {
55+ runtimeName : "ShipmentUnitReference" ,
56+ name : [ { code : "en-US" , content : "Shipment unit reference" } ] ,
57+ description : [ { code : "en-US" , content : "The shipment unit reference of the parcel to update. Max length is 40 characters." } ] ,
58+ } )
59+ @Parameter ( {
60+ runtimeName : "PartnerParcelNumber" ,
61+ name : [ { code : "en-US" , content : "Partner parcel number" } ] ,
62+ description : [ { code : "en-US" , content : "The partner parcel number of the parcel to update. Max length is 50 characters." } ] ,
3963} )
4064export class UpdateParcelWeightFunction {
41- async run ( context : FunctionContext , data : UpdateParcelWeightRequestData ) : Promise < UpdateParcelWeightResponseData > {
65+ async run (
66+ context : FunctionContext ,
67+ Weight : number ,
68+ TrackID ?: string ,
69+ ParcelNumber ?: number ,
70+ ShipmentReference ?: string ,
71+ ShipmentUnitReference ?: string ,
72+ PartnerParcelNumber ?: string
73+ ) : Promise < UpdateParcelWeightResponseData > {
4274 const url = context . matchedConfig . findConfig ( "ship_it_api_url" ) as string ;
4375
4476 try {
45- const result = await axios . post ( `${ url } /rs/shipments/updateparcelweight` , data , {
46- headers : {
47- Authorization : `Bearer ${ await getAuthToken ( context ) } ` ,
48- "Content-Type" : "application/glsVersion1+json" ,
77+ const result = await axios . post (
78+ `${ url } /rs/shipments/updateparcelweight` ,
79+ {
80+ TrackID,
81+ ParcelNumber,
82+ ShipmentReference,
83+ ShipmentUnitReference,
84+ PartnerParcelNumber,
85+ Weight,
4986 } ,
50- } ) ;
87+ {
88+ headers : {
89+ Authorization : `Bearer ${ await getAuthToken ( context ) } ` ,
90+ "Content-Type" : "application/glsVersion1+json" ,
91+ } ,
92+ }
93+ ) ;
5194 return UpdateParcelWeightResponseDataSchema . parse ( result . data ) ;
5295 } catch ( error : any ) {
5396 throw new RuntimeError ( "UPDATE_PARCEL_WEIGHT_FAILED" , error . toString ( ) ) ;
0 commit comments