-
Couldn't load subscription status.
- Fork 5.5k
17131 achieva agents #18649
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
17131 achieva agents #18649
Changes from all commits
Commits
Show all changes
2 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
33 changes: 33 additions & 0 deletions
33
components/barcode_lookup/actions/batch-barcode-lookup/batch-barcode-lookup.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,33 @@ | ||
| import app from "../../barcode_lookup.app.mjs"; | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
|
|
||
| export default { | ||
| key: "barcode_lookup-batch-barcode-lookup", | ||
| name: "Batch Barcode Lookup", | ||
| description: "Get multiple products by barcode. [See the documentation](https://www.barcodelookup.com/api-documentation)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| app, | ||
| barcodes: { | ||
| type: "string[]", | ||
| label: "Barcodes", | ||
| description: "The barcodes to search for. You can also use a partial barcode followed by an asterisk (*).", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.app.searchProducts({ | ||
| $, | ||
| params: { | ||
| barcode: parseObject(this.barcodes)?.join(","), | ||
| }, | ||
| }); | ||
| $.export("$summary", "Successfully retrieved products by barcodes"); | ||
| return response; | ||
| }, | ||
| }; | ||
32 changes: 32 additions & 0 deletions
32
components/barcode_lookup/actions/get-product-by-barcode/get-product-by-barcode.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,32 @@ | ||
| import app from "../../barcode_lookup.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "barcode_lookup-get-product-by-barcode", | ||
| name: "Get Product by Barcode", | ||
| description: "Get a product by barcode. [See the documentation](https://www.barcodelookup.com/api-documentation)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| app, | ||
| barcode: { | ||
| type: "string", | ||
| label: "Barcode", | ||
| description: "The barcode to search for. You can also use a partial barcode (6 digits minimum) followed by an asterisk (*).", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.app.searchProducts({ | ||
| $, | ||
| params: { | ||
| barcode: this.barcode, | ||
| }, | ||
| }); | ||
| $.export("$summary", "Successfully retrieved product by barcode"); | ||
| return response; | ||
| }, | ||
| }; |
109 changes: 109 additions & 0 deletions
109
...ts/barcode_lookup/actions/search-products-by-parameters/search-products-by-parameters.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,109 @@ | ||
| import app from "../../barcode_lookup.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "barcode_lookup-search-products-by-parameters", | ||
| name: "Search Products by Parameters", | ||
| description: "Search for products by parameters. [See the documentation](https://www.barcodelookup.com/api-documentation)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| app, | ||
| mpn: { | ||
| type: "string", | ||
| label: "MPN", | ||
| description: "MPN parameter is the manufacturer part number. `E.g. **LXCF9407**`", | ||
| optional: true, | ||
| }, | ||
| asin: { | ||
| type: "string", | ||
| label: "ASIN", | ||
| description: "ASIN parameter is the Amazon Standard Identification Number. `E.g. **B079L4WR4T**`", | ||
| optional: true, | ||
| }, | ||
| title: { | ||
| type: "string", | ||
| label: "Title", | ||
| description: "Search by product name (title) for any item. `E.g. **Red Running Shoes**`", | ||
| optional: true, | ||
| }, | ||
| category: { | ||
| type: "string", | ||
| label: "Category", | ||
| description: "Search by category - based on [Google's product taxonomy](https://www.google.com/basepages/producttype/taxonomy.en-US.txt). `E.g. **Home & Garden > Decor**`", | ||
| optional: true, | ||
| }, | ||
| manufacturer: { | ||
| type: "string", | ||
| label: "Manufacturer", | ||
| description: "search by manufacturer - use double quotes (\"\") around value for an exact match. `E.g. **\"Samsung\"**`", | ||
| optional: true, | ||
| }, | ||
| brand: { | ||
| type: "string", | ||
| label: "Brand", | ||
| description: "Search by brand - use double quotes (\"\") around value for an exact match. `E.g. **\"Calvin Klein\"**`", | ||
| optional: true, | ||
| }, | ||
| search: { | ||
| type: "string", | ||
| label: "Search", | ||
| description: "Query all the search fields including title, category, brand and MPN. `E.g. **\"Air Jordan Red Shoes Size 40\"**`", | ||
| optional: true, | ||
| }, | ||
| geo: { | ||
| type: "string", | ||
| label: "Geo", | ||
| description: "Filter online store results by geographical location", | ||
| options: [ | ||
| "us", | ||
| "gb", | ||
| "ca", | ||
| "eu", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| maxResults: { | ||
| type: "integer", | ||
| label: "Max Results", | ||
| description: "The maximum number of results to return", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| try { | ||
| const response = await this.app.paginate({ | ||
| $, | ||
| fn: this.app.searchProducts, | ||
| maxResults: this.maxResults, | ||
| params: { | ||
| mpn: this.mpn, | ||
| asin: this.asin, | ||
| title: this.title, | ||
| category: this.category, | ||
| manufacturer: this.manufacturer, | ||
| brand: this.brand, | ||
| search: this.search, | ||
| metadata: "y", | ||
| geo: this.geo, | ||
| formatted: "y", | ||
| }, | ||
| }); | ||
|
|
||
| const responseArray = []; | ||
| for await (const item of response) { | ||
| responseArray.push(item); | ||
| } | ||
|
|
||
| $.export("$summary", `Successfully retrieved ${responseArray.length} products`); | ||
| return responseArray; | ||
| } catch (error) { | ||
| $.export("$summary", "Successfully retrieved 0 products"); | ||
| return []; | ||
| } | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| }; | ||
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 |
|---|---|---|
| @@ -1,11 +1,58 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "barcode_lookup", | ||
| propDefinitions: {}, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return "https://api.barcodelookup.com/v3"; | ||
| }, | ||
| _params(params = {}) { | ||
| return { | ||
| ...params, | ||
| key: `${this.$auth.api_key}`, | ||
| }; | ||
| }, | ||
| _makeRequest({ | ||
| $ = this, params, path, ...opts | ||
| }) { | ||
| return axios($, { | ||
| url: this._baseUrl() + path, | ||
| params: this._params(params), | ||
| ...opts, | ||
| }); | ||
| }, | ||
| searchProducts(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "/products", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| 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, | ||
| }); | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| for (const d of data) { | ||
| yield d; | ||
|
|
||
| if (maxResults && ++count === maxResults) { | ||
| return count; | ||
| } | ||
| } | ||
|
|
||
| hasMore = data?.length; | ||
|
|
||
| } while (hasMore); | ||
| }, | ||
| }, | ||
| }; | ||
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,24 @@ | ||
| export const parseObject = (obj) => { | ||
| if (!obj) return undefined; | ||
|
|
||
| if (Array.isArray(obj)) { | ||
| return obj.map((item) => { | ||
| if (typeof item === "string") { | ||
| try { | ||
| return JSON.parse(item); | ||
| } catch (e) { | ||
| return item; | ||
| } | ||
| } | ||
| return item; | ||
| }); | ||
| } | ||
| if (typeof obj === "string") { | ||
| try { | ||
| return JSON.parse(obj); | ||
| } catch (e) { | ||
| return obj; | ||
| } | ||
| } | ||
| return obj; | ||
| }; |
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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "@pipedream/barcode_lookup", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream Barcode Lookup Components", | ||
| "main": "barcode_lookup.app.mjs", | ||
| "keywords": [ | ||
|
|
@@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.1.0" | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.