@@ -14,14 +14,14 @@ import {
1414} from "@code0-tech/hercules" ;
1515import { getAuthToken } from "../helpers.js" ;
1616import {
17- ReprintParcelRequestData ,
1817 ReprintParcelResponseData ,
1918 ReprintParcelResponseDataSchema ,
2019} from "../data_types/glsReprintParcel.js" ;
20+ import { ReturnLabels } from "../data_types/glsPrintingOptions.js" ;
2121
2222@Identifier ( "reprintParcel" )
2323@DisplayIcon ( "codezero:gls" )
24- @Signature ( "(data: GLS_REPRINT_PARCEL_REQUEST_DATA ): GLS_REPRINT_PARCEL_RESPONSE_DATA" )
24+ @Signature ( "(CreationDate: string, TemplateSet: \"NONE\"|\"D_200\"|\"PF_4_I\"|\"PF_4_I_200\"|\"PF_4_I_300\"|\"PF_8_D_200\"|\"T_200_BF\"|\"T_300_BF\"|\"ZPL_200\"|\"ZPL_200_TRACKID_EAN_128\"|\"ZPL_200_TRACKID_CODE_39\"|\"ZPL_200_REFNO_EAN_128\"|\"ZPL_200_REFNO_CODE_39\"|\"ZPL_300\"|\"ZPL_300_TRACKID_EAN_128\"|\"ZPL_300_TRACKID_CODE_39\"|\"ZPL_300_REFNO_EAN_128\"|\"ZPL_300_REFNO_CODE_39\", LabelFormat: \"PDF\"|\"ZEBRA\"|\"INTERMEC\"|\"DATAMAX\"|\"TOSHIBA\"|\"PNG\", TrackID?: string, ParcelNumber?: number, ShipmentReference?: string, ShipmentUnitReference?: string, PartnerParcelNumber?: string ): GLS_REPRINT_PARCEL_RESPONSE_DATA" )
2525@Name ( { code : "en-US" , content : "Reprint parcel" } )
2626@DisplayMessage ( { code : "en-US" , content : "Reprint parcel" } )
2727@Documentation ( {
@@ -33,21 +33,88 @@ import {
3333 content : "Reprints the label for an existing parcel.\nUse this if the original label is damaged, lost, or needs to be printed in a different format." ,
3434} )
3535@Parameter ( {
36- runtimeName : "data" ,
37- name : [ { code : "en-US" , content : "Data" } ] ,
38- description : [ { code : "en-US" , content : "The reprint parcel request data." } ] ,
36+ runtimeName : "CreationDate" ,
37+ name : [ { code : "en-US" , content : "Creation date" } ] ,
38+ description : [ { code : "en-US" , content : "The creation date of the parcel, in ISO format (YYYY-MM-DD)." } ] ,
39+ } )
40+ @Parameter ( {
41+ runtimeName : "TemplateSet" ,
42+ name : [ { code : "en-US" , content : "Template set" } ] ,
43+ description : [ { code : "en-US" , content : "The template set to use for the reprinted label." } ] ,
44+ } )
45+ @Parameter ( {
46+ runtimeName : "LabelFormat" ,
47+ name : [ { code : "en-US" , content : "Label format" } ] ,
48+ description : [ { code : "en-US" , content : "The format of the reprinted label." } ] ,
49+ } )
50+ @Parameter ( {
51+ runtimeName : "TrackID" ,
52+ name : [ { code : "en-US" , content : "Track ID" } ] ,
53+ description : [ { code : "en-US" , content : "The Track ID of the parcel to reprint. Max length is 8 characters." } ] ,
54+ optional : true ,
55+ } )
56+ @Parameter ( {
57+ runtimeName : "ParcelNumber" ,
58+ name : [ { code : "en-US" , content : "Parcel number" } ] ,
59+ description : [ { code : "en-US" , content : "The parcel number of the parcel to reprint." } ] ,
60+ optional : true ,
61+ } )
62+ @Parameter ( {
63+ runtimeName : "ShipmentReference" ,
64+ name : [ { code : "en-US" , content : "Shipment reference" } ] ,
65+ description : [ { code : "en-US" , content : "The shipment reference of the parcel to reprint. Max length is 40 characters." } ] ,
66+ optional : true ,
67+ } )
68+ @Parameter ( {
69+ runtimeName : "ShipmentUnitReference" ,
70+ name : [ { code : "en-US" , content : "Shipment unit reference" } ] ,
71+ description : [ { code : "en-US" , content : "The shipment unit reference of the parcel to reprint. Max length is 40 characters." } ] ,
72+ optional : true ,
73+ } )
74+ @Parameter ( {
75+ runtimeName : "PartnerParcelNumber" ,
76+ name : [ { code : "en-US" , content : "Partner parcel number" } ] ,
77+ description : [ { code : "en-US" , content : "The partner parcel number of the parcel to reprint. Max length is 50 characters." } ] ,
78+ optional : true ,
3979} )
4080export class ReprintParcelFunction {
41- async run ( context : FunctionContext , data : ReprintParcelRequestData ) : Promise < ReprintParcelResponseData > {
81+ async run (
82+ context : FunctionContext ,
83+ CreationDate : string ,
84+ TemplateSet : ReturnLabels [ "TemplateSet" ] ,
85+ LabelFormat : ReturnLabels [ "LabelFormat" ] ,
86+ TrackID ?: string ,
87+ ParcelNumber ?: number ,
88+ ShipmentReference ?: string ,
89+ ShipmentUnitReference ?: string ,
90+ PartnerParcelNumber ?: string
91+ ) : Promise < ReprintParcelResponseData > {
4292 const url = context . matchedConfig . findConfig ( "ship_it_api_url" ) as string ;
4393
4494 try {
45- const result = await axios . post ( `${ url } /rs/shipments/reprintparcel` , data , {
46- headers : {
47- Authorization : `Bearer ${ await getAuthToken ( context ) } ` ,
48- "Content-Type" : "application/glsVersion1+json" ,
95+ const result = await axios . post (
96+ `${ url } /rs/shipments/reprintparcel` ,
97+ {
98+ TrackID,
99+ ParcelNumber,
100+ ShipmentReference,
101+ ShipmentUnitReference,
102+ PartnerParcelNumber,
103+ CreationDate,
104+ PrintingOptions : {
105+ ReturnLabels : {
106+ TemplateSet,
107+ LabelFormat,
108+ } ,
109+ } ,
49110 } ,
50- } ) ;
111+ {
112+ headers : {
113+ Authorization : `Bearer ${ await getAuthToken ( context ) } ` ,
114+ "Content-Type" : "application/glsVersion1+json" ,
115+ } ,
116+ }
117+ ) ;
51118 return ReprintParcelResponseDataSchema . parse ( result . data ) ;
52119 } catch ( error : any ) {
53120 console . log ( error ) ;
0 commit comments