-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreatePrintingOptionsFunction.ts
More file actions
82 lines (81 loc) · 2.98 KB
/
Copy pathcreatePrintingOptionsFunction.ts
File metadata and controls
82 lines (81 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import {
Description,
DisplayIcon,
DisplayMessage,
Documentation,
Identifier,
Name,
Parameter,
Signature,
} from "@code0-tech/hercules";
import {LabelFormat, PrintingOptions, TemplateSet} from "../../data_types/glsPrintingOptions.js";
@Identifier("createPrintingOptions")
@Signature("(TemplateSet?: GLS_TEMPLATE_SET, LabelFormat?: GLS_LABEL_FORMAT, UseDefault?: string, LabelPrinter?: string, DocumentPrinter?: string): GLS_PRINTING_OPTIONS")
@Name({code: "en-US", content: "Create GLS printing settings"})
@DisplayIcon("codezero:gls")
@DisplayMessage({code: "en-US", content: "Create GLS printing settings in format ${TemplateSet} as ${LabelFormat}"})
@Documentation({
code: "en-US",
content: "Creates a GLS printing options object that controls how shipment labels are generated and printed.",
})
@Description({
code: "en-US",
content: "Creates a GLS printing options object that controls how shipment labels are generated and printed.",
})
@Parameter({
runtimeName: "TemplateSet",
name: [{code: "en-US", content: "Template set"}],
description: [{
code: "en-US",
content: "The label template set to use for return labels. Required together with LabelFormat to generate return labels."
}],
optional: true,
})
@Parameter({
runtimeName: "LabelFormat",
name: [{code: "en-US", content: "Label format"}],
description: [{
code: "en-US",
content: "The file format for return labels. Required together with TemplateSet to generate return labels."
}],
optional: true,
})
@Parameter({
runtimeName: "UseDefault",
name: [{code: "en-US", content: "Use default"}],
description: [{code: "en-US", content: "Identifier of the default printing profile to use. Max 7 characters."}],
optional: true,
})
@Parameter({
runtimeName: "LabelPrinter",
name: [{code: "en-US", content: "Label printer"}],
description: [{code: "en-US", content: "Name of the printer to use for shipment labels. Max 255 characters."}],
optional: true,
})
@Parameter({
runtimeName: "DocumentPrinter",
name: [{code: "en-US", content: "Document printer"}],
description: [{code: "en-US", content: "Name of the printer to use for documents. Max 255 characters."}],
optional: true,
})
export class CreatePrintingOptionsFunction {
run(
_context: unknown,
TemplateSet?: TemplateSet,
LabelFormat?: LabelFormat,
UseDefault?: string,
LabelPrinter?: string,
DocumentPrinter?: string,
): PrintingOptions {
return {
...(TemplateSet && LabelFormat ? {ReturnLabels: {TemplateSet, LabelFormat}} : {}),
...(UseDefault !== undefined ? {UseDefault} : {}),
...((LabelPrinter || DocumentPrinter) ? {
DefinePrinter: {
...(LabelPrinter !== undefined ? {LabelPrinter} : {}),
...(DocumentPrinter !== undefined ? {DocumentPrinter} : {}),
},
} : {}),
};
}
}