Sweater Weather was built to be used as a backend application that the frontend will then communicate with in order to get the necessary information. The overall application is for planning road trips, and will allow users to see the current weather as well as the forecasted weather at the destination. The frontend communicates with this backend piece through an API, which the backend then exposes the infomation coming from the APIs in the proper format that satisfies the frontend team's requirments.
·
Report Bug
·
Request Feature
Three APIs were used in this project in order to obtain the required information. All weather data is coming from the Open Weather one call API. The MapQuest API was used in order to obtain latitude and longitude coordinates for a city that were then used to query the Open Weather API. Finally the Upsplash API was used in order to provide the frontend with a backgroud image of a specified city.
example: http://localhost:3000/api/v1/forecast?location=denver,co
{
"data": {
"id": null,
"type": "forecast",
"attributes": {
"current_weather": {
"datetime": "2021-01-20T07:46:12.000-07:00",
"sunrise": "2021-01-20T07:16:35.000-07:00",
"sunset": "2021-01-20T17:05:12.000-07:00",
"temperature": 30.660000000000025,
"feels_like": 25.400000000000034,
"humidity": 49,
"uvi": 0.19,
"visibility": 10000,
"conditions": "clear sky",
"icon": "01d"
},
"daily_weather": [
{
"date": "2021-01-20",
"sunrise": "2021-01-20T14:16:35.000+00:00",
"sunset": "2021-01-21T00:05:12.000+00:00",
"max_temp": 42.379999999999995,
"min_temp": 30.660000000000025,
"conditions": "clear sky",
"icon": "01d"
},
{...} etc
],
"hourly_weather": [
{
"time": "07:01",
"temperature": 30.660000000000025,
"wind_speed": "6.89 mph",
"wind_direction": "from SSW",
"conditions": "clear sky",
"icon": "01n"
},
{...} etc
]
}
}
}
example: http://localhost:3000/api/v1/backgrounds?location=denver,co
{
"data": {
"id": null,
"type": "image",
"attributes": {
"image": {
"location": "denver,co",
"image_url": "https://images.unsplash.com/photo-1600041161228-519e6dd27bac?crop=entropy&cs=srgb&fm=jpg&ixid=MXwxOTkzMjd8MHwxfHNlYXJjaHwxfHxkZW52ZXIsY298ZW58MHx8fA&ixlib=rb-1.2.1&q=85",
"raw_image_url": "https://images.unsplash.com/photo-1600041161228-519e6dd27bac?ixid=MXwxOTkzMjd8MHwxfHNlYXJjaHwxfHxkZW52ZXIsY298ZW58MHx8fA&ixlib=rb-1.2.1",
"credit": {
"source": "https://unsplash.com",
"author": "Michael Kilcoyne",
"author_profile": "https://unsplash.com/@mikekilcoyne"
}
}
}
}
}
example: http://localhost:3000/api/v1/users
body: { "email": "whatever@example.com", "password": "password", "password_confirmation": "password" }
{
"data": {
"type": "users",
"id": "1",
"attributes": {
"email": "whatever@example.com",
"api_key": "jgn983hy48thw9begh98h4539h4"
}
}
}
example: http://localhost:3000/api/v1/sessions
body: { "email": "whatever@example.com", "password": "password" }
{
"data": {
"type": "users",
"id": "1",
"attributes": {
"email": "whatever@example.com",
"api_key": "jgn983hy48thw9begh98h4539h4"
}
}
}
example: http://localhost:3000/api/v1/road_trip
body: { "origin": "Denver,CO", "destination": "Pueblo,CO", "api_key": "jgn983hy48thw9begh98h4539h4" }
{
"data": {
"id": null,
"type": "roadtrip",
"attributes": {
"start_city": "Denver, CO",
"end_city": "Pueblo, CO",
"travel_time": "01 hours, 44 minutes",
"weather_at_eta": {
"temperature": 27.100000000000023,
"conditions": "clear sky"
}
}
}
}
To use this locally, you can fork or clone this repo.
git clone git@github.com:s-steel/sweater_weather.git
cd sweater_weather
bundle install
rake db:{create,migrate,seed}
rails s
From here you can make api calls to your local server. I recommend using Postman in order to make these call and see the results.
Sweater Weather has been fully tested. To view the test coverage;
Once inside your terminal within the Sweater Weather directory run the following command.
open coverage
This will open up a folder with an index.html file. Clicking on this file will show you a list of all lines of code within this project, and whether they have been tested or not.
Additionally, running bundle exec rspec
will show you the quick summary of the test coverage in this application.
See the open issues for a list of proposed features, known issues, and project extensions.
Contributions are what make this community such an amazing and fun place to learn, grow, and create! Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch
git checkout -b feature/NewGreatFeature
- Commit your Changes
git commit -m 'Add some NewGreatFeature'
- Push to the Branch
git push origin feature/NewGreatFeature
- Open a new Pull Request!
Sean Steel - - GitHub
Project Link: Sweater Weather