Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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",
version: "0.0.2",
type: "action",
annotations: {
destructiveHint: false,
Expand All @@ -21,7 +21,7 @@ export default {
},
},
async run({ $ }) {
const response = await this.app.searchProducts({
const response = await this.app.getProducts({
$,
params: {
barcode: parseObject(this.barcodes)?.join(","),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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",
version: "0.0.2",
type: "action",
annotations: {
destructiveHint: false,
Expand All @@ -20,7 +20,7 @@ export default {
},
},
async run({ $ }) {
const response = await this.app.searchProducts({
const response = await this.app.getProducts({
$,
params: {
barcode: this.barcode,
Expand Down
82 changes: 82 additions & 0 deletions components/barcode_lookup/actions/get-products/get-products.mjs
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
Expand Up @@ -4,7 +4,7 @@ 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",
version: "0.0.2",
type: "action",
annotations: {
destructiveHint: false,
Expand Down Expand Up @@ -78,7 +78,7 @@ export default {
try {
const response = await this.app.paginate({
$,
fn: this.app.searchProducts,
fn: this.app.getProducts,
maxResults: this.maxResults,
params: {
mpn: this.mpn,
Expand Down
107 changes: 69 additions & 38 deletions components/barcode_lookup/barcode_lookup.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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, e.g. `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, e.g. `B079L4WR4T`",
optional: true,
},
title: {
type: "string",
label: "Title",
description: "Product title or name, e.g. `Red Running Shoes`",
optional: true,
},
category: {
type: "string",
label: "Category",
description: "Category or type of the product, e.g. `Home & Garden > Decor`",
optional: true,
},
manufacturer: {
type: "string",
label: "Manufacturer",
description: "Name of the product manufacturer, e.g. `Samsung`",
optional: true,
},
brand: {
type: "string",
label: "Brand",
description: "Brand associated with the product, e.g. `Calvin Klein`",
optional: true,
},
search: {
type: "string",
label: "Search",
description: "General search term for products, e.g. `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,
});
},
},
};
2 changes: 1 addition & 1 deletion components/barcode_lookup/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/barcode_lookup",
"version": "0.1.0",
"version": "0.2.0",
"description": "Pipedream Barcode Lookup Components",
"main": "barcode_lookup.app.mjs",
"keywords": [
Expand Down
Loading