jimriddle1 / sweater_weather

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Learning Goals

  • 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
  • Test both API consumption and exposure, making use of at least one mocking tool (VCR, Webmock, etc)

API Usage


WEATHER

Get Weather

  • This endpoint consumes data returned from MapquestGeocode and OpenWeather, and returns current daily and hourly weather of a given location.
[GET] /api/v1/forecast

Example:

[GET] /api/v1/forecast?location=chicago,il

RESPONSE:

{
  "data": {
    "id": null,
    "type": "forecast",
    "attributes": {
      "current_weather": {
        "datetime": "2020-09-30 13:27:03 -0600",
        "temperature": 79.4,
        etc
      },
      "daily_weather": [
        {
          "date": "2020-10-01",
          "sunrise": "2020-10-01 06:10:43 -0600",
          etc
        },
        {...} etc
      ],
      "hourly_weather": [
        {
          "time": "14:00:00",
          "conditions": "cloudy with a chance of meatballs",
          etc
        },
        {...} etc
      ]
    }
  }
}

USER

Create User

  • This endpoint creates a user
[POST] /api/v1/users/


Required BDOY: 
 - email
 - password
 - password confirmation

Example:

[POST] /api/v1/users/

 - Body: 
	 {
	  "email": "whatever@example.com",
	  "password": "password",
	  "password_confirmation": "password"
	}

RESPONSE:

{
	"data": {
		"type": "users",
		"id": "1",
		"attributes": {
			"email": "whatever@example.com",
			"api_key": "abcdefg"
		}
	}
}

Login User

  • This endpoint logs in a user
[POST] /api/v1/sessions/


Required BDOY: 
 - email
 - password

Example:

[POST] /api/v1/sessions/

 - Body: 
	 {
	  "email": "whatever@example.com",
	  "password": "password"
	}

RESPONSE:

{
	"data": {
		"type": "users",
		"id": "1",
		"attributes": {
			"email": "whatever@example.com",
			"api_key": "abcdefg"
		}
	}
}

ROADTRIP

Road Trip Info

  • This endpoint consumes data returned from MapquestDirections and OpenWeather, and returns future weather of a given destination.
[POST]  /api/v1/road_trip


Required BODY: 
 - origin
 - destination
 - api_key

Example:

[POST]  /api/v1/users/road_trip

 - Body: 
	 {
	  "origin": "Denver,CO",
	  "destination": "Pueblo,CO",
	  "api_key": "abcdefg"
	}

RESPONSE:

{
	"data": {
		"id": "null",
		"type": "road_trip",
		"attributes": {
			"start_city": "Denver,CO",
			"end_city": "Pueblo,CO",
			"travel_time": "01:45:23",
			"weather_at_eta": {
				"temperature": 85.7,
				"conditions": "clear sky"
			}
		}
	}
}

Feel like messing around?

Installation

  1. Clone this directory to your local repository using the SSH key:

$ git clone git@github.com:jimriddle1/sweater_weather.git

  1. Install gems for development using Bundler:

$ bundle install

  1. Set up your database with:

$ rails db:{drop,create,migrate}

  1. Run the test suite with:

$ bundle exec rspec

  1. Run your development server with:

$ rails s

About


Languages

Language:HTML 69.5%Language:Ruby 30.5%