Skip to content
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

New Components - tripadvisor_content_api #11403

Merged
merged 16 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 11 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
@@ -0,0 +1,37 @@
import app from "../../tripadvisor_content_api.app.mjs";

export default {
key: "tripadvisor_content_api-get-location-details",
name: "Get Location Details",
description: "Returns comprehensive information about a location. [See the documentation](https://tripadvisor-content-api.readme.io/reference/getlocationdetails)",
version: "0.0.1",
type: "action",
props: {
app,
searchQuery: {
propDefinition: [
app,
"searchQuery",
],
},
vunguyenhung marked this conversation as resolved.
Show resolved Hide resolved
locationId: {
propDefinition: [
app,
"locationId",
(c) => ({
searchQuery: c.searchQuery,
}),
],
},
},
async run({ $ }) {
const response = await this.app.getLocationDetails({
$,
locationId: this.locationId,
});

$.export("$summary", `Successfully returned the details for location '${response.name}'`);

return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import app from "../../tripadvisor_content_api.app.mjs";

export default {
key: "tripadvisor_content_api-location-reviews",
name: "Get Location Reviews",
description: "Returns up to 5 of the most recent reviews for a specific location. [See the documentation](https://tripadvisor-content-api.readme.io/reference/getlocationreviews)",
version: "0.0.1",
type: "action",
props: {
app,
locationId: {
propDefinition: [
app,
"locationId",
(c) => ({
searchQuery: c.searchQuery,
}),
],
},
},
async run({ $ }) {
const response = await this.app.getLocationReviews({
$,
locationId: this.locationId,
});

$.export("$summary", `Successfully listed ${response.data.length} of the most recent reviews for the specified location`);

return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import app from "../../tripadvisor_content_api.app.mjs";

export default {
key: "tripadvisor_content_api-location-search",
name: "Search Locations",
description: "Returns up to 10 locations found by the given search query. [See the documentation](https://tripadvisor-content-api.readme.io/reference/searchforlocations)",
version: "0.0.1",
type: "action",
props: {
app,
searchQuery: {
propDefinition: [
app,
"searchQuery",
],
},
category: {
propDefinition: [
app,
"category",
],
},
address: {
propDefinition: [
app,
"address",
],
},
},
async run({ $ }) {
const response = await this.app.searchLocations({
$,
params: {
searchQuery: this.searchQuery,
category: this.category,
address: this.address,
},
});

$.export("$summary", `Found ${response.data.length} location(s)`);

return response;
},
};
7 changes: 5 additions & 2 deletions components/tripadvisor_content_api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/tripadvisor_content_api",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Tripadvisor (Content API) Components",
"main": "tripadvisor_content_api.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.6.2"
}
}
}
89 changes: 85 additions & 4 deletions components/tripadvisor_content_api/tripadvisor_content_api.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,92 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "tripadvisor_content_api",
propDefinitions: {},
propDefinitions: {
locationId: {
type: "string",
label: "Location ID",
description: "The ID of the location",
async options({ searchQuery }) {
const { data: resources } = await this.searchLocations({
params: {
searchQuery,
},
});
return resources.map(({
location_id, name,
}) => ({
value: location_id,
label: name,
}));
},
},
searchQuery: {
type: "string",
label: "Search Query",
description: "The search query to find locations",
},
address: {
type: "string",
label: "Location Address",
description: "The address of the location",
optional: true,
},
category: {
type: "string",
label: "Location Category",
description: "The category of the location",
optional: true,
options: [
"hotels",
"attractions",
"restaurants",
"geos",
],
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.content.tripadvisor.com/api/v1";
},
_makeRequest(opts = {}) {
const {
$ = this,
path,
params,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
params: {
...params,
key: `${this.$auth.api_key}`,
},
});
},
getLocationDetails({
locationId, ...args
}) {
return this._makeRequest({
...args,
path: `/location/${locationId}/details`,
});
},
getLocationReviews({
locationId, ...args
}) {
return this._makeRequest({
...args,
path: `/location/${locationId}/reviews`,
});
},
searchLocations(args = {}) {
return this._makeRequest({
...args,
path: "/location/search",
});
},
},
};
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading