This is a Back End Application that exposes 4 endpoints. 3 external API keys are required for this application to function properly.
Never be surprised by weather on your RoadTrip again. Sweater Weather is a weather application where a user can see the current weather and forecasted weather of a specific location. A registered user can plan a roadtrip and see how long the trip will take and the weather upon arrival to their destination.
- Rails 7.0.4
- Ruby 3.1.1
To get a local copy, follow these instructions
- Fork the Project
- Clone the repo
#terminal
[email protected]:AlecKap/whether-sweater.git
- Navigate to the newly cloned repo and open it in your text editor of choice
- Install the gems
#terminal
bundle install
- Create the database
#terminal
rails db:{create,migrate}
- Create application.yml
#terminal
bundle exec figaro install
- Add environment variables to application.yml file
- Navigate to the application.yml file in the config directory
- Add the following to the file
#application.yml
MAPQUEST_API_KEY: <your key here>
WEATHER_API_KEY: <your key here>
- Get your MapQuest api key from https://developer.mapquest.com/documentation/
- Get your Weather api key from https://www.weatherapi.com/
- Run Tests in the terminal to verify everything was set up correctly
#terminal
bundle exec rspec
- All tests should be passing
- Run Rails Server from the terminal to verify you can successfully hit the endpoints
#terminal
rails s
- Test the endpoints
- You can utilize Postman or VScodes Thunderclient to test the endpoints are running properly
- Append
http://localhost:3000
to each of the endpoints listed below.
get 'api/v0/forecast'
post 'api/v0/users'
post 'api/v0/sessions'
post 'api/v0/road_trip'
get http://localhost:3000/api/v0/forecast?location=denver,co
"data": {
"id": null,
"type": "forecast",
"attributes": {
"current_weather": {
"last_updated": "2023-06-12 19:45",
"temperature": 54.0,
"feels_like": 54.8,
"humidity": 80,
"uvi": 4.0,
"visibility": 9.0,
"conditions": "Partly cloudy",
"icon": "//cdn.weatherapi.com/weather/64x64/day/116.png"
},
"daily_weather": [
{
"date": "2023-06-13",
"sunrise": "05:32 AM",
"sunset": "08:29 PM",
"max_temp": 61.0,
"min_temp": 52.5,
"conditions": "Heavy rain",
"icon": "//cdn.weatherapi.com/weather/64x64/day/308.png"
},
{
"date": "2023-06-14",
"sunrise": "05:32 AM",
"sunset": "08:29 PM",
"max_temp": 83.1,
"min_temp": 48.9,
"conditions": "Patchy rain possible",
"icon": "//cdn.weatherapi.com/weather/64x64/day/176.png"
},
etc... for the next 3 days
],
"hourly_weather": [
{
"time": "00:00",
"temperature": 54.1,
"conditions": "Moderate rain at times",
"icon": "//cdn.weatherapi.com/weather/64x64/night/299.png"
},
{
"time": "01:00",
"temperature": 53.8,
"conditions": "Partly cloudy",
"icon": "//cdn.weatherapi.com/weather/64x64/night/116.png"
},
{
"time": "02:00",
"temperature": 53.4,
"conditions": "Cloudy",
"icon": "//cdn.weatherapi.com/weather/64x64/night/119.png"
},
etc... for the remaining 24 hours
]
}
}
}
post http://localhost:3000/api/v0/users
# in the body of the request, send
{
"email": "[email protected]",
"password": "password",
"password_confirmation": "password"
}
{
"data": {
"id": "3",
"type": "users",
"attributes": {
"email": "[email protected]",
"api_key": "61e82e95170d1a917904be3967"
}
}
}
post http://localhost/api/v0/sessions
# in the body of the request, send
{
"email": "[email protected]",
"password": "password"
}
{
"data": {
"type": "users",
"id": "1",
"attributes": {
"email": "[email protected]",
"api_key": "t1h2i3s4_i5s6_l7e8g9i10t11"
}
}
}
post http://localhost/api/v0/road_trip
#in the body of the request send
{
"origin": "Cincinatti,OH",
"destination": "Chicago,IL",
"api_key": "<your_api_key>"
}
{
"data": {
"id": "null",
"type": "road_trip",
"attributes": {
"start_city": "Cincinatti, OH",
"end_city": "Chicago, IL",
"travel_time": "04:40:45",
"weather_at_eta": {
"datetime": "2023-04-07 23:00",
"temperature": 44.2,
"condition": "Cloudy with a chance of meatballs"
}
}
}
}
create_table "users", force: :cascade do |t|
t.string "email"
t.string "password_digest"
t.string "api_key"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
- MapQuest API (for directions)
- Weather API (for weather information)