-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] bluecart_api #10915 #19022
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?
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,41 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import app from "../../bluecart_api.app.mjs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| export default { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| key: "bluecart_api-get-autocomplete", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: "Get Autocomplete", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Get autocomplete suggestions for the specified search term. [See the documentation](https://docs.trajectdata.com/bluecartapi/walmart-product-data-api/parameters/autocomplete)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| version: "0.0.1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| annotations: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| destructiveHint: false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| openWorldHint: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| readOnlyHint: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "action", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| props: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| app, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| walmartDomain: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| app, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "walmartDomain", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| searchTerm: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| app, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "searchTerm", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "The search term to get autocomplete suggestions for", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| async run({ $ }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const response = await this.app.getAutocomplete({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| $, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| params: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| searchTerm: this.searchTerm, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "autocomplete", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| $.export("$summary", "Successfully retrieved " + response.autocomplete_results.length + " suggestions"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+30
to
+40
Contributor
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. Fix parameter naming inconsistency and add null check. Two issues:
Apply this diff: async run({ $ }) {
const response = await this.app.getAutocomplete({
$,
params: {
- searchTerm: this.searchTerm,
+ search_term: this.searchTerm,
type: "autocomplete",
},
});
- $.export("$summary", "Successfully retrieved " + response.autocomplete_results.length + " suggestions");
+ if (!response?.autocomplete_results) {
+ throw new Error("Invalid API response: autocomplete_results not found");
+ }
+ $.export("$summary", `Successfully retrieved ${response.autocomplete_results.length} suggestions`);
return response;
},📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,34 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
| import app from "../../bluecart_api.app.mjs"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| export default { | ||||||||||||||||||||||||||||||||||||||||||||||||
| key: "bluecart_api-get-categories", | ||||||||||||||||||||||||||||||||||||||||||||||||
| name: "Get Categories", | ||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Get a list of categories related to the provided search term. [See the documentation](https://docs.trajectdata.com/bluecartapi/walmart-product-data-api/parameters/category)", | ||||||||||||||||||||||||||||||||||||||||||||||||
| version: "0.0.1", | ||||||||||||||||||||||||||||||||||||||||||||||||
| annotations: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| destructiveHint: false, | ||||||||||||||||||||||||||||||||||||||||||||||||
| openWorldHint: true, | ||||||||||||||||||||||||||||||||||||||||||||||||
| readOnlyHint: true, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| type: "action", | ||||||||||||||||||||||||||||||||||||||||||||||||
| props: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| app, | ||||||||||||||||||||||||||||||||||||||||||||||||
| searchTerm: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||||||||
| app, | ||||||||||||||||||||||||||||||||||||||||||||||||
| "searchTerm", | ||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||
| description: "The term used to search for categories", | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| async run({ $ }) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| const response = await this.app.getCategories({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| $, | ||||||||||||||||||||||||||||||||||||||||||||||||
| params: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| search_term: this.searchTerm, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| $.export("$summary", "Successfully retrieved " + response.categories.length + " categories"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| return response; | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+24
to
+33
Contributor
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. Add defensive null check for the API response. Line 31 directly accesses Apply this diff: async run({ $ }) {
const response = await this.app.getCategories({
$,
params: {
search_term: this.searchTerm,
},
});
- $.export("$summary", "Successfully retrieved " + response.categories.length + " categories");
+ if (!response?.categories) {
+ throw new Error("Invalid API response: categories not found");
+ }
+ $.export("$summary", `Successfully retrieved ${response.categories.length} categories`);
return response;
},📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import app from "../../bluecart_api.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "bluecart_api-get-product", | ||
| name: "Get product", | ||
| description: "Get product data from Walmart. [See the documentation](https://docs.trajectdata.com/bluecartapi/walmart-product-data-api/parameters/product)", | ||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| walmartDomain: { | ||
| propDefinition: [ | ||
| app, | ||
| "walmartDomain", | ||
| ], | ||
| }, | ||
| url: { | ||
| propDefinition: [ | ||
| app, | ||
| "url", | ||
| ], | ||
| }, | ||
| itemId: { | ||
| propDefinition: [ | ||
| app, | ||
| "itemId", | ||
| ], | ||
| }, | ||
| }, | ||
|
|
||
| async run({ $ }) { | ||
| const response = await this.app.searchItem({ | ||
| $, | ||
| params: { | ||
| walmart_domain: this.walmartDomain, | ||
| type: "product", | ||
| item_id: this.itemId, | ||
| url: this.url, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", "Successfully retrieved data for the product with id: " + response.product.item_id); | ||
| return response; | ||
| }, | ||
|
Comment on lines
+36
to
+49
Contributor
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. Add defensive null checks for the API response. The code directly accesses Apply this diff to add error handling: async run({ $ }) {
const response = await this.app.searchItem({
$,
params: {
walmart_domain: this.walmartDomain,
type: "product",
item_id: this.itemId,
url: this.url,
},
});
- $.export("$summary", "Successfully retrieved data for the product with id: " + response.product.item_id);
+ if (!response?.product?.item_id) {
+ throw new Error("Invalid API response: product data not found");
+ }
+ $.export("$summary", `Successfully retrieved data for the product with id: ${response.product.item_id}`);
return response;
},🤖 Prompt for AI Agents |
||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,71 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
| import constants from "./common/constants.mjs"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "bluecart_api", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| walmartDomain: { | ||
| type: "string", | ||
| label: "Walmart Domain", | ||
| description: "The Walmart domain to target", | ||
| options: constants.DOMAIN_OPTIONS, | ||
| }, | ||
| url: { | ||
| type: "string", | ||
| label: "URL", | ||
| description: "The Walmart product page URL to retrieve results from", | ||
| optional: true, | ||
| }, | ||
| searchTerm: { | ||
| type: "string", | ||
| label: "Search Term", | ||
| description: "A search term used to find Walmart items", | ||
| }, | ||
| itemId: { | ||
| type: "string", | ||
| label: "Item ID", | ||
| description: "The Walmart Item ID to retrieve product details for. Not used if a URL is provided", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return "https://api.bluecartapi.com"; | ||
| }, | ||
| async _makeRequest(opts = {}) { | ||
| const { | ||
| $ = this, | ||
| path, | ||
| params, | ||
| ...otherOpts | ||
| } = opts; | ||
| return axios($, { | ||
| ...otherOpts, | ||
| url: this._baseUrl() + path, | ||
| params: { | ||
| api_key: `${this.$auth.api_key}`, | ||
| ...params, | ||
| }, | ||
| }); | ||
| }, | ||
| async getCategories(args = {}) { | ||
| return this._makeRequest({ | ||
| path: "/categories", | ||
| ...args, | ||
| }); | ||
| }, | ||
| async searchItem(args = {}) { | ||
| return this._makeRequest({ | ||
| path: "/request", | ||
| ...args, | ||
| }); | ||
| }, | ||
| async getAutocomplete(args = {}) { | ||
| return this._makeRequest({ | ||
| path: "/request", | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| export default { | ||
| DOMAIN_OPTIONS: [ | ||
| "walmart.com", | ||
| "walmart.ca", | ||
| ], | ||
| }; |
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.
🧩 Analysis chain
Unused prop:
walmartDomainis defined but never passed to the API.The
walmartDomainprop is defined (lines 16-21) but is not included in the API call parameters (lines 33-36). This suggests either:walmart_domainin params (similar to get-product action)Compare with get-product action which correctly passes
walmart_domain: this.walmartDomain.Please verify the BlueCart API autocomplete endpoint requirements and either:
walmartDomainprop if not neededwalmart_domain: this.walmartDomainto the params object🌐 Web query:
💡 Result:
I can't find BlueCart's autocomplete endpoint documentation online. Could you paste the exact endpoint URL or the docs page you’re using (or a sample request/response)? I’ll check and confirm whether walmart_domain is required.
I'll investigate the codebase to verify this concern.
Length of output: 1074
🏁 Script executed:
Length of output: 309
🏁 Script executed:
Length of output: 46
🏁 Script executed:
Length of output: 158
Length of output: 1080
🏁 Script executed:
Length of output: 1647
Add
walmart_domainparameter to the autocomplete API call or remove the unused prop.The
walmartDomainprop is defined (lines 16-21) but not passed to the API call (lines 33-36). The get-product action uses the same endpoint (/request) and correctly passeswalmart_domain: this.walmartDomain. For consistency and to match the API pattern, either add the parameter to the params object in get-autocomplete, or remove the unused prop definition.🤖 Prompt for AI Agents