-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] barcode_lookup #10970 #18687
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,82 @@ | ||
import app from "../../barcode_lookup.app.mjs"; | ||
|
||
export default { | ||
key: "barcode_lookup-get-products", | ||
name: "Get Products", | ||
description: "Retrieve products details by barcode, MPN, ASIN, or search terms. [See the documentation](https://www.barcodelookup.com/api-documentation#endpoints)", | ||
version: "0.0.1", | ||
annotations: { | ||
destructiveHint: false, | ||
openWorldHint: true, | ||
readOnlyHint: true, | ||
}, | ||
type: "action", | ||
props: { | ||
app, | ||
barcode: { | ||
propDefinition: [ | ||
app, | ||
"barcode", | ||
], | ||
}, | ||
mpn: { | ||
propDefinition: [ | ||
app, | ||
"mpn", | ||
], | ||
}, | ||
asin: { | ||
propDefinition: [ | ||
app, | ||
"asin", | ||
], | ||
}, | ||
title: { | ||
propDefinition: [ | ||
app, | ||
"title", | ||
], | ||
}, | ||
category: { | ||
propDefinition: [ | ||
app, | ||
"category", | ||
], | ||
}, | ||
manufacturer: { | ||
propDefinition: [ | ||
app, | ||
"manufacturer", | ||
], | ||
}, | ||
brand: { | ||
propDefinition: [ | ||
app, | ||
"brand", | ||
], | ||
}, | ||
search: { | ||
propDefinition: [ | ||
app, | ||
"search", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.getProducts({ | ||
$, | ||
params: { | ||
barcode: this.barcode, | ||
mpn: this.mpn, | ||
asin: this.asin, | ||
title: this.title, | ||
category: this.category, | ||
manufacturer: this.manufacturer, | ||
brand: this.brand, | ||
search: this.search, | ||
}, | ||
}); | ||
$.export("$summary", "Successfully retrieved " + response.products.length + " products"); | ||
return response; | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import app from "../../barcode_lookup.app.mjs"; | ||
|
||
export default { | ||
key: "barcode_lookup-get-rate-limits", | ||
name: "Get Rate Limits", | ||
description: "Retrieve the current API rate limits for your account. [See the documentation](https://www.barcodelookup.com/api-documentation#endpoints)", | ||
version: "0.0.1", | ||
annotations: { | ||
destructiveHint: false, | ||
openWorldHint: true, | ||
readOnlyHint: true, | ||
}, | ||
type: "action", | ||
props: { | ||
app, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.getRateLimits({ | ||
$, | ||
}); | ||
$.export("$summary", "Successfully retrieved the account rate limits"); | ||
return response; | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,56 +3,87 @@ import { axios } from "@pipedream/platform"; | |
export default { | ||
type: "app", | ||
app: "barcode_lookup", | ||
propDefinitions: {}, | ||
propDefinitions: { | ||
barcode: { | ||
type: "string", | ||
label: "Barcode", | ||
description: "Barcode to search, must be 7, 8, 10, 11, 12, 13 or 14 digits long, i.e.: `865694301167`", | ||
optional: true, | ||
}, | ||
mpn: { | ||
type: "string", | ||
label: "MPN", | ||
description: "Manufacturer Part Number of the product, i.e: `LXCF9407`", | ||
optional: true, | ||
}, | ||
asin: { | ||
type: "string", | ||
label: "ASIN", | ||
description: "Amazon Standard Identification Number of the product, i.e.: `B079L4WR4T`", | ||
optional: true, | ||
}, | ||
title: { | ||
type: "string", | ||
label: "Title", | ||
description: "Product title or name, i.e.: `Red Running Shoes`", | ||
optional: true, | ||
}, | ||
category: { | ||
type: "string", | ||
label: "Category", | ||
description: "Category or type of the product, i.e.: `Home & Garden > Decor`", | ||
optional: true, | ||
}, | ||
manufacturer: { | ||
type: "string", | ||
label: "Manufacturer", | ||
description: "Name of the product manufacturer, i.e.: `Samsung`", | ||
optional: true, | ||
}, | ||
brand: { | ||
type: "string", | ||
label: "Brand", | ||
description: "Brand associated with the product, i.e.: `Calvin Klein`", | ||
optional: true, | ||
}, | ||
search: { | ||
type: "string", | ||
label: "Search", | ||
description: "General search term for products, i.e.: `Air Jordan Red Shoes Size 40`", | ||
optional: true, | ||
}, | ||
}, | ||
methods: { | ||
_baseUrl() { | ||
return "https://api.barcodelookup.com/v3"; | ||
}, | ||
_params(params = {}) { | ||
return { | ||
...params, | ||
key: `${this.$auth.api_key}`, | ||
}; | ||
}, | ||
_makeRequest({ | ||
$ = this, params, path, ...opts | ||
}) { | ||
async _makeRequest(opts = {}) { | ||
const { | ||
$ = this, | ||
path, | ||
params, | ||
...otherOpts | ||
} = opts; | ||
return axios($, { | ||
...otherOpts, | ||
url: this._baseUrl() + path, | ||
params: this._params(params), | ||
...opts, | ||
params: { | ||
key: `${this.$auth.api_key}`, | ||
...params, | ||
}, | ||
}); | ||
}, | ||
searchProducts(opts = {}) { | ||
async getProducts(args = {}) { | ||
return this._makeRequest({ | ||
path: "/products", | ||
...opts, | ||
...args, | ||
}); | ||
}, | ||
async *paginate({ | ||
fn, params = {}, maxResults = null, ...opts | ||
}) { | ||
let hasMore = false; | ||
let count = 0; | ||
let page = 0; | ||
|
||
do { | ||
params.page = ++page; | ||
const { products: data } = await fn({ | ||
params, | ||
...opts, | ||
}); | ||
for (const d of data) { | ||
yield d; | ||
|
||
if (maxResults && ++count === maxResults) { | ||
return count; | ||
} | ||
} | ||
|
||
hasMore = data?.length; | ||
|
||
} while (hasMore); | ||
async getRateLimits(args = {}) { | ||
return this._makeRequest({ | ||
path: "/rate-limits", | ||
...args, | ||
}); | ||
}, | ||
Comment on lines
+76
to
87
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. 🧩 Analysis chainBreaking changes: ensure backward compatibility or update all dependents. The refactor introduces breaking changes:
Multiple existing actions in this PR still reference the old method names and will fail at runtime. Either:
As flagged in other files, the following actions need updates:
To verify all call sites have been identified, run: 🏁 Script executed: #!/bin/bash
# Search for calls to the removed/renamed methods
echo "=== Searching for searchProducts calls ==="
rg -n --type=js 'searchProducts' components/barcode_lookup/
echo -e "\n=== Searching for paginate calls ==="
rg -n --type=js '\.paginate\(' components/barcode_lookup/ Length of output: 80 🏁 Script executed: #!/bin/bash
echo "=== Searching for searchProducts calls in entire repo ==="
rg -n --type js --type mjs 'searchProducts' .
echo -e "\n=== Searching for paginate calls in entire repo ==="
rg -n --type js --type mjs '\.paginate\(' . Length of output: 166 🏁 Script executed: #!/bin/bash
echo "=== Searching for searchProducts calls across all files ==="
rg -n 'searchProducts' .
echo -e "\n=== Searching for paginate calls across all files ==="
rg -n '\.paginate\(' . Length of output: 60675 Update dependent actions after renaming searchProducts/remove paginate
|
||
}, | ||
}; |
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.
Please replace "i.e." with "e.g." in all the prop descriptions, since they're providing example values (not clarifying the actual expression)