Skip to content

ruezheng/sweater_weather

Repository files navigation

Sweater Weather

ruby rails rspec contributors

Table of Contents

App

Sweater Weather is a service-oriented Ruby on Rails API application that exposes API endpoints for trip planning. This app allows users to see current and forecasted weather to plan upcoming trips.

(back to top)

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

(back to top)

Installation

  1. Fork and/or Clone the repo using the SSH key
git clone git@github.com:rue-zheng/sweather_weather.git
  1. Install gems and dependencies
 bundle install
  1. Create database and run migrations
rails db:create
rails db:migrate
  1. Set up figaro to securely use API key
bundle exec figaro install
  1. To use the API services mentioined above, add the following line in the hidden root/config/application.yml file generated in step 4:
mapquest_api_key: YOUR_MAPQUEST_API_KEY
openweather_api_key: YOUR_OPEN_WEATHER_API_KEY
  1. Run run test suit
bundle exec rspec
  1. Start the local server to service API requests:
rails s

Open web browser and add endpoints to the end of the local base url:

http://localhost:3000

(back to top)

Endpoints

Forecast for a location

  • http request
GET /api/v1/forecast?location=denver,co
Content-Type: application/json
Accept: application/json
headers: { 'Authorization' => 'Bearer YOUR_API_KEY' }
  • Postman Sample Response:

image

(back to top)

Background image for a location

  • http request
GET '/api/v1/backgrounds?location=denver,co'
Content-Type: application/json
Accept: application/json
headers: { 'Authorization' => 'Bearer YOUR_API_KEY' }
  • Postman sample response

image

(back to top)

User registration

  • http request
POST 'api/v1/users'
Content-Type: application/json
Accept: application/json

body:
{
  "email": "user@example.com",
  "password": "password",
  "password_confirmation": "password"
}
  • Postman sample response

image

(back to top)

User login

  • http request
POST /api/v1/sessions
Content-Type: application/json
Accept: application/json

body:
{
  "email": "user@example.com",
  "password": "password"
}
  • Postman sample response

image

(back to top)

Creating a Road Trip

  • http request
POST /api/v1/road_trip
Content-Type: application/json
Accept: application/json

body:
{
  "origin": "Denver,CO",
  "destination": "Los Angeles,CA",
  "api_key": "jgn983hy48thw9begh98h4539h4"
}
  • Postman sample response (valid trip):

image

  • Postman sample response (impossible route):

image

(back to top)

External API Endpoints

MapQuest

OpenWeather

  • Endpoint(s) consumed:
  • Instruction to obtain an API key:
    • Visit OpenWeather Signup Page and create an account
    • Login and click on your user name. Under the dropdown menu, select My API Keys option to view and manage your API key (Note: it may take a few hours for the API key to be activated).
    • Developer's Guide

Schema

image

(back to top)

## Contributor

Rue Zheng

|

(back to top)

About

Sweater Weather is a service-oriented application used to plan road trips, built with Ruby on Rails. This app allows users to see the current weather as well as the forecasted weather at the destination.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors