-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] modelry #12525 #16350
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
[Components] modelry #12525 #16350
Changes from all 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
72 changes: 72 additions & 0 deletions
72
components/modelry/actions/create-product/create-product.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,72 @@ | ||
| import app from "../../modelry.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "modelry-create-product", | ||
| name: "Create Product", | ||
| description: "Create a new product. [See the documentation](https://files.cgtarsenal.com/api/doc/index.html#api-Products-CreateProduct)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| sku: { | ||
| propDefinition: [ | ||
| app, | ||
| "sku", | ||
| ], | ||
| }, | ||
| title: { | ||
| propDefinition: [ | ||
| app, | ||
| "title", | ||
| ], | ||
| }, | ||
| batchId: { | ||
| propDefinition: [ | ||
| app, | ||
| "batchId", | ||
| ], | ||
| }, | ||
| description: { | ||
| propDefinition: [ | ||
| app, | ||
| "description", | ||
| ], | ||
| }, | ||
| tags: { | ||
| propDefinition: [ | ||
| app, | ||
| "tags", | ||
| ], | ||
| }, | ||
| dimensions: { | ||
| propDefinition: [ | ||
| app, | ||
| "dimensions", | ||
| ], | ||
| }, | ||
| externalUrl: { | ||
| propDefinition: [ | ||
| app, | ||
| "externalUrl", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.app.createProduct({ | ||
| $, | ||
| data: { | ||
| product: { | ||
| sku: this.sku, | ||
| title: this.title, | ||
| batch_id: this.batchId, | ||
| description: this.description, | ||
| tags: this.tags, | ||
| dimensions: this.dimensions, | ||
| external_url: this.externalUrl, | ||
| }, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully created product "${response.data.attributes.title}" with ID: ${response.data.id}`); | ||
| return response; | ||
| }, | ||
| }; |
26 changes: 26 additions & 0 deletions
26
components/modelry/actions/delete-product/delete-product.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,26 @@ | ||
| import app from "../../modelry.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "modelry-delete-product", | ||
| name: "Delete Product", | ||
| description: "Delete the product with the specified ID. [See the documentation](https://files.cgtarsenal.com/api/doc/index.html#api-Products-DeleteProduct)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| productId: { | ||
| propDefinition: [ | ||
| app, | ||
| "productId", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.app.deleteProduct({ | ||
| $, | ||
| productId: this.productId, | ||
| }); | ||
| $.export("$summary", "Successfully deleted the product"); | ||
| 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,26 @@ | ||
| import app from "../../modelry.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "modelry-get-product", | ||
| name: "Get Product", | ||
| description: "Get details of the product with the specified ID. [See the documentation](https://files.cgtarsenal.com/api/doc/index.html#api-Products-GetProduct)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| productId: { | ||
| propDefinition: [ | ||
| app, | ||
| "productId", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.app.getProduct({ | ||
| $, | ||
| productId: this.productId, | ||
| }); | ||
| $.export("$summary", `Successfully retrieved the details for the product "${response.data.attributes.title}" with ID: ${response.data.id}`); | ||
| 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 |
|---|---|---|
| @@ -1,11 +1,115 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "modelry", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| sku: { | ||
| type: "string", | ||
| label: "SKU", | ||
| description: "SKU of the product", | ||
| }, | ||
| title: { | ||
| type: "string", | ||
| label: "Title", | ||
| description: "Name or title of the product", | ||
| }, | ||
| batchId: { | ||
| type: "string", | ||
| label: "Batch ID", | ||
| description: "Identifier of the product's batch", | ||
| optional: true, | ||
| }, | ||
| description: { | ||
| type: "string", | ||
| label: "Description", | ||
| description: "Description of the product", | ||
| optional: true, | ||
| }, | ||
| tags: { | ||
| type: "string[]", | ||
| label: "Tags", | ||
| description: "Keywords associated with the product", | ||
| optional: true, | ||
| }, | ||
| dimensions: { | ||
| type: "string", | ||
| label: "Dimensions", | ||
| description: "Dimensions of the product", | ||
| optional: true, | ||
| }, | ||
| externalUrl: { | ||
| type: "string", | ||
| label: "External URL", | ||
| description: "External URL of the product", | ||
| optional: true, | ||
| }, | ||
| productId: { | ||
| type: "string", | ||
| label: "Product ID", | ||
| description: "Identifier of the product", | ||
| async options() { | ||
| const response = await this.getProducts(); | ||
| const products = response.data; | ||
| return products.map(({ | ||
| attributes, id, | ||
| }) => ({ | ||
| label: attributes.title, | ||
| value: id, | ||
| })); | ||
| }, | ||
| }, | ||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return "https://api.modelry.ai/api/v1"; | ||
| }, | ||
| async _makeRequest(opts = {}) { | ||
| const { | ||
| $ = this, | ||
| path, | ||
| headers, | ||
| ...otherOpts | ||
| } = opts; | ||
| return axios($, { | ||
| ...otherOpts, | ||
| url: this._baseUrl() + path, | ||
| headers: { | ||
| ...headers, | ||
| "Content-Type": "application/json", | ||
| "Authorization": `${this.$auth.api_token}`, | ||
| }, | ||
| }); | ||
| }, | ||
| async createProduct(args = {}) { | ||
| return this._makeRequest({ | ||
| path: "/products", | ||
| method: "post", | ||
| ...args, | ||
| }); | ||
| }, | ||
| async getProduct({ | ||
| productId, args, | ||
| }) { | ||
| return this._makeRequest({ | ||
| path: `/products/${productId}/`, | ||
| ...args, | ||
| }); | ||
| }, | ||
| async deleteProduct({ | ||
| productId, args, | ||
| }) { | ||
| return this._makeRequest({ | ||
| path: `/products/${productId}/`, | ||
| method: "delete", | ||
| ...args, | ||
| }); | ||
| }, | ||
| async getProducts(args = {}) { | ||
| return this._makeRequest({ | ||
| path: "/products", | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| }; |
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,6 +1,6 @@ | ||
| { | ||
| "name": "@pipedream/modelry", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream Modelry Components", | ||
| "main": "modelry.app.mjs", | ||
| "keywords": [ | ||
|
|
@@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.