Skip to content

Commit 81fc1e5

Browse files
authored
Merge branch 'master' into issue-10926
2 parents aa368bc + 88e141a commit 81fc1e5

File tree

7 files changed

+182
-45
lines changed

7 files changed

+182
-45
lines changed

components/barcode_lookup/actions/batch-barcode-lookup/batch-barcode-lookup.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "barcode_lookup-batch-barcode-lookup",
66
name: "Batch Barcode Lookup",
77
description: "Get multiple products by barcode. [See the documentation](https://www.barcodelookup.com/api-documentation)",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
type: "action",
1010
annotations: {
1111
destructiveHint: false,
@@ -21,7 +21,7 @@ export default {
2121
},
2222
},
2323
async run({ $ }) {
24-
const response = await this.app.searchProducts({
24+
const response = await this.app.getProducts({
2525
$,
2626
params: {
2727
barcode: parseObject(this.barcodes)?.join(","),

components/barcode_lookup/actions/get-product-by-barcode/get-product-by-barcode.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "barcode_lookup-get-product-by-barcode",
55
name: "Get Product by Barcode",
66
description: "Get a product by barcode. [See the documentation](https://www.barcodelookup.com/api-documentation)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
annotations: {
1010
destructiveHint: false,
@@ -20,7 +20,7 @@ export default {
2020
},
2121
},
2222
async run({ $ }) {
23-
const response = await this.app.searchProducts({
23+
const response = await this.app.getProducts({
2424
$,
2525
params: {
2626
barcode: this.barcode,
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import app from "../../barcode_lookup.app.mjs";
2+
3+
export default {
4+
key: "barcode_lookup-get-products",
5+
name: "Get Products",
6+
description: "Retrieve products details by barcode, MPN, ASIN, or search terms. [See the documentation](https://www.barcodelookup.com/api-documentation#endpoints)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: true,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
barcode: {
17+
propDefinition: [
18+
app,
19+
"barcode",
20+
],
21+
},
22+
mpn: {
23+
propDefinition: [
24+
app,
25+
"mpn",
26+
],
27+
},
28+
asin: {
29+
propDefinition: [
30+
app,
31+
"asin",
32+
],
33+
},
34+
title: {
35+
propDefinition: [
36+
app,
37+
"title",
38+
],
39+
},
40+
category: {
41+
propDefinition: [
42+
app,
43+
"category",
44+
],
45+
},
46+
manufacturer: {
47+
propDefinition: [
48+
app,
49+
"manufacturer",
50+
],
51+
},
52+
brand: {
53+
propDefinition: [
54+
app,
55+
"brand",
56+
],
57+
},
58+
search: {
59+
propDefinition: [
60+
app,
61+
"search",
62+
],
63+
},
64+
},
65+
async run({ $ }) {
66+
const response = await this.app.getProducts({
67+
$,
68+
params: {
69+
barcode: this.barcode,
70+
mpn: this.mpn,
71+
asin: this.asin,
72+
title: this.title,
73+
category: this.category,
74+
manufacturer: this.manufacturer,
75+
brand: this.brand,
76+
search: this.search,
77+
},
78+
});
79+
$.export("$summary", "Successfully retrieved " + response.products.length + " products");
80+
return response;
81+
},
82+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import app from "../../barcode_lookup.app.mjs";
2+
3+
export default {
4+
key: "barcode_lookup-get-rate-limits",
5+
name: "Get Rate Limits",
6+
description: "Retrieve the current API rate limits for your account. [See the documentation](https://www.barcodelookup.com/api-documentation#endpoints)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: true,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
},
17+
async run({ $ }) {
18+
const response = await this.app.getRateLimits({
19+
$,
20+
});
21+
$.export("$summary", "Successfully retrieved the account rate limits");
22+
return response;
23+
},
24+
};

components/barcode_lookup/actions/search-products-by-parameters/search-products-by-parameters.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "barcode_lookup-search-products-by-parameters",
55
name: "Search Products by Parameters",
66
description: "Search for products by parameters. [See the documentation](https://www.barcodelookup.com/api-documentation)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
annotations: {
1010
destructiveHint: false,
@@ -78,7 +78,7 @@ export default {
7878
try {
7979
const response = await this.app.paginate({
8080
$,
81-
fn: this.app.searchProducts,
81+
fn: this.app.getProducts,
8282
maxResults: this.maxResults,
8383
params: {
8484
mpn: this.mpn,

components/barcode_lookup/barcode_lookup.app.mjs

Lines changed: 69 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,87 @@ import { axios } from "@pipedream/platform";
33
export default {
44
type: "app",
55
app: "barcode_lookup",
6-
propDefinitions: {},
6+
propDefinitions: {
7+
barcode: {
8+
type: "string",
9+
label: "Barcode",
10+
description: "Barcode to search, must be 7, 8, 10, 11, 12, 13 or 14 digits long, e.g. `865694301167`",
11+
optional: true,
12+
},
13+
mpn: {
14+
type: "string",
15+
label: "MPN",
16+
description: "Manufacturer Part Number of the product, i.e: `LXCF9407`",
17+
optional: true,
18+
},
19+
asin: {
20+
type: "string",
21+
label: "ASIN",
22+
description: "Amazon Standard Identification Number of the product, e.g. `B079L4WR4T`",
23+
optional: true,
24+
},
25+
title: {
26+
type: "string",
27+
label: "Title",
28+
description: "Product title or name, e.g. `Red Running Shoes`",
29+
optional: true,
30+
},
31+
category: {
32+
type: "string",
33+
label: "Category",
34+
description: "Category or type of the product, e.g. `Home & Garden > Decor`",
35+
optional: true,
36+
},
37+
manufacturer: {
38+
type: "string",
39+
label: "Manufacturer",
40+
description: "Name of the product manufacturer, e.g. `Samsung`",
41+
optional: true,
42+
},
43+
brand: {
44+
type: "string",
45+
label: "Brand",
46+
description: "Brand associated with the product, e.g. `Calvin Klein`",
47+
optional: true,
48+
},
49+
search: {
50+
type: "string",
51+
label: "Search",
52+
description: "General search term for products, e.g. `Air Jordan Red Shoes Size 40`",
53+
optional: true,
54+
},
55+
},
756
methods: {
857
_baseUrl() {
958
return "https://api.barcodelookup.com/v3";
1059
},
11-
_params(params = {}) {
12-
return {
13-
...params,
14-
key: `${this.$auth.api_key}`,
15-
};
16-
},
17-
_makeRequest({
18-
$ = this, params, path, ...opts
19-
}) {
60+
async _makeRequest(opts = {}) {
61+
const {
62+
$ = this,
63+
path,
64+
params,
65+
...otherOpts
66+
} = opts;
2067
return axios($, {
68+
...otherOpts,
2169
url: this._baseUrl() + path,
22-
params: this._params(params),
23-
...opts,
70+
params: {
71+
key: `${this.$auth.api_key}`,
72+
...params,
73+
},
2474
});
2575
},
26-
searchProducts(opts = {}) {
76+
async getProducts(args = {}) {
2777
return this._makeRequest({
2878
path: "/products",
29-
...opts,
79+
...args,
3080
});
3181
},
32-
async *paginate({
33-
fn, params = {}, maxResults = null, ...opts
34-
}) {
35-
let hasMore = false;
36-
let count = 0;
37-
let page = 0;
38-
39-
do {
40-
params.page = ++page;
41-
const { products: data } = await fn({
42-
params,
43-
...opts,
44-
});
45-
for (const d of data) {
46-
yield d;
47-
48-
if (maxResults && ++count === maxResults) {
49-
return count;
50-
}
51-
}
52-
53-
hasMore = data?.length;
54-
55-
} while (hasMore);
82+
async getRateLimits(args = {}) {
83+
return this._makeRequest({
84+
path: "/rate-limits",
85+
...args,
86+
});
5687
},
5788
},
5889
};

components/barcode_lookup/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/barcode_lookup",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Pipedream Barcode Lookup Components",
55
"main": "barcode_lookup.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)