Skip to content
Open
Show file tree
Hide file tree
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
42 changes: 42 additions & 0 deletions components/monta/actions/get-order/get-order.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import monta from "../../monta.app.mjs";

export default {
key: "monta-get-order",
name: "Get Order",
description: "Get an order by ID. [See the documentation](https://api-v6.monta.nl/index.html#tag/Order/paths/~1order~1%7Bwebshoporderid%7D/get)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
monta,
orderId: {
propDefinition: [
monta,
"orderId",
],
},
channel: {
type: "string",
label: "Channel",
description: "The channel name if multiple order IDs are available between channels",
optional: true,
},
},
async run({ $ }) {
const response = await this.monta.getOrder({
$,
orderId: this.orderId,
params: {
channel: this.channel,
},
});

$.export("$summary", `Successfully retrieved order with ID \`${this.orderId}\`.`);

return response;
},
};
41 changes: 41 additions & 0 deletions components/monta/actions/get-return/get-return.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import monta from "../../monta.app.mjs";

export default {
key: "monta-get-return",
name: "Get Return",
description: "Get a return by ID. [See the documentation](https://api-v6.monta.nl/index.html#tag/Return/paths/~1return~1%7Bid%7D/get)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
monta,
orderId: {
propDefinition: [
monta,
"orderId",
],
},
returnId: {
propDefinition: [
monta,
"returnId",
({ orderId }) => ({
orderId,
}),
],
},
},
async run({ $ }) {
const response = await this.monta.getReturn({
$,
returnId: this.returnId,
});

$.export("$summary", `Successfully retrieved return with ID \`${this.returnId}\`.`);
return response;
},
};
35 changes: 35 additions & 0 deletions components/monta/actions/list-order-events/list-order-events.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import monta from "../../monta.app.mjs";

export default {
key: "monta-list-order-events",
name: "List Order Events",
description: "List order events for an order. [See the documentation](https://api-v6.monta.nl/index.html#tag/Order/paths/~1order~1%7Bwebshoporderid%7D~1events/get)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
monta,
orderId: {
propDefinition: [
monta,
"orderId",
],
},
},
async run({ $ }) {
let events = await this.monta.listOrderEvents({
$,
orderId: this.orderId,
});

$.export("$summary", `Successfully retrieved ${events.length} event${events.length === 1
? ""
: "s"}`);

return events;
},
};
92 changes: 87 additions & 5 deletions components/monta/monta.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,93 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "monta",
propDefinitions: {},
propDefinitions: {
orderId: {
type: "string",
label: "Order ID",
description: "The ID of an order",
async options({ page }) {
const orders = await this.listOrders({
params: {
page,
},
});
return orders.map(({ Id: id }) => ({
label: `Order ID: ${id}`,
value: id,
}));
},
},
returnId: {
type: "string",
label: "Return ID",
description: "The ID of a return",
async options({ orderId }) {
const { Returns: returns } = await this.listReturns({
orderId,
});
return returns.map(({ Id: id }) => ({
label: `Return ID: ${id}`,
value: id,
}));
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api-v6.monta.nl";
},
_makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
...opts,
url: `${this._baseUrl()}${path}`,
auth: {
username: this.$auth.username,
password: this.$auth.password,
},
});
},
getOrder({
orderId, ...opts
}) {
return this._makeRequest({
path: `/orders/${orderId}`,
...opts,
});
},
getReturn({
returnId, ...opts
}) {
return this._makeRequest({
path: `/returns/${returnId}`,
...opts,
});
},
listOrders(opts = {}) {
return this._makeRequest({
path: "/orders",
...opts,
});
},
listReturns({
orderId, ...opts
}) {
return this._makeRequest({
path: `/order/${orderId}/return`,
...opts,
});
},
listOrderEvents({
orderId, ...opts
}) {
return this._makeRequest({
path: `/order/${orderId}/events`,
...opts,
});
},
},
};
};
7 changes: 5 additions & 2 deletions components/monta/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/monta",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Monta Components",
"main": "monta.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
}
Loading
Loading