Skip to content

Commit 2cf74d8

Browse files
authored
Fixed errors on bluecart_api deploy (#19225)
* Fixed errors * Fixed errors * Fixed errors * Fixed errors
1 parent 8af1783 commit 2cf74d8

File tree

5 files changed

+96
-17
lines changed

5 files changed

+96
-17
lines changed

components/bluecart_api/actions/get-autocomplete/get-autocomplete.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "bluecart_api-get-autocomplete",
55
name: "Get Autocomplete",
66
description: "Get autocomplete suggestions for the specified search term. [See the documentation](https://docs.trajectdata.com/bluecartapi/walmart-product-data-api/parameters/autocomplete)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,
@@ -31,7 +31,7 @@ export default {
3131
const response = await this.app.getAutocomplete({
3232
$,
3333
params: {
34-
searchTerm: this.searchTerm,
34+
search_term: this.searchTerm,
3535
type: "autocomplete",
3636
},
3737
});

components/bluecart_api/actions/get-categories/get-categories.mjs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "bluecart_api-get-categories",
55
name: "Get Categories",
66
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)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,
@@ -22,13 +22,32 @@ export default {
2222
},
2323
},
2424
async run({ $ }) {
25-
const response = await this.app.getCategories({
26-
$,
27-
params: {
28-
search_term: this.searchTerm,
29-
},
30-
});
31-
$.export("$summary", "Successfully retrieved " + response.categories.length + " categories");
32-
return response;
25+
try {
26+
const response = await this.app.getCategories({
27+
$,
28+
params: {
29+
search_term: this.searchTerm,
30+
},
31+
});
32+
33+
$.export("$summary", "Successfully retrieved " + response.categories.length + " categories");
34+
return response;
35+
36+
} catch (err) {
37+
if (
38+
err?.response?.status === 400 &&
39+
err?.response?.data?.request_info?.message?.includes("No categories match")
40+
) {
41+
const message = err.response.data.request_info.message;
42+
43+
$.export("$summary", message);
44+
return {
45+
success: false,
46+
categories: [],
47+
message,
48+
};
49+
}
50+
throw err;
51+
}
3352
},
3453
};

components/bluecart_api/actions/get-product/get-product.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "bluecart_api-get-product",
55
name: "Get product",
66
description: "Get product data from Walmart. [See the documentation](https://docs.trajectdata.com/bluecartapi/walmart-product-data-api/parameters/product)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,
Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,71 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
14
export default {
25
type: "app",
36
app: "bluecart_api",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
walmartDomain: {
9+
type: "string",
10+
label: "Walmart Domain",
11+
description: "The Walmart domain to target",
12+
options: constants.DOMAIN_OPTIONS,
13+
},
14+
url: {
15+
type: "string",
16+
label: "URL",
17+
description: "The Walmart product page URL to retrieve results from",
18+
optional: true,
19+
},
20+
searchTerm: {
21+
type: "string",
22+
label: "Search Term",
23+
description: "A search term used to find Walmart items",
24+
},
25+
itemId: {
26+
type: "string",
27+
label: "Item ID",
28+
description: "The Walmart Item ID to retrieve product details for. Not used if a URL is provided",
29+
optional: true,
30+
},
31+
},
532
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
33+
_baseUrl() {
34+
return "https://api.bluecartapi.com";
35+
},
36+
async _makeRequest(opts = {}) {
37+
const {
38+
$ = this,
39+
path,
40+
params,
41+
...otherOpts
42+
} = opts;
43+
return axios($, {
44+
...otherOpts,
45+
url: this._baseUrl() + path,
46+
params: {
47+
api_key: this.$auth.api_key,
48+
...params,
49+
},
50+
});
51+
},
52+
async getCategories(args = {}) {
53+
return this._makeRequest({
54+
path: "/categories",
55+
...args,
56+
});
57+
},
58+
async searchItem(args = {}) {
59+
return this._makeRequest({
60+
path: "/request",
61+
...args,
62+
});
63+
},
64+
async getAutocomplete(args = {}) {
65+
return this._makeRequest({
66+
path: "/request",
67+
...args,
68+
});
969
},
1070
},
1171
};

components/bluecart_api/package.json

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

0 commit comments

Comments
 (0)