- About The Project
- Learning Goals
- Skills Developed
- Built With
- Setup Instructions
- Endpoint Documentation
- Author and Contact Information
Whether Sweater A service-oriented architecture design software application project for the Turing School of Software & Design which provides API endpoints for a hypothetical application used to plan road trips.
PROJECT requirement specifications Turing's original project requirements.
- Expose an API that aggregates data from multiple external APIs
- Expose an API that requires an authentication token
- Expose an API for CRUD functionality
- Determine completion criteria based on the needs of other developers
- Research, select, and consume an API based on your needs as a developer
- Practiced MVC concepts, effectively staying within rails conventions
- Consumed multiple API endpoints and utilized POROS and Serializers as a way to apply OOP principals
- Implemented user authentication and authorized sessions.
- Employed test driven development TDD to achieve project goals.
To download a local copy please follow the below steps.
- Clone the repo
git clone https://github.com/jhennerich/whether_sweater
- Install dependencies
bundle install
- DB creation/migration
rails db:create rails db:migrate
- Install figaro: creates a local config/application.yml file
bundle exec figaro install
- Obtain and install required API keys in application.yml
- MapQuest's Geocoding API
application.yml value mapquest_api_key
- OpenWeather One Call API
application.yml value openweather_appid
- Unsplash
application.yml value unsplash_api_key
- Run tests and view test coverage
bundle exec rspec open coverage/index.html
- Run server and navigate to http://localhost:3000/
rails s
GET http://localhost:3000/api/v1/forecast?location=denver,co
- Example results
{ "data": { "id": null, "type": "forecast", "attributes": { "current_weather": { "datetime": "2022-06-14T23:24:54.000+00:00", "sunrise": "2022-06-14T11:31:26.000+00:00", "sunset": "2022-06-15T02:29:10.000+00:00", "temperature": 82.81, "feels_like": 80.58, "humidity": 23, "uvi": 2.79, "visibility": 10000, "conditions": "few clouds", "icon": "02d" }, "daily_weather": [ { "date": "2022:06:14", "sunrise": "2022-06-14T11:31:26.000+00:00", "sunset": "2022-06-15T02:29:10.000+00:00", "max_temp": 83.26, "min_temp": 61.21, "conditions": "few clouds", "icon": "02d" }, { "date": "2022:06:15", "sunrise": "2022-06-15T11:31:27.000+00:00", "sunset": "2022-06-16T02:29:34.000+00:00", "max_temp": 87.67, "min_temp": 57.18, "conditions": "clear sky", "icon": "01d" }, { "date": "2022:06:16", "sunrise": "2022-06-16T11:31:29.000+00:00", "sunset": "2022-06-17T02:29:55.000+00:00", "max_temp": 94.44, "min_temp": 65.21, "conditions": "clear sky", "icon": "01d" }, { "date": "2022:06:17", "sunrise": "2022-06-17T11:31:33.000+00:00", "sunset": "2022-06-18T02:30:15.000+00:00", "max_temp": 96.13, "min_temp": 70.36, "conditions": "clear sky", "icon": "01d" }, { "date": "2022:06:18", "sunrise": "2022-06-18T11:31:39.000+00:00", "sunset": "2022-06-19T02:30:34.000+00:00", "max_temp": 97.43, "min_temp": 71.62, "conditions": "scattered clouds", "icon": "03d" } ], "hourly_weather": [ { "time": "23:00:00", "temperature": 82.81, "conditions": "few clouds", "icon": "02d" }, { "time": "00:00:00", "temperature": 83.05, "conditions": "few clouds", "icon": "02d" }, { "time": "01:00:00", "temperature": 82.63, "conditions": "few clouds", "icon": "02d" }, { "time": "02:00:00", "temperature": 80.29, "conditions": "few clouds", "icon": "02d" }, { "time": "03:00:00", "temperature": 74.61, "conditions": "few clouds", "icon": "02n" }, { "time": "04:00:00", "temperature": 68.13, "conditions": "clear sky", "icon": "01n" }, { "time": "05:00:00", "temperature": 64.58, "conditions": "clear sky", "icon": "01n" }, { "time": "06:00:00", "temperature": 63.09, "conditions": "clear sky", "icon": "01n" } ] } } }
GET http://localhost:3000/api/v1/backgrounds?location=denver,co
- Example results
{ "data": { "id": null, "type": "image", "attributes": { "image": { "location": "denver, co", "image_url": "https://images.unsplash.com/photo-1629163330223-c183571735a1?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwzMzY5NDN8MHwxfHNlYXJjaHwxfHxkZW52ZXIlMkMlMjBjb3xlbnwwfHx8fDE2NTUyNDkzNzg&ixlib=rb-1.2.1&q=80&w=1080", "credit": { "source": "https://api.unsplash.com/photos/zSm5JPgNeuc", "author": "Taylor Daugherty" } } } } }
POST http://localhost:3000/api/v1/users
- Please note you must call this endpoint with a JSON Body
{
"email":"[email protected]",
"password":"password",
"password_confirmation":"password"
}
- Example results
{
"data": {
"id": "2",
"type": "users",
"attributes": {
"email": "[email protected]",
"api_key": "8ed75a909699057ddd8f4d4c12a1e110"
}
}
}
POST http://localhost:3000/api/v1/sessions
- Please note you must call this endpoint with a JSON Body
{
"email":"[email protected]",
"password":"password",
"password_confirmation":"password"
}
- Example results
{
"data": {
"id": "1",
"type": "users",
"attributes": {
"email": "[email protected]",
"api_key": "6cd1a7e46b1e465816d7c44f00d12fa0"
}
}
}
POST http://localhost:3000/api/v1/road_trip
- Please note you must call this endpoint with a JSON Body
{
"origin":"Denver, CO",
"destination":"St. Louis, MO",
"api_key": "1105647f94680eb28e4d929bf1012ca0"
}
- Example results
{
"data": {
"id": null,
"type": "roadtrip",
"attributes": {
"start_city": "Denver, CO",
"end_city": "St. Louis, MO",
"road_trip_time": "12 hours, 7 minutes, and 23 seconds",
"weather_at_eta": {
"temperature": 96.42,
"conditions": "clear sky"
}
}
}
}
- John Hennerich - Turing Student - GitHub Profile - LinkedIn