Skip to content
Merged
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
70 changes: 66 additions & 4 deletions components/accuweather/accuweather.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,73 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "accuweather",
propDefinitions: {},
propDefinitions: {
locationKey: {
type: "string",
label: "Location Key",
description: "The location key for the desired location. You can get this using the 'Get Location Key' action.",
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "http://dataservice.accuweather.com";
},
_params(params = {}) {
return {
apikey: `${this.$auth.api_key}`,
...params,
};
},
_makeRequest({
$ = this, params, path, ...opts
}) {
return axios($, {
url: this._baseUrl() + path,
params: this._params(params),
...opts,
});
},
searchLocation(opts = {}) {
return this._makeRequest({
path: "/locations/v1/search",
...opts,
});
},
getCurrentConditions({
locationKey, ...opts
}) {
return this._makeRequest({
path: `/currentconditions/v1/${locationKey}`,
...opts,
});
},
getDailyForecast({
days, locationKey, ...opts
}) {
return this._makeRequest({
path: `/forecasts/v1/daily/${days}day/${locationKey}`,
...opts,
});
},
getHourlyForecast({
hours, locationKey, ...opts
}) {
return this._makeRequest({
path: `/forecasts/v1/hourly/${hours}hour/${locationKey}`,
...opts,
});
},
getHistoricalWeather({
locationKey, time, ...opts
}) {
return this._makeRequest({
path: `/currentconditions/v1/${locationKey}/historical${time === 24
? "/24"
: ""}`,
...opts,
});
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import accuweather from "../../accuweather.app.mjs";

export default {
key: "accuweather-get-current-conditions",
name: "Get Current Conditions",
description: "Retrieve current weather conditions for a specific location using its location key. [See the documentation](https://developer.accuweather.com/accuweather-current-conditions-api/apis/get/currentconditions/v1/%7BlocationKey%7D)",
version: "0.0.1",
type: "action",
props: {
accuweather,
locationKey: {
propDefinition: [
accuweather,
"locationKey",
],
},
},
async run({ $ }) {
const response = await this.accuweather.getCurrentConditions({
$,
locationKey: this.locationKey,
});
$.export("$summary", `Retrieved current conditions for location key: ${this.locationKey}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import accuweather from "../../accuweather.app.mjs";
import { FORECAST_DAYS_OPTIONS } from "../../common/constants.mjs";

export default {
key: "accuweather-get-daily-forecast",
name: "Get Daily Forecast",
description: "Get daily weather forecast for a specific location with temperature, precipitation, and conditions. [See the documentation](https://developer.accuweather.com/accuweather-forecast-api/apis)",
version: "0.0.1",
type: "action",
props: {
accuweather,
locationKey: {
propDefinition: [
accuweather,
"locationKey",
],
},
forecastDays: {
type: "integer",
label: "Forecast Days",
description: "Number of days to forecast",
options: FORECAST_DAYS_OPTIONS,
},
},
async run({ $ }) {
const response = await this.accuweather.getDailyForecast({
$,
locationKey: this.locationKey,
days: this.forecastDays,
params: {
details: true,
},
});

$.export("$summary", `Retrieved forecast for ${this.forecastDays} day${this.forecastDays === 1
? ""
: "s"}`);

return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import accuweather from "../../accuweather.app.mjs";
import { HISTORICAL_TIME_OPTIONS } from "../../common/constants.mjs";

export default {
key: "accuweather-get-historical-weather",
name: "Get Historical Weather",
description: "Retrieve historical weather data for a specific location and date range. [See the documentation](https://developer.accuweather.com/accuweather-current-conditions-api/apis)",
version: "0.0.1",
type: "action",
props: {
accuweather,
locationKey: {
propDefinition: [
accuweather,
"locationKey",
],
},
historicalTime: {
type: "integer",
label: "Historical Time",
description: "Historical time for weather data",
options: HISTORICAL_TIME_OPTIONS,
},
},
async run({ $ }) {
const response = await this.accuweather.getHistoricalWeather({
$,
locationKey: this.locationKey,
time: this.historicalTime,
});

$.export("$summary", `Retrieved historical weather data for ${this.historicalTime} hours`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import accuweather from "../../accuweather.app.mjs";
import { FORECAST_HOURS_OPTIONS } from "../../common/constants.mjs";

export default {
key: "accuweather-get-hourly-forecast",
name: "Get Hourly Forecast",
description: "Retrieve hourly weather forecast (1-12 hours) for a specific location with detailed weather data. [See the documentation](https://developer.accuweather.com/accuweather-forecast-api/apis)",
version: "0.0.1",
type: "action",
props: {
accuweather,
locationKey: {
propDefinition: [
accuweather,
"locationKey",
],
},
forecastHours: {
type: "integer",
label: "Forecast Hours",
description: "Number of hours to forecast",
options: FORECAST_HOURS_OPTIONS,
},
},
async run({ $ }) {
const response = await this.accuweather.getHourlyForecast({
$,
locationKey: this.locationKey,
hours: this.forecastHours,
params: {
details: true,
},
});

$.export("$summary", `Retrieved forecast for ${this.forecastHours} hour${this.forecastHours === 1
? ""
: "s"}`);

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

export default {
key: "accuweather-get-location-key",
name: "Get Location Key",
description: "Search for a location and retrieve its unique location key required for weather API calls. [See the documentation](https://developer.accuweather.com/accuweather-locations-api/apis/get/locations/v1/search)",
version: "0.0.1",
type: "action",
props: {
accuweather,
locationQuery: {
type: "string",
label: "Location Query",
description: "Search query for location (e.g., 'New York', 'London', 'Tokyo').",
},
},
async run({ $ }) {
const response = await this.accuweather.searchLocation({
$,
params: {
q: this.locationQuery,
},
});

let summary = `Successfully found ${response.length} location${response.length === 1
? ""
: "s"}`;

if (response.length === 0) {
summary = `No location found for query: ${this.locationQuery}`;
}

$.export("$summary", summary);
return response;
},
};
32 changes: 32 additions & 0 deletions components/accuweather/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export const FORECAST_DAYS_OPTIONS = [
{
label: "1 Day",
value: 1,
},
{
label: "5 Days",
value: 5,
},
];

export const FORECAST_HOURS_OPTIONS = [
{
label: "1 Hour",
value: 1,
},
{
label: "12 Hours",
value: 12,
},
];

export const HISTORICAL_TIME_OPTIONS = [
{
label: "6 Hours",
value: 6,
},
{
label: "24 Hours",
value: 24,
},
];
7 changes: 5 additions & 2 deletions components/accuweather/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/accuweather",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream AccuWeather Components",
"main": "accuweather.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
}
11 changes: 8 additions & 3 deletions pnpm-lock.yaml

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

Loading