-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] AccuWeather #17509 #17700
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
26 changes: 26 additions & 0 deletions
26
components/accuweather/actions/get-current-conditions/get-current-conditions.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }; |
41 changes: 41 additions & 0 deletions
41
components/accuweather/actions/get-daily-forecast/get-daily-forecast.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }; |
35 changes: 35 additions & 0 deletions
35
components/accuweather/actions/get-historical-weather/get-historical-weather.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }; |
41 changes: 41 additions & 0 deletions
41
components/accuweather/actions/get-hourly-forecast/get-hourly-forecast.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }; |
36 changes: 36 additions & 0 deletions
36
components/accuweather/actions/get-location-key/get-location-key.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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": [ | ||
|
|
@@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.1.0" | ||
| } | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.