Skip to content

Commit 4020ef0

Browse files
committed
feat: refactor shipment functions to standardize service naming and improve parameter handling
1 parent c0fe33f commit 4020ef0

20 files changed

Lines changed: 349 additions & 79 deletions

actions/gls-action/src/functions/cancelShipmentFunction.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//TODO: Why is the request data here wrapped within a object and isn't a direct parameter
2+
13
import {
24
Description,
35
DisplayMessage,
@@ -40,7 +42,7 @@ export class CancelShipmentFunction {
4042
if (typeof error === "string") {
4143
throw new RuntimeError("ERROR_CREATING_GLS_SHIPMENT", error);
4244
}
43-
throw new RuntimeError("ERROR_CREATING_GLS_SHIPMENT", "An error occurred while creating the shipment.");
45+
throw new RuntimeError("ERROR_CREATING_GLS_SHIPMENT", "An error occurred while cancelling the GLS shipment.");
4446
}
4547
}
4648
}

actions/gls-action/src/functions/getAllowedServicesFunction.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//TODO: Why is the request data here wrapped within a object and isn't a direct parameter of 3
2+
13
import axios from "axios";
24
import {
35
Description,
@@ -49,7 +51,7 @@ export class GetAllowedServicesFunction {
4951
if (typeof error === "string") {
5052
throw new RuntimeError("ERROR_CREATING_GLS_SHIPMENT", error);
5153
}
52-
throw new RuntimeError("ERROR_CREATING_GLS_SHIPMENT", "An error occurred while creating the shipment.");
54+
throw new RuntimeError("ERROR_CREATING_GLS_SHIPMENT", "An error occurred while fetching the allowed GLS services.");
5355
}
5456
}
5557
}

actions/gls-action/src/functions/getEndOfDayReportFunction.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//TODO: Why is the request data here wrapped within a object and isn't a direct parameter
2+
13
import axios from "axios";
24
import {
35
Description,

actions/gls-action/src/functions/reprintParcelFunction.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//TODO: Outsource this into seperate functions for trackid, parcelnumber, references, etc.
2+
13
import axios from "axios";
24
import {
35
Description,

actions/gls-action/src/functions/services/_shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Parameter } from "@code0-tech/hercules";
22

33
export const SHARED_SERVICE_SIGNATURE =
4-
"shipment: GLS_SHIPMENT_WITHOUT_SERVICES, printingOptions: GLS_PRINTING_OPTIONS, returnOptions?: GLS_RETURN_OPTIONS, customContent?: GLS_CUSTOM_CONTENT";
4+
"shipment: GLS_SHIPMENT_WITHOUT_SERVICES, printingOptions: GLS_PRINTING_OPTIONS, customContent?: GLS_CUSTOM_CONTENT, returnOptions?: GLS_RETURN_OPTIONS";
55

66
export const SharedShipmentParameter = Parameter({
77
runtimeName: "shipment",

actions/gls-action/src/functions/services/createAddresseeOnlyShipmentFunction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ export class CreateAddresseeOnlyShipmentFunction {
4545
customContent?: CustomContent,
4646
returnOptions?: ReturnOptions
4747
): Promise<CreateParcelsResponse> {
48-
return postShipmentHelper(context, [{ AddresseeOnlyService: {} }], shipment, printingOptions, customContent, returnOptions);
48+
return postShipmentHelper(context, [{ Service: { ServiceName: "service_addresseeonly" } }], shipment, printingOptions, customContent, returnOptions);
4949
}
5050
}

actions/gls-action/src/functions/services/createDeliveryNextWorkingDayShipmentFunction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ export class CreateDeliveryNextWorkingDayShipmentFunction {
4949
if (shipment.Product != "EXPRESS") {
5050
throw new RuntimeError("INVALID_PRODUCT", "The product for Delivery Next Working Day service must be EXPRESS.");
5151
}
52-
return postShipmentHelper(context, [{ EOB: {} }], shipment, printingOptions, customContent, returnOptions);
52+
return postShipmentHelper(context, [{ Service: { ServiceName: "service_eob" } }], shipment, printingOptions, customContent, returnOptions);
5353
}
5454
}

actions/gls-action/src/functions/services/createDeliverySaturdayShipmentFunction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ export class CreateDeliverySaturdayShipmentFunction {
4343
if (shipment.Product != "EXPRESS") {
4444
throw new RuntimeError("INVALID_PRODUCT", "The product for Delivery Saturday service must be EXPRESS.");
4545
}
46-
return postShipmentHelper(context, [{ SaturdayService: {} }], shipment, printingOptions, customContent, returnOptions);
46+
return postShipmentHelper(context, [{ Service: { ServiceName: "service_Saturday" } }], shipment, printingOptions, customContent, returnOptions);
4747
}
4848
}

actions/gls-action/src/functions/services/createFlexDeliveryShipmentFunction.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
Description,
2+
Description, DisplayIcon,
33
DisplayMessage,
44
Documentation,
55
FunctionContext,
@@ -24,7 +24,8 @@ import {
2424
@Identifier("createFlexDeliveryShipment")
2525
@Signature(`(${SHARED_SERVICE_SIGNATURE}): GLS_CREATE_PARCELS_RESPONSE`)
2626
@Name({ code: "en-US", content: "Create flex delivery shipment" })
27-
@DisplayMessage({ code: "en-US", content: "Create flex delivery shipment" })
27+
@DisplayIcon("tabler:truck-delivery")
28+
@DisplayMessage({ code: "en-US", content: "Send flex delivery shipment" })
2829
@Documentation({
2930
code: "en-US",
3031
content: "Creates a shipment with flexible delivery - the recipient can redirect or reschedule delivery.",
@@ -45,6 +46,6 @@ export class CreateFlexDeliveryShipmentFunction {
4546
customContent?: CustomContent,
4647
returnOptions?: ReturnOptions
4748
): Promise<CreateParcelsResponse> {
48-
return postShipmentHelper(context, [{ FlexDeliveryService: {} }], shipment, printingOptions, customContent, returnOptions);
49+
return postShipmentHelper(context, [{ Service: { ServiceName: "service_flexdelivery" } }], shipment, printingOptions, customContent, returnOptions);
4950
}
5051
}

actions/gls-action/src/functions/services/createGuaranteed24ShipmentFunction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ export class CreateGuaranteed24ShipmentFunction {
4545
customContent?: CustomContent,
4646
returnOptions?: ReturnOptions
4747
): Promise<CreateParcelsResponse> {
48-
return postShipmentHelper(context, [{ Guaranteed24Service: {} }], shipment, printingOptions, customContent, returnOptions);
48+
return postShipmentHelper(context, [{ Service: { ServiceName: "service_guaranteed24" } }], shipment, printingOptions, customContent, returnOptions);
4949
}
5050
}

0 commit comments

Comments
 (0)