Skip to content

lcpulzone/whether_sweater

Repository files navigation


Whether, Sweater

This is a back-end application that exposes API's to support building an application that to plan road trips.
The API's exposed will allow front-end developers to show users the current weather as well as the forecasted weather when they arrive at their destination.
Report Bug · Request Feature


Table of Contents

  1. About The Project
  2. Getting Started
  3. Endpoints
  4. Roadmap
  5. Contact
  6. Acknowledgements

About The Project

Whether, Sweater is a fictional back-end application built to plan road trips. This app will allow users to see the current weather as well as the forecasted weather at the destination.

The front-end communicated with back-end through an API.

The goal of this project was to work in a service-oriented architecture to expose an API that satisfied the front-end team’s requirements.

Main 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
  • Research, select, and consume an API based on your needs as a developer

Built With

forthebadge
tested with rspec

Getting Started

Prerequisites

Rails 5.2.6
Ruby 2.7.2

Installation

To get a local copy up and running follow these simple steps.

  1. Fork & clone this repo

  2. Run bundle install to install gem packages

  3. Run rails db:{drop,create,migrate} to set up the database

  4. Run bundle exec figaro install then add your API keys to the config/application.yml file as: OW_API_KEY for Open Weather, MQD_API_KEY for Map Quest, and UN_API_KEY for Unsplash

  5. Run rails s and navigate to localhost:3000 to consume Whether, Sweater's API endpoints

Endpoints

Retrieve weather for a city

  • Request GET /api/v1/forecast?location=<location>

  • Sample Request:

    GET /api/v1/forecast?location=bend,or

  • Sample Response:

{
    "data": {
        "id": null,
        "type": "forecast",
        "attributes": {
            "current_weather": {
                "datetime": "September 05, 11:05 AM -0600",
                "sunrise": "September 05, 07:33 AM -0600",
                "sunset": "September 05, 08:34 PM -0600",
                "temperature": 70.38,
                "feels_like": 68.47,
                "humidity": 29,
                "uvi": 3.09,
                "visibility": 1609,
                "conditions": "haze",
                "icon": "50d"
            },
            "daily_weather": [
                {
                    "date": "September 05, 2021",
                    "sunrise": "September 05, 07:33 AM -0600",
                    "sunset": "September 05, 08:34 PM -0600",
                    "max_temp": 89.8,
                    "min_temp": 53.22,
                    "conditions": "clear sky",
                    "icon": "01d"
                },
                {
                    "date": "September 06, 2021",
                    "sunrise": "September 06, 07:34 AM -0600",
                    "sunset": "September 06, 08:32 PM -0600",
                    "max_temp": 88.25,
                    "min_temp": 52.95,
                    "conditions": "clear sky",
                    "icon": "01d"
                },
                {
                    "date": "September 07, 2021",
                    "sunrise": "September 07, 07:35 AM -0600",
                    "sunset": "September 07, 08:30 PM -0600",
                    "max_temp": 95.61,
                    "min_temp": 57.45,
                    "conditions": "scattered clouds",
                    "icon": "03d"
                },
                {
                    "date": "September 08, 2021",
                    "sunrise": "September 08, 07:36 AM -0600",
                    "sunset": "September 08, 08:29 PM -0600",
                    "max_temp": 85.01,
                    "min_temp": 55.42,
                    "conditions": "clear sky",
                    "icon": "01d"
                },
                {
                    "date": "September 09, 2021",
                    "sunrise": "September 09, 07:38 AM -0600",
                    "sunset": "September 09, 08:27 PM -0600",
                    "max_temp": 86.2,
                    "min_temp": 52.07,
                    "conditions": "scattered clouds",
                    "icon": "03d"
                }
            ],
            "hourly_weather": [
                {
                    "time": "11:00 AM",
                    "temperature": 70.38,
                    "conditions": "clear sky",
                    "icon": "01d"
                },
                {
                    "time": "12:00 PM",
                    "temperature": 72.41,
                    "conditions": "clear sky",
                    "icon": "01d"
                },
                {
                    "time": "01:00 PM",
                    "temperature": 75.96,
                    "conditions": "clear sky",
                    "icon": "01d"
                },
                {
                    "time": "02:00 PM",
                    "temperature": 80.37,
                    "conditions": "clear sky",
                    "icon": "01d"
                },
                {
                    "time": "03:00 PM",
                    "temperature": 85.26,
                    "conditions": "clear sky",
                    "icon": "01d"
                },
                {
                    "time": "04:00 PM",
                    "temperature": 89.8,
                    "conditions": "clear sky",
                    "icon": "01d"
                },
                {
                    "time": "05:00 PM",
                    "temperature": 88.36,
                    "conditions": "clear sky",
                    "icon": "01d"
                },
                {
                    "time": "06:00 PM",
                    "temperature": 86.43,
                    "conditions": "clear sky",
                    "icon": "01d"
                }
            ]
        }
    }
}

Background image for the city

  • Request GET /api/v1/backgrounds?location=<location>

  • Sample Request:

    GET /api/v1/forecast?location=bend,or

  • Sample Response:

{
    "data": {
        "id": null,
        "type": "image",
        "attributes": {
            "location": "bend,or",
            "description": "Horseshoe Bend during daytime",
            "image_urls": {
                "raw": "https://images.unsplash.com/photo-1483086451546-5a971a934123?ixid=MnwyNTI1NzN8MHwxfHNlYXJjaHwxfHxiZW5kJTJDb3J8ZW58MHx8fHwxNjMwODYxNTAy&ixlib=rb-1.2.1",
                "full": "https://images.unsplash.com/photo-1483086451546-5a971a934123?crop=entropy&cs=srgb&fm=jpg&ixid=MnwyNTI1NzN8MHwxfHNlYXJjaHwxfHxiZW5kJTJDb3J8ZW58MHx8fHwxNjMwODYxNTAy&ixlib=rb-1.2.1&q=85",
                "regular": "https://images.unsplash.com/photo-1483086451546-5a971a934123?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwyNTI1NzN8MHwxfHNlYXJjaHwxfHxiZW5kJTJDb3J8ZW58MHx8fHwxNjMwODYxNTAy&ixlib=rb-1.2.1&q=80&w=1080",
                "small": "https://images.unsplash.com/photo-1483086451546-5a971a934123?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwyNTI1NzN8MHwxfHNlYXJjaHwxfHxiZW5kJTJDb3J8ZW58MHx8fHwxNjMwODYxNTAy&ixlib=rb-1.2.1&q=80&w=400",
                "thumb": "https://images.unsplash.com/photo-1483086451546-5a971a934123?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwyNTI1NzN8MHwxfHNlYXJjaHwxfHxiZW5kJTJDb3J8ZW58MHx8fHwxNjMwODYxNTAy&ixlib=rb-1.2.1&q=80&w=200"
            },
            "credit": {
                "name": "Des Récits",
                "self": "https://api.unsplash.com/users/desrecits",
                "html": "https://unsplash.com/@desrecits",
                "photos": "https://api.unsplash.com/users/desrecits/photos",
                "portfolio": "https://api.unsplash.com/users/desrecits/portfolio"
            }
        }
    }
}

User Registration

  • Request POST /api/v1/users

  • Sample Request:

    {
      "email": "missfrizbeethemouse@pets.com",
      "password": "***************ries",
      "password_confirmation":  "***************ries"
    }
    
  • Sample Response:

{
    "data": {
        "id": "10",
        "type": "users",
        "attributes": {
            "email": "missfrizbeethemouse@pets.com",
            "api_key": "****************************fO9x"
        }
    }
}

Login

  • Request POST /api/v1/sessions

  • Sample Request:

    {
      "email": "tedthedog@pets.com",
      "password": "**************wels"
    }
    
  • Sample Response:

{
    "data": {
        "id": "3",
        "type": "users",
        "attributes": {
            "email": "tedthedog@pets.com",
            "api_key": "****************************RPhR"
        }
    }
}

Road Trip

  • Request POST /api/v1/road_trip

  • Sample Request:

    {
      "origin": "Denver,CO",
      "destination": "Bend,OR",
      "api_key": "****************************dXIp"
    }
    
  • Sample Response:

{
    "data": {
        "id": null,
        "type": "roadtrip",
        "attributes": {
            "start_city": "Denver,CO",
            "end_city": "Bend,OR",
            "travel_time": "16:13:11",
            "weather_at_eta": {
                "temperature": 55.51,
                "conditions": "overcast clouds"
            }
        }
    }
}

Roadmap

See the open issues for a list of proposed features (and known issues).

Contact

Leigh Cepriano Pulzone - Linkedin - GitHub - Email

Project Link

Acknowledgements

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published