Add Shopify Discount Code Endpoints#21403
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified. |
|
Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:
|
📝 WalkthroughWalkthroughThe Shopify integration now exports four asynchronous discount-code actions for retrieving, updating, deleting, and bulk-creating discount codes through the injected Shopify service. ChangesShopify discount code actions
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9917890047
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1,91 @@ | |||
| export default { | |||
There was a problem hiding this comment.
Publish these as real action components
In the contexts I checked (.github/workflows/publish-components.yaml publishes each changed component file directly, and existing Shopify actions live under components/shopify/actions/<slug>/<slug>.mjs with top-level key and type: "action"), this new top-level actions.js is treated as one component file rather than expanded into four actions. Because the exported object has no top-level action key/type and is not imported by shopify.app.mjs, the discount-code operations will not be available in the registry; they need to be added as normal action component files or explicitly wired into the supported publish path.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@components/shopify/actions.js`:
- Around line 84-88: Update the discount-code payload in async run() to
transform string entries in this.codes into objects with a code property before
calling Shopify’s price_rules batch endpoint, while preserving entries already
supplied as pre-formatted objects. Pass the normalized array as discount_codes.
- Around line 84-88: Update the request construction in async run() to transform
this.codes into Shopify’s required discount_codes object array, wrapping string
entries as objects with a code property while preserving entries already
supplied as objects. Pass the normalized array in the existing post call and
retain the current endpoint and response behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: cb8c906a-fcc0-4b13-a423-dedf35a0c9ec
📒 Files selected for processing (1)
components/shopify/actions.js
| async run() { | ||
| return await this.shopify.post(`price_rules/${this.priceRuleId}/batch.json`, { | ||
| discount_codes: this.codes | ||
| }) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Map string arrays to object arrays for the Shopify API.
The Shopify bulk discount creation endpoint expects discount_codes to be an array of objects (e.g., [{"code": "SUMMER1"}]), but the framework's array props typically collect and return an array of strings when used from the UI. Passing string items directly will cause a Shopify API validation error.
Map the array items to objects, while safely handling cases where a user might pass pre-formatted objects via a custom expression.
🐛 Proposed fix
async run() {
return await this.shopify.post(`price_rules/${this.priceRuleId}/batch.json`, {
- discount_codes: this.codes
+ discount_codes: this.codes.map(code => typeof code === "string" ? { code } : code)
})
}📝 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.
| async run() { | |
| return await this.shopify.post(`price_rules/${this.priceRuleId}/batch.json`, { | |
| discount_codes: this.codes | |
| }) | |
| } | |
| async run() { | |
| return await this.shopify.post(`price_rules/${this.priceRuleId}/batch.json`, { | |
| discount_codes: this.codes.map(code => typeof code === "string" ? { code } : code) | |
| }) | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@components/shopify/actions.js` around lines 84 - 88, Update the discount-code
payload in async run() to transform string entries in this.codes into objects
with a code property before calling Shopify’s price_rules batch endpoint, while
preserving entries already supplied as pre-formatted objects. Pass the
normalized array as discount_codes.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Map string arrays to object arrays for the Shopify API.
The Shopify bulk discount creation endpoint expects discount_codes to be an array of objects (e.g., [{"code": "SUMMER1"}]), but Pipedream array props typically accept and return an array of strings when used in the UI. Passing strings directly will cause a Shopify API validation error.
Map the array items to objects while safely handling cases where a user might pass pre-formatted objects via a custom expression.
💻 Proposed fix
async run() {
return await this.shopify.post(`price_rules/${this.priceRuleId}/batch.json`, {
- discount_codes: this.codes
+ discount_codes: this.codes.map(code => typeof code === "string" ? { code } : code)
})
}📝 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.
| async run() { | |
| return await this.shopify.post(`price_rules/${this.priceRuleId}/batch.json`, { | |
| discount_codes: this.codes | |
| }) | |
| } | |
| async run() { | |
| return await this.shopify.post(`price_rules/${this.priceRuleId}/batch.json`, { | |
| discount_codes: this.codes.map(code => typeof code === "string" ? { code } : code) | |
| }) | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@components/shopify/actions.js` around lines 84 - 88, Update the request
construction in async run() to transform this.codes into Shopify’s required
discount_codes object array, wrapping string entries as objects with a code
property while preserving entries already supplied as objects. Pass the
normalized array in the existing post call and retain the current endpoint and
response behavior.
ashwins01
left a comment
There was a problem hiding this comment.
Hi @Ap-0007, thank you for your contribution, but the changes are not aligned with the contribution guidelines at https://pipedream.com/docs/components/contributing/guidelines
Please feel free to take a look at the existing actions/sources of the Shopify connector on how best to submit a contribution going forward.
|
Closing this in favour of #21428 |
|
Awesome, thanks for the feedback! I'll make sure to include all required template sections in the description moving forward. The PR will be updated ASAP. |
What was broken
Missing Shopify Discount Code endpoints
What changed
Added GET, PUT, DELETE, and POST endpoints for Shopify Discount Codes
How to test
Test each endpoint with a valid Shopify API key and discount code
Opened by autonomous agent. Human review required before merge.
Summary by CodeRabbit