Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions components/wics/wics.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "wics",
propDefinitions: {
api_key: {
type: "string",
secret: true,
label: "API Key",
description: "WICS API Key",
},
base_url: {
type: "string",
label: "Base URL",
description: "WICS Base URL",
default: "https://api.wics.nl",
},
},
methods: {
_baseUrl() {
return this.$auth.base_url || "https://api.wics.nl";
},
Comment on lines +6 to +23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Avoid duplicating the base URL default and consider normalizing trailing slashes

You hard‑code "https://api.wics.nl" both in propDefinitions.base_url.default and _baseUrl(), and _baseUrl() doesn’t normalize trailing slashes. To keep things DRY and avoid //orders when users include a trailing slash, consider centralizing and normalizing here:

-  methods: {
-    _baseUrl() {
-      return this.$auth.base_url || "https://api.wics.nl";
-    },
+  methods: {
+    _baseUrl() {
+      const baseUrl = this.$auth.base_url || "https://api.wics.nl";
+      return baseUrl.replace(/\/+$/, "");
+    },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
propDefinitions: {
api_key: {
type: "string",
secret: true,
label: "API Key",
description: "WICS API Key",
},
base_url: {
type: "string",
label: "Base URL",
description: "WICS Base URL",
default: "https://api.wics.nl",
},
},
methods: {
_baseUrl() {
return this.$auth.base_url || "https://api.wics.nl";
},
propDefinitions: {
api_key: {
type: "string",
secret: true,
label: "API Key",
description: "WICS API Key",
},
base_url: {
type: "string",
label: "Base URL",
description: "WICS Base URL",
default: "https://api.wics.nl",
},
},
methods: {
_baseUrl() {
const baseUrl = this.$auth.base_url || "https://api.wics.nl";
return baseUrl.replace(/\/+$/, "");
},
🤖 Prompt for AI Agents
In components/wics/wics.app.mjs around lines 6–23, you duplicate the base URL
default and don’t normalize trailing slashes; introduce a single constant like
DEFAULT_BASE_URL (use it for propDefinitions.base_url.default) and have
_baseUrl() return (this.$auth.base_url || DEFAULT_BASE_URL) with trailing
slashes stripped (e.g., remove any trailing '/' characters) so callers never get
a double-slash when concatenating paths. Ensure all concatenations add a single
'/' as needed elsewhere.

async _makeRequest({ $ = this, path, ...opts }) {
return axios($, {
url: `${this._baseUrl()}${path}`,
headers: {
Authorization: `Bearer ${this.$auth.api_key}`,
"Content-Type": "application/json",
},
...opts,
});
},
async getOrder(order_id) {
return this._makeRequest({
path: `/orders/${order_id}`,
});
},
async listOrders(params = {}) {
return this._makeRequest({
path: "/orders",
params,
});
},
async createOrder(data) {
return this._makeRequest({
method: "POST",
path: "/orders",
data,
});
},
},
async auth() {
return this._makeRequest({
path: "/auth/verify",
});
},
};