-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New Components - picqer #17044
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
base: master
Are you sure you want to change the base?
New Components - picqer #17044
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import picqer from "../../picqer.app.mjs"; | ||
|
||
export default { | ||
key: "picqer-add-order-comment", | ||
name: "Add Comment To Order", | ||
description: "Add a comment to an order in Picqer. [See the documentation](https://picqer.com/en/api/comments#adding-comments-to-an-order)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
picqer, | ||
orderId: { | ||
propDefinition: [ | ||
picqer, | ||
"orderId", | ||
], | ||
}, | ||
body: { | ||
propDefinition: [ | ||
picqer, | ||
"commentBody", | ||
], | ||
}, | ||
showAtRelated: { | ||
propDefinition: [ | ||
picqer, | ||
"showAtRelated", | ||
], | ||
}, | ||
isVisibleFulfillment: { | ||
propDefinition: [ | ||
picqer, | ||
"isVisibleFulfillment", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.picqer.addOrderComment({ | ||
$, | ||
orderId: this.orderId, | ||
data: { | ||
body: this.body, | ||
show_at_related: this.showAtRelated, | ||
is_visible_fulfilment: this.isVisibleFulfillment, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully added comment to order ${this.orderId}`); | ||
return response; | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,50 @@ | ||||||||||||||||||||||||||||||||||||||||||
import picqer from "../../picqer.app.mjs"; | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
export default { | ||||||||||||||||||||||||||||||||||||||||||
key: "picqer-add-return-comment", | ||||||||||||||||||||||||||||||||||||||||||
name: "Add Comment To Return", | ||||||||||||||||||||||||||||||||||||||||||
description: "Add a comment to a return in Picqer. [See the documentation](https://picqer.com/en/api/comments#add-a-comment-to-an-return)", | ||||||||||||||||||||||||||||||||||||||||||
version: "0.0.1", | ||||||||||||||||||||||||||||||||||||||||||
type: "action", | ||||||||||||||||||||||||||||||||||||||||||
props: { | ||||||||||||||||||||||||||||||||||||||||||
picqer, | ||||||||||||||||||||||||||||||||||||||||||
returnId: { | ||||||||||||||||||||||||||||||||||||||||||
propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||
picqer, | ||||||||||||||||||||||||||||||||||||||||||
"returnId", | ||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||
body: { | ||||||||||||||||||||||||||||||||||||||||||
propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||
picqer, | ||||||||||||||||||||||||||||||||||||||||||
"commentBody", | ||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||
showAtRelated: { | ||||||||||||||||||||||||||||||||||||||||||
propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||
picqer, | ||||||||||||||||||||||||||||||||||||||||||
"showAtRelated", | ||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||
isVisibleFulfillment: { | ||||||||||||||||||||||||||||||||||||||||||
propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||
picqer, | ||||||||||||||||||||||||||||||||||||||||||
"isVisibleFulfillment", | ||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||
async run({ $ }) { | ||||||||||||||||||||||||||||||||||||||||||
const response = await this.picqer.addReturnComment({ | ||||||||||||||||||||||||||||||||||||||||||
$, | ||||||||||||||||||||||||||||||||||||||||||
returnId: this.returnId, | ||||||||||||||||||||||||||||||||||||||||||
data: { | ||||||||||||||||||||||||||||||||||||||||||
body: this.body, | ||||||||||||||||||||||||||||||||||||||||||
show_at_related: this.showAtRelated, | ||||||||||||||||||||||||||||||||||||||||||
is_visible_fulfilment: this.isVisibleFulfillment, | ||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+36
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid sending If - data: {
- body: this.body,
- show_at_related: this.showAtRelated,
- is_visible_fulfilment: this.isVisibleFulfillment,
- },
+ data: {
+ body: this.body,
+ ...(this.showAtRelated !== undefined && { show_at_related: this.showAtRelated }),
+ ...(this.isVisibleFulfillment !== undefined && { is_visible_fulfilment: this.isVisibleFulfillment }),
+ }, Keeps the payload minimal and complies with API expectations. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
$.export("$summary", `Successfully added comment to return ${this.returnId}`); | ||||||||||||||||||||||||||||||||||||||||||
return response; | ||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Avoid sending
undefined
fields to the APIIf
showAtRelated
orisVisibleFulfillment
are left empty, they’re transmitted asnull
/undefined
, which some APIs reject. Build the payload conditionally:📝 Committable suggestion
🤖 Prompt for AI Agents