Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
@@ -0,0 +1,41 @@
import app from "../../bluecart_api.app.mjs";

export default {
key: "bluecart_api-get-autocomplete",
name: "Get Autocomplete",
description: "Get autocomplete suggestions for the specified search term. [See the documentation](https://docs.trajectdata.com/bluecartapi/walmart-product-data-api/parameters/autocomplete)",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
type: "action",
props: {
app,
walmartDomain: {
propDefinition: [
app,
"walmartDomain",
],
},
searchTerm: {
propDefinition: [
app,
"searchTerm",
],
description: "The search term to get autocomplete suggestions for",
},
},
async run({ $ }) {
const response = await this.app.getAutocomplete({
$,
params: {
searchTerm: this.searchTerm,
type: "autocomplete",
},
});
$.export("$summary", "Successfully retrieved " + response.autocomplete_results.length + " suggestions");
return response;
},
};
34 changes: 34 additions & 0 deletions components/bluecart_api/actions/get-categories/get-categories.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import app from "../../bluecart_api.app.mjs";

export default {
key: "bluecart_api-get-categories",
name: "Get Categories",
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)",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
type: "action",
props: {
app,
searchTerm: {
propDefinition: [
app,
"searchTerm",
],
description: "The term used to search for categories",
},
},
async run({ $ }) {
const response = await this.app.getCategories({
$,
params: {
search_term: this.searchTerm,
},
});
$.export("$summary", "Successfully retrieved " + response.categories.length + " categories");
return response;
},
};
50 changes: 50 additions & 0 deletions components/bluecart_api/actions/get-product/get-product.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import app from "../../bluecart_api.app.mjs";

export default {
key: "bluecart_api-get-product",
name: "Get product",
description: "Get product data from Walmart. [See the documentation](https://docs.trajectdata.com/bluecartapi/walmart-product-data-api/parameters/product)",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
type: "action",
props: {
app,
walmartDomain: {
propDefinition: [
app,
"walmartDomain",
],
},
url: {
propDefinition: [
app,
"url",
],
},
itemId: {
propDefinition: [
app,
"itemId",
],
},
},

async run({ $ }) {
const response = await this.app.searchItem({
$,
params: {
walmart_domain: this.walmartDomain,
type: "product",
item_id: this.itemId,
url: this.url,
},
});

$.export("$summary", "Successfully retrieved data for the product with id: " + response.product.item_id);
return response;
},
};
70 changes: 65 additions & 5 deletions components/bluecart_api/bluecart_api.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,71 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "bluecart_api",
propDefinitions: {},
propDefinitions: {
walmartDomain: {
type: "string",
label: "Walmart Domain",
description: "The Walmart domain to target",
options: constants.DOMAIN_OPTIONS,
},
url: {
type: "string",
label: "URL",
description: "The Walmart product page URL to retrieve results from",
optional: true,
},
searchTerm: {
type: "string",
label: "Search Term",
description: "A search term used to find Walmart items",
},
itemId: {
type: "string",
label: "Item ID",
description: "The Walmart Item ID to retrieve product details for. Not used if a URL is provided",
optional: true,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.bluecartapi.com";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
params,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
params: {
api_key: `${this.$auth.api_key}`,
...params,
},
});
},
async getCategories(args = {}) {
return this._makeRequest({
path: "/categories",
...args,
});
},
async searchItem(args = {}) {
return this._makeRequest({
path: "/request",
...args,
});
},
async getAutocomplete(args = {}) {
return this._makeRequest({
path: "/request",
...args,
});
},
},
};
};
6 changes: 6 additions & 0 deletions components/bluecart_api/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
DOMAIN_OPTIONS: [
"walmart.com",
"walmart.ca",
],
};
5 changes: 4 additions & 1 deletion components/bluecart_api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/bluecart_api",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream BlueCart API Components",
"main": "bluecart_api.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.1"
}
}
Loading
Loading