- What it does
- How to Install Sweater Weather
- Endpoints
- Schema
- Dependencies
- Testing
- Learning Goals
- Licenses
- Contact
- Acknowledgments
An API that drives the front-end Sweater Weather App. This application not only allows you plan a roadtrip to a city of your choosing, but also will get you up to date on the weather conditions of that city.
For usage on your local machine follow the instructions listed below:
- In your local environment:
git clone [email protected]:GeorgieGirl24/sweater-weather.git
cd
bundle install
rake db:{create,migrate}
figaro install
- Retrieve API keys:
- OpenWeatherMap (Please use to OpenWeather API documentation)
- MapQuest (Please use to MapQuest API documentation)
- Unsplash (Please use to Unsplash API documentation)
- Please make sure that after
application.yml
is created that you include the follwing keys:
WEATHER_API_KEY: <Your API Key>
IMAGE_API_KEY: <Your API Key>
MAP_API_KEY: <Your API Key>
WEATHER_API_HOST: 'http://api.openweathermap.org'
MAP_API_HOST: 'http://www.mapquestapi.com'
IMAGE_API_HOST: 'https://api.unsplash.com'
- Open a new tab in the terminal and run:
rails s
- In a web browser, navigate to
http://localhost:3000
to any of theGET
routes in this repo
- All Endpoints are formatted to JSON guidelines
This is an example of a successfull response in Postman:
GET /api/v1/forecast?location=denver,co
Content-Type: application/json
Accept: application/json
{
"data": {
"id": null,
"type": "forecast",
"attributes": {
"current_weather": {
"datetime": "2021-01-20T00:28:40.000-07:00",
"sunrise": "2021-01-20T07:17:17.000-07:00",
"sunset": "2021-01-20T17:05:57.000-07:00",
"temperature": 26.55,
"feels_like": 17.26,
"humidity": 56,
"uvi": 0,
"visibility": 10000,
"conditions": "clear sky",
"icon": "01n"
},
"daily_weather": [
{
"date": "2021-01-20",
"sunrise": "2021-01-20T07:17:17.000-07:00",
"sunset": "2021-01-20T17:05:57.000-07:00",
"max_temp": 47.53,
"min_temp": 26.55,
"conditions": "clear sky",
"icon": "01d"
},
{
"date": "2021-01-21",
"sunrise": "2021-01-21T07:16:42.000-07:00",
"sunset": "2021-01-21T17:07:06.000-07:00",
"max_temp": 43,
"min_temp": 34.09,
"conditions": "overcast clouds",
"icon": "04d"
},...
],
"hourly_weather": [
{
"time": "00:00:00",
"temperature": 26.55,
"wind_speed": "6.6 mph",
"wind_direction": "from WSW",
"conditions": "clear sky",
"icon": "01n"
},...
]
}
}
}
This is an example of a successfull response in Postman:
GET /api/v1/backgrounds?location=denver,co
Content-Type: application/json
Accept: application/json
{
"data": {
"id": null,
"type": "image",
"attributes": {
"image": {
"image_url": "https://images.unsplash.com/photo-1519424187720-db6d0fc5a5d2?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MXwxOTkxNTl8MHwxfHNlYXJjaHwxfHwlN0IlMjJsb2NhdGlvbiUyMj0lM0UlMjJkZW52ZXIsY28lMjIlN0R8ZW58MHx8fA&ixlib=rb-1.2.1&q=80&w=1080",
"link": "https://unsplash.com/photos/chaqHXlOzYs"
},
"credit": {
"source": "https://unsplash.com/",
"artist": "Owen Lystrup",
"artist_link": "https://unsplash.com/@owencavlys"
}
}
}
}
This is an example of a successfull response in Postman:
POST /api/v1/users
Content-Type: application/json
Accept: application/json
JSON request body
{
"email": "[email protected]",
"password": "password",
"password_confirmation": "password"
}
{
"data": {
"id": "6",
"type": "users",
"attributes": {
"email": "[email protected]",
"api_key": "3uqJRZzgHKutjOmYBiKWLwtt"
}
}
}
Some links to check out for unsuccessful responses:
- User Error: Email already exsists
- User Error: Email already exsists
- User Error: Passwords Dont Match
- User Error: Email is left blank
This is an example of a successfull response in Postman:
POST /api/v1/sessions
Content-Type: application/json
Accept: application/json
JSON request body
{
"email": "[email protected]",
"password": "password"
}
{
"data": {
"id": "2",
"type": "users",
"attributes": {
"email": "[email protected]",
"api_key": "slDxY2LlnLsKTI85VJdJ4Att"
}
}
}
Some links to check out for unsuccessful responses:
This is an example of a successfull response in Postman:
POST /api/v1/road_trip
Content-Type: application/json
Accept: application/json
JSON request body
{
"origin": "Denver,CO",
"destination": "Pueblo,CO",
"api_key": "GTWzPl3kxUSBxaCRqiCTOQtt"
}
{
"data": {
"id": null,
"type": "roadtrip",
"attributes": {
"start_city": "Denver,CO",
"end_city": "Pueblo,CO",
"travel_time": "01:44:22",
"weather_at_eta": {
"temperature": 36.95,
"conditions": "light rain"
}
}
}
}
Some links to checkout other responses:
- Users is the only table in the database. It hold an email, password_digest, and api key
- figaro
- faraday
- fast_jsonapi
- webmock
- vcr
- shoulda-matchers
- simplecov
-
Fully tested with RSpec
-
RSpec is a tool for unit testing that will ensure there is the intended functionality at each level of our code.
-
In order to run the tests, run
bundle exec rspec
in the command line and you should have all passing tests.
-
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
- Ruby 2.5.3
- Rails 2.5.4.3
Thank you to Ian Douglas and Dione Wilson for being such amazing instructors and guiding me through this project!