-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - shopify #17797
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
New Components - shopify #17797
Changes from all commits
Commits
Show all changes
4 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
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
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
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
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
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
77 changes: 77 additions & 0 deletions
77
components/shopify_developer_app/actions/create-fulfillment/create-fulfillment.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,77 @@ | ||
| import shopify from "../../shopify_developer_app.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "shopify_developer_app-create-fulfillment", | ||
| name: "Create Fulfillment", | ||
| description: "Create a fulfillment. [See the documentation](https://shopify.dev/docs/api/admin-graphql/unstable/mutations/fulfillmentcreate)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| shopify, | ||
| fulfillmentOrderId: { | ||
| propDefinition: [ | ||
| shopify, | ||
| "fulfillmentOrderId", | ||
| ], | ||
| }, | ||
| fulfillmentOrderLineItemIds: { | ||
| propDefinition: [ | ||
| shopify, | ||
| "fulfillmentOrderLineItemIds", | ||
| (c) => ({ | ||
| fulfillmentOrderId: c.fulfillmentOrderId, | ||
| }), | ||
| ], | ||
| reloadProps: true, | ||
| }, | ||
| notifyCustomer: { | ||
| type: "boolean", | ||
| label: "Notify Customer", | ||
| description: "Whether to notify the customer", | ||
| optional: true, | ||
| }, | ||
| message: { | ||
| type: "string", | ||
| label: "Message", | ||
| description: "An optional message for the fulfillment request.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async additionalProps() { | ||
| const props = {}; | ||
| if (!this.fulfillmentOrderLineItemIds) { | ||
| return props; | ||
| } | ||
|
|
||
| for (const id of this.fulfillmentOrderLineItemIds) { | ||
| props[`quantity_${id}`] = { | ||
| type: "integer", | ||
| label: `Quantity for Line Item - ${id}`, | ||
| description: "The quantity of the line item to fulfill", | ||
| }; | ||
| } | ||
| return props; | ||
| }, | ||
| async run({ $ }) { | ||
| const fulfillment = await this.shopify.createFulfillment({ | ||
| fulfillment: { | ||
| lineItemsByFulfillmentOrder: [ | ||
| { | ||
| fulfillmentOrderId: this.fulfillmentOrderId, | ||
| fulfillmentOrderLineItems: this.fulfillmentOrderLineItemIds.map((id) => ({ | ||
| id, | ||
| quantity: this[`quantity_${id}`], | ||
| })), | ||
| }, | ||
| ], | ||
| notifyCustomer: this.notifyCustomer, | ||
| }, | ||
| message: this.message, | ||
| }); | ||
| if (fulfillment.fulfillmentCreate.userErrors.length > 0) { | ||
| throw new Error(fulfillment.fulfillmentCreate.userErrors[0].message); | ||
| } | ||
| $.export("$summary", `Created fulfillment with ID: ${fulfillment.fulfillmentCreate.fulfillment.id}`); | ||
| return fulfillment; | ||
| }, | ||
| }; |
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
100 changes: 100 additions & 0 deletions
100
components/shopify_developer_app/actions/refund-order/refund-order.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,100 @@ | ||
| import shopify from "../../shopify_developer_app.app.mjs"; | ||
| import { MAX_LIMIT } from "@pipedream/shopify/common/constants.mjs"; | ||
|
|
||
| export default { | ||
| key: "shopify_developer_app-refund-order", | ||
| name: "Refund Order", | ||
| description: "Refund an order. [See the documentation](https://shopify.dev/docs/api/admin-graphql/unstable/mutations/refundcreate)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| shopify, | ||
| orderId: { | ||
| propDefinition: [ | ||
| shopify, | ||
| "orderId", | ||
| ], | ||
| }, | ||
| note: { | ||
| type: "string", | ||
| label: "Note", | ||
| description: "An optional note that's attached to the refund", | ||
| optional: true, | ||
| }, | ||
| lineItemIds: { | ||
| propDefinition: [ | ||
| shopify, | ||
| "lineItemIds", | ||
| (c) => ({ | ||
| orderId: c.orderId, | ||
| }), | ||
| ], | ||
| reloadProps: true, | ||
| }, | ||
| }, | ||
| async additionalProps() { | ||
| const props = {}; | ||
| if (!this.lineItemIds) { | ||
| return props; | ||
| } | ||
| const order = await this.shopify.getOrder({ | ||
| id: this.orderId, | ||
| first: MAX_LIMIT, | ||
| }); | ||
| for (const id of this.lineItemIds) { | ||
| const lineItem = order.order.lineItems.edges.find((item) => item.node.id === id); | ||
| props[`quantity_${id}`] = { | ||
| type: "integer", | ||
| label: `Quantity for line item - ${lineItem.node.title}`, | ||
| description: "The quantity of the line item to refund", | ||
| }; | ||
| props[`restockType_${id}`] = { | ||
| type: "string", | ||
| label: `Restock type for line item - ${lineItem.node.title}`, | ||
| description: "The restock type for the line item", | ||
| options: [ | ||
| "CANCEL", | ||
| "NO_RESTOCK", | ||
| "RETURN", | ||
| ], | ||
| default: "RETURN", | ||
| }; | ||
| props[`locationId_${id}`] = { | ||
| type: "string", | ||
| label: `Location ID for line item - ${lineItem.node.title}`, | ||
| description: "The location ID for the line item", | ||
| options: async ({ prevContext }) => { | ||
| return this.shopify.getPropOptions({ | ||
| resourceFn: this.shopify.listLocations, | ||
| resourceKeys: [ | ||
| "locations", | ||
| ], | ||
| labelKey: "name", | ||
| prevContext, | ||
| }); | ||
| }, | ||
| }; | ||
| } | ||
| return props; | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.shopify.refundOrder({ | ||
| input: { | ||
| note: this.note, | ||
| orderId: this.orderId, | ||
| refundLineItems: this.lineItemIds.map((id) => ({ | ||
| lineItemId: id, | ||
| quantity: this[`quantity_${id}`], | ||
| locationId: this[`locationId_${id}`], | ||
| restockType: this[`restockType_${id}`], | ||
| })), | ||
| }, | ||
| }); | ||
|
|
||
| if (response.refundCreate.userErrors.length > 0) { | ||
| throw new Error(response.refundCreate.userErrors[0].message); | ||
| } | ||
| $.export("$summary", `Refunded 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
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.