Trevorsuter / sweater-weather

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sweater Weather

About this Project

Table of Contents

Getting Started

Prerequisites

To run this application you will need Ruby 2.5.3 and Rails 5.2.5

Installing

  • Install the gem packages
    • bundle install

Running the tests

RSpec testing suite is utilized for testing this application.

  • Run the RSpec suite to ensure everything is passing as expected
    bundle exec rspec

API Consumption

Endpoints

GET Forecast Data

GET /api/v1/forecast?location={city,state}

  • Required path params:
    • location: MUST be in city,state format

GET /api/v1/forecast?location=denver,co

{
  "data": {
    "id": "null",
    "type": "forecast",
    "attributes": {
      "current_weather": {
        "datetime": "2021-04-26T18:20:06.000-06:00",
        "sunrise": "2021-04-26T06:06:18.000-06:00",
        "sunset": "2021-04-26T19:48:45.000-06:00",
        "temperature": 71.96,
        "feels_like": 69.19,
        "humidity": 7,
        "uvi": 0.62,
        "visibility": 10000,
        "conditions": "overcast clouds",
        "icon": "04d"
      },
      "daily_weather": [
        {
          "date": "2021-04-26",
          "sunrise": "2021-04-26T06:06:18.000-06:00",
          "sunset": "2021-04-26T19:48:45.000-06:00",
          "max_temp": 75.27,
          "min_temp": 52.65,
          "conditions": "overcast clouds",
          "icon": "04d"
        },
        {"..."}
      ],
      "current_weather": [
        {
          "time": "18:00:00",
          "temperature": 71.96,
          "conditions": "overcast clouds",
          "icon": "04d"
        },
        {"..."}
      ]
    }
   }
  • Notes about this endpoint:
    • daily_weather returns a total of 5 days of data
    • hourly_weather returns a total of 8 hours of data
    • all units of measurement are in imperial form

GET Background Data

GET /api/v1/backgrounds?location={city,state}

  • Required path params:
    • location: Must be in city,state format

GET api/v1/backgrounds?location=denver,co

{
  "data": {
    "id": "null",
    "type": "image",
    "attributes": {
      "image": {
        "location": "denver,co",
        "search_url": {"search_url"},
        "image_url": {"image_url"},
        "credit": {
          "name": {"image name"},
          "source": {"image source"},
          "logo": {"source logo"}
        } 
      }
    }
  }
}
  • Notes about this endpoint:
    • All images default to searching for pictures of that city's Downtown area.

POST User Data

POST api/v1/users

request_body: {"email": "(email)", "password": "(password)", "password_confirmation": "(password confirmation)"}

  • NO PATH PARAMS ARE USED IN THIS ENDPOINT, all data must be passed through in the body of the request in JSON format shown above.

  • Required in the body:

    • email
    • password
    • password confirmation must match the password for successful creation

POST api/v1/users

request_body: {"email": "example@email.com", password: "password", password_confirmation: "password"}

{
  "data": {
    "id": 1,
    "type": "user",
    "attributes": {
      "email": "example@email.com",
      "api_key": "g46k7791m07za88140"
    }
  }
}
  • Notes about this endpoint:
    • 201 status code if creation is successful
    • 401 status code with description if unsuccessful

Post User Login Data

POST /api/v1/sessions

body: {"email": "(example@email.com)", "password": "(password)"}

  • NO PATH PARAMS ARE USED IN THIS ENDPOINT, all data must be passed through in the body of the request in JSON format shown above.

  • Required in the body:

    • email
    • password

POST /api/v1/sessions

body: {"email": "example@email.com", "password": "password123"}

{
 "data": {
   "id": "1",
   "type": "user",
   "attributes": {
     "email": "example@email.com",
     "api_key": "g46k7791m07za88140" 
   }
 }
}
  • Notes about this endpoint:
    • 201 status code if creation is successful
    • 401 status code with description if unsuccessful

POST Roadtrip Data

POST /api/v1/roadtrip

body: { "origin": "(origin location)", "destination": "(destination location)", "api_key": "(user api key)"

  • NO PATH PARAMS ARE USED IN THIS ENDPOINT, all data must be passed through in the body of the request in JSON format shown above.

  • Required in the body:

    • origin: the starting location of the roadtrip
    • destination: the ending location of the roadtrip
    • api_key: the created user's api key, used to grant access

POST /api/v1/roadtrip

body: {"origin": "Denver,CO", "destination": "Boulder,CO", "api_key": "92868b0d3fe5bece35dfbd91fd7a881b"}

{
 "data": {
   "id": "null",
   "type": "roadtrip",
   "attributes": {
     "start_city": "Denver,CO",
     "end_city": "Boulder,CO",
     "travel_time": "00:35:23",
     "weather_at_eta": {
       "temperature": "45.7",
       "conditions": "overcast clouds"
       }
     }
 }
}
  • Notes about this endpoint:
    • 401 status code with description if invalid route is given (ex. New York, NY -> London, UK)
    • 401 status code if any params are missing
    • 401 status code if API key is not found in the user database
    • 401 status code with description if locations gave an error in other areas

Built With

Contributing

Please follow the steps below and know that all contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/<New-Cool-Feature-Name>)
  3. Commit your Changes (git commit -m 'Add <New-Cool-Feature-Name>')
  4. Push to the Branch (git push origin feature/<New-Cool-Feature-Name>)
  5. Open a Pull Request

Versioning

  • Rails 5.2.5
  • Ruby 2.5.3
  • RSpec 3.10.0
  • Rbenv 1.1.2

Author

About


Languages

Language:Ruby 99.7%Language:HTML 0.3%