Coder Social home page Coder Social logo

sweater_weather_api's Introduction

Sweater Weather (or is it Whether, Sweater?)

This is the final project of Mod 3 (of 4) at Turing School of Software and Design in Denver, CO. It is the backend portion of a service-oriented architecture. We were provided with detailed wire frames and/or the expected JSON response from the front end, and asked to consume multiple external APIs to gather and format the data required.

Endpoints

GET '/api/v1/backgrounds?location=<city>,<state>'

example response for this request: GET '/api/v1/backgrounds?location=denver,co'

`{:data=>
  {:id=>nil,
   :type=>"background",
   :attributes=>
    {:image_url=>
      ["https://images.unsplash.com/photo-1580408597610-51b1ad419857?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE1MzY1MH0"]}}}`

GET '/api/v1/forecast?location=<city>,<state>'

example response for this request: GET '/api/v1/forecast?location=denver,co'

  `{:data=>
    {:id=>nil,
     :type=>"forecast",
     :attributes=>
      {:location=>"denver,co",
       :current=>
        {:overview=>
          {:temperature=>85.66,
           :description=>"moderate rain",
           :date=>"August 4",
           :time=>" 6:22 PM",
           :high=>85.66,
           :low=>75.22},
         :details=>
          {:sunrise=>" 6:02 AM",
           :sunset=>" 8:09 PM",
           :feels_like=>79.38,
           :humidity=>28,
           :visibility=>6977,
           :uv_index=>10.81}},
       :hourly=>
        [{:hour=>"07 PM", :temperature=>77.5},
         {:hour=>"08 PM", :temperature=>72.23},
         {:hour=>"09 PM", :temperature=>71.04},
         {:hour=>"10 PM", :temperature=>72.21},
         {:hour=>"11 PM", :temperature=>73.31},
         {:hour=>"12 AM", :temperature=>72.34},
         {:hour=>"01 AM", :temperature=>71.35},
         {:hour=>"02 AM", :temperature=>70.72}],
       :daily=>
        [{:day_of_week=>"Wednesday",
          :description=>"Rain",
          :percipitation=>1.53,
          :high=>89.71,
          :low=>69.51},
         {:day_of_week=>"Thursday",
          :description=>"Rain",
          :percipitation=>0.17,
          :high=>93.54,
          :low=>68.16},
         {:day_of_week=>"Friday",
          :description=>"Rain",
          :percipitation=>0.72,
          :high=>93.0,
          :low=>73.56},
         {:day_of_week=>"Saturday",
          :description=>"Clear",
          :percipitation=>0.0,
          :high=>94.15,
          :low=>73.4},
         {:day_of_week=>"Sunday",
          :description=>"Clouds",
          :percipitation=>0.0,
          :high=>91.76,
          :low=>74.52}]}}}`

POST '/api/v1/users?email=<email>&password=<password>&password_confirmation=<password confirmation>'

example response for this request: POST '/api/v1/[email protected]&password=password&password_confirmation=password'

  `{:data=>
    {:id=>"524",
     :type=>"users",
     :attributes=>
      {:email=>"[email protected]", :api_key=>"c5875144080529943bf0"}}}`

POST '/api/v1/sessions?email=<email>&password=<password>'

example response for this request: '/api/v1/[email protected]&password=password'

  `{:status=>200,
   :body=>
    {:data=>
      {:id=>"521",
       :type=>"users",
       :attributes=>
        {:email=>"[email protected]",
         :api_key=>"fee168326c00c3d72897"}}}}`

POST '/api/v1/road_trip?origin=<city>,<state>&destination=<city>,<state>&api_key=<api_key>'

example response for this request: POST '/api/v1/road_trip?origin=denver,co&destination=pueblo,co&api_key=<api_key>'

`{:data=>
  {:id=>"94",
   :type=>"road_trip",
   :attributes=>
    {:origin=>"denver,co",
     :destination=>"pueblo,co",
     :duration=>"6237",
     :temperature=>70.72,
     :description=>"broken clouds"}}}`

sweater_weather_api's People

Contributors

stellakunzang avatar dependabot[bot] avatar

Watchers

James Cloos avatar  avatar

sweater_weather_api's Issues

Request

`POST /api/v1/users
Content-Type: application/json
Accept: application/json

{
"email": "[email protected]",
"password": "password"
"password_confirmation": "password"
}`

Response

`status: 201
body:

{
"data": {
"type": "users",
"id": "1",
"attributes": {
"email": "[email protected]",
"api_key": "jgn983hy48thw9begh98h4539h4"
}
}
}`

Request

`POST /api/v1/road_trip
Content-Type: application/json
Accept: application/json

body:

{
"origin": "Denver,CO",
"destination": "Pueblo,CO",
"api_key": "jgn983hy48thw9begh98h4539h4"
}`

Requirements

  • A successful request creates a user and generates a unique api key associated with that user.
  • An unsuccessful request returns a 400 level status code and body with a description of why the request wasn’t successful. Potential reasons a request would fail: passwords don’t match, email has already been taken, missing a field, etc.

Requirements

  • A successful request returns the user’s api key.
  • An unsuccessful request returns a 400 level status code and body with a description of why the request wasn’t successful. Potential reasons a request would fail: credentials are bad.

Requirements

  • API key must be sent
  • If no API key or an incorrect key is provided return 401 (Unauthorized)
  • You will use MapQuest’s Directions API: https://developer.mapquest.com/documentation/directions-api/
  • The structure of the response should be JSON API 1.0 Compliant.

Sad Path Testing

  • cannot register if passwords don't match
  • cannot register if field is left blank
  • cannot register if email already exists
  • returns 400 status code with description in body explaining why the request wasn't successful.

1a. Retrieve weather for a city

  • Request:

GET /api/v1/forecast?location=denver,co Content-Type: application/json Accept: application/json

  • Response:

Use the wireframes to see what data is required on the front-end to decide what data should be included in your response. Use the Fast JSON API and the response should adhere to the JSON 1.0 spec.

  • Requirements:
  • Needs to pull out the city and state from the GET request and send it to MapQuest’s Geocoding API to retrieve the lat and long for the city (this can be its own story). Use of the MapQuest’s Geocoding API is a hard requirement.
  • Retrieve forecast data from the OpenWeather One Call API using the lat and long

Request

`POST /api/v1/sessions
Content-Type: application/json
Accept: application/json

{
"email": "[email protected]",
"password": "password"
}`

Response

`status: 200
body:

{
"data": {
"type": "users",
"id": "1",
"attributes": {
"email": "[email protected]",
"api_key": "jgn983hy48thw9begh98h4539h4"
}
}
}`

Response

Includes:

  • Origin location
  • Destination location
  • Travel time
  • Arrival Forecast (degrees, description)

README

  • API Endpoints
  • Example of return data
  • Excerpts from presentation about 4 pillars
  • Section describing refactoring
  • Host on Heroku

1b. Background Image for a City

  • Request:
    GET /api/v1/backgrounds?location=denver,co Content-Type: application/json Accept: application/json

  • Response:
    This will return the url to an appropriate background image for a location.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.