-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Monta - new components #18985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Monta - new components #18985
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/Info/paths/~1info/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 avalaible between channels", | ||
michelle0927 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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; | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
35
components/monta/actions/list-order-events/list-order-events.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.