Files

59 lines
2.4 KiB
HTML
Raw Permalink Normal View History

2026-10-14 23:17:40 +02:00
<script type="text/javascript">
RED.nodes.registerType("zammad-api", {
category: "Zammad",
color: "#3e8e41",
defaults: {
name: { value: "" },
config: { type: "zammad-config", required: true }
},
inputs: 1,
outputs: 1,
icon: "font-awesome/fa-exchange",
label: function () {
return this.name || "Zammad API";
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
oneditprepare: function () {
$("#node-input-config").val(this.config ? this.config.id : "");
}
});
</script>
<script type="text/x-red" data-template-name="zammad-api">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Zammad API">
</div>
<div class="form-row">
<label for="node-input-config"><i class="fa fa-server"></i> Config</label>
<input type="text" id="node-input-config">
</div>
<div class="form-tips" style="color:#888; font-size:11px; margin-top:10px;">
Override via message properties:
<ul style="margin:4px 0; padding-left:18px;">
<li><b>msg.method</b> – GET, POST, PUT, DELETE</li>
<li><b>msg.endpoint</b> – /tickets, /users, etc.</li>
<li><b>msg.payload</b> – request body (object or JSON string)</li>
<li><b>msg.headers</b> – additional headers object</li>
</ul>
</div>
</script>
<script type="text/x-red" data-help-name="zammad-api">
<p>Generic Zammad API caller. Sends any HTTP method to any endpoint.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>msg.method<span class="property-type">string</span></dt><dd>HTTP method (GET, POST, PUT, DELETE). Default: GET</dd>
<dt>msg.endpoint<span class="property-type">string</span></dt><dd>API path e.g. /tickets, /users/search</dd>
<dt>msg.payload<span class="property-type">object|string</span></dt><dd>Request body</dd>
<dt>msg.headers<span class="property-type">object</span></dt><dd>Additional HTTP headers</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>msg.payload<span class="property-type">object</span></dt><dd>Parsed JSON response body</dd>
<dt>msg.statusCode<span class="property-type">number</span></dt><dd>HTTP status code</dd>
</dl>
</script>