Sweater Weather is an api backend designed to help people plan road trips. The app allows users to register and log in, see weather forecasts for any city, as well as the forecast for their roadtrip destination at their ETA.
This application consumes the following APIs:
To use this application:
- Fork this repository
- Clone your fork
- From the command line, install gems and set up your DB:
bundle installrails db:{create,migrate}
- To setup gems:
bundle exec figaro install- Store API keys in
/config/application.ymlas: mapquest_key: <YOUR-KEY-HERE>openweather_key: <YOUR-KEY-HERE>unsplash_access_key: <YOUR-KEY-HERE>
- Run the test suite with
bundle exec rspec - Run your development server with
rails sto see the app in action.
GET /api/v1/forecast?location=<LOCATION>
Example JSON response:
{
"data": {
"id": null,
"type": "forecast",
"attributes": {
"current_weather": {
"datetime": "2021-11-16T22:13:08.000-07:00",
"temperature": 47.75,
"sunrise": "2021-11-16T06:46:09.000-07:00",
"sunset": "2021-11-16T16:43:41.000-07:00",
"feels_like": 47.14,
"humidity": 41,
"uvi": 0,
"visibility": 10000,
"conditions": "clear sky",
"icon": "01n"
},
"daily_weather": [
{
"date": "2021-11-16",
"sunrise": "2021-11-16T06:46:09.000-07:00",
"sunset": "2021-11-16T16:43:41.000-07:00",
"min_temp": 46.47,
"max_temp": 67.98,
"conditions": "overcast clouds",
"icon": "04d"
},
...
],
"hourly_weather": [
{
"time": "22:00:00",
"temp": 47.75,
"conditions": "clear sky",
"icon": "01n"
},
...
]
}
}
}
GET /api/v1/backgrounds?location=<LOCATION>
Example JSON response:
{
"data": {
"type": "image",
"id": null,
"attributes": {
"image": {
"location": "denver,co",
"image_url": "https://images.unsplash.com/photo-1634507307799-ace9b49840b7?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwyNzU2ODB8MHwxfHNlYXJjaHwxfHxkZW52ZXIlMkNjb3xlbnwwfHx8fDE2MzcwOTAxNzc&ixlib=rb-1.2.1&q=80&w=1080",
"credit": {
"source": "unsplash.com",
"author": "Dillon Wanner"
}
}
}
}
}
POST /api/v1/users
Content-Type: application/json
Accept: application/json
body:
{
"email": "whatever@example.com",
"password": "password",
"password_confirmation": "password"
}
Example JSON response:
{
"data": {
"type": "user",
"id": 1,
"attributes": {
"email": "whatever@example.com",
"api_key": "12345"
}
}
}
POST /api/v1/sessions
Content-Type: application/json
Accept: application/json
body:
{
"email": "whatever@example.com",
"password": "password"
}
Example JSON response:
{
"data": {
"type": "user",
"id": 1,
"attributes": {
"email": "whatever@example.com",
"api_key": "12345"
}
}
}
POST /api/v1/road_trip
Content-Type: application/json
Accept: application/json
body:
{
"origin": "Denver,CO",
"destination": "Pueblo,CO",
"api_key": "12345"
}
Example JSON response:
{
"data": {
"id": null,
"type": "roadtrip",
"attributes": {
"start_city": "Denver,CO",
"end_city": "Pueblo,CO",
"travel_time": "01:45:23",
"weather_at_eta": {
"temperature": 52.16,
"conditions": "clear sky"
}
}
}
}
- Ruby 2.7.2
- Rails 5.2.5
- Rowan DeLong
- rowanwinzer@gmail.com