API constructed by aggregating two external APIs to provide charging station information including 10-hour forecast. This app serves data from NREL and OpenWeather external APIs. The current endpoints facilitate access for a guest and registered user. A user can search nearby stations using various search queries including:
- zip code
- full address
- city and state
A registered user can save stations to their account. Backend also allows user registration and authentication.
Note: This app is currently being worked on and it is also deployed on Heroku.
- Built With
- Front-End Repo
- Getting Started
- Usage
- Running the tests
- DB Schema
- Endpoints
- Acknowledgements
- You can find more information about the application at GitHub Repo
- Visit the deployed application on Heroku
To run this application you will need
- Ruby 2.5.3 and Rails 5.2.6
- Sign up for an API key at:
To get a local copy up and running follow these simple steps:
- Fork this repo
- Clone your forked repo to your local machine
git clone <git@github.com:EV-Station-Finder/ev_station_finder_fe.git>
- Install gem packages
bundle install
- Install Figaro
bundle exec figaro install
- Setup your API keys in your
config/application.yml
fileCHARGER_KEY: <your_api_key> WEATHER_KEY: <your_api_key>
- Create rails database and migrate
rails db:{create,migrate}
- Start rails server
rails s
- Nagivate to
http://localhost:3000/
RSpec testing suite is utilized for testing this application.
- Run the RSpec suite to ensure everything is passing as expected
bundle exec rspec
1. Stations (expand for details)
This will render an index page with the results as a list of stations.
request_body = {
"location": "Los Angeles, CA",
"token": "eyJhbGciOiJIUzI1N/J9.eyJ1c5VyX2lkIjo5N30.Dbrd03NdQJu2Ko_vF8hONHP2Yk-LLJuDc5M2znBa4dI" (optional)
}
The location
parameter can accept the following:
- street, city, state, postal code
- street, city, state
- street, postal code
- postal code
- city, state
The token
parameter is optional and requires a valid user's token (logged in user):
Example response (returns up to 20 stations)
{
"data": [
{
"id": null,
"type": "station",
"attributes": {
"api_id": 57896,
"name": "Aiso Street Parking Garage",
"distance": 0.17641,
"status": "Available",
"hours": "24 hours daily",
"ev_network": "eVgo Network",
"street_address": "101 Judge John Aiso St",
"city": "Los Angeles",
"state": "CA",
"zip_code": "90012",
"is_favorited": true
}
},
{
"id": null,
"type": "station",
"attributes": {
"api_id": 578908,
"name": "Nissan of Downtown Los Angeles",
"distance": 2.07951,
"status": "Available",
"hours": "Dealership business hours",
"ev_network": "Non-Networked",
"street_address": "635 W Washington Blvd",
"city": "Los Angeles",
"state": "CA",
"zip_code": "90015",
"is_favorited": true
}
}
]
}
request_body = {
"token": "eyJhbGciOiJIUzI1N/J9.eyJ1c5VyX2lkIjo5N30.Dbrd03NdQJu2Ko_vF8hONHP2Yk-LLJuDc5M2znBa4dI" (optional)
}
The token
parameter is optional and requires a valid user's token (logged in user):
Example response
{
"data": {
"id": null,
"type": "station",
"attributes": {
"name": "Some Charger",
"api_id": 152087,
"status": "Temporarily Closed",
"hours": "24hrs",
"ev_connector_types": ["CHADEMO", "J1772COMBO"],
"ev_network": "Tesla",
"street_address": "123 Street Ave",
"city": "Denver",
"state": "CO",
"zip_code": "12345",
"is_favorited": true,
"accepted_payments": [
"apple_pay", "credit"
],
"hourly_weather": [{
"time": "1300",
"temperature": "75",
"conditions": "Sunny",
"icon": "10d"
}, ... 10 total hour forecasts ]
}
}
}
2. Users (expand for details)
request_body = {
"first_name": "Hari",
"last_name": "Seldon",
"email": "hari.seldon@foundation.com",
"street_address": "123 Planet XYZ",
"city": "Jupiter",
"state": "UN",
"zip_code": "12345",
"password": "verysecurepassword"
}
Example response
{
"data": {
"token": "eyJhbGciOiJIUzI1N/J9.eyJ1c5VyX2lkIjo5N30.Dbrd03NdQJu2Ko_vF8hONHP2Yk-LLJuDc5M2znBa4dI",
"type": "user",
}
}
- Returns user information with the token instead of the ID, and without the user's password digest
request_body = {
"token": "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyNDd9.hSjNPgNbJdVtlIwtOkKqz1OKLxdmND1rvVbL5iZ7cxE"
}
Example response
{
"data": {
"id": null,
"type": "user",
"attributes": {
"first_name": "Hari",
"last_name": "Seldon",
"email": "hari.seldon@foundation.com",
"street_address": "123 Planet XYZ",
"city": "Jupiter",
"state": "UN",
"zip_code": "12345"
}
}
}
- Updates user and returns updated user information
- Update all or partial user info (Request body will only contain the attributes that are to be updated)
request_body = {
"token": "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyNDd9.hSjNPgNbJdVtlIwtOkKqz1OKLxdmND1rvVbL5iZ7cxE",
"first_name": "Hari",
"last_name": "Seldon",
"email": "hari.seldon@example.com",
"street_address": "123 Planet ABC",
"city": "Jupiter",
"state": "UN",
"zip_code": "12345"
}
Example response
{
"data": {
"id": null,
"type": "user",
"attributes": {
"first_name": "Hari",
"last_name": "Seldon",
"email": "hari.seldon@example.com",
"street_address": "123 Planet ABC",
"city": "Jupiter",
"state": "UN",
"zip_code": "12345"
}
}
}
- Deletes user and returns 204 HTTP Status
request_body = {
"token": "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyNDd9.hSjNPgNbJdVtlIwtOkKqz1OKLxdmND1rvVbL5iZ7cxE"
}
3. Sessions (expand for details)
request_body = {
"email": "hari.seldon@foundation.com",
"password": "verysecurepassword"
}
Example response
{
"data": {
"token": "eyJhbGciOiJIUzI1N/J9.eyJ1c5VyX2lkIjo5N30.Dbrd03NdQJu2Ko_vF8hONHP2Yk-LLJuDc5M2znBa4dI",
"type": "user"
}
}
request_body = {
"token": "eyJhbGciOiJIUzI1N/J9.eyJ1c5VyX2lkIjo5N30.Dbrd03NdQJu2Ko_vF8hONHP2Yk-LLJuDc5M2znBa4dI"
}
Example response
{
"data": {
"token": "eyJhbGciOiJIUzI1N/J9.eyJ1c5VyX2lkIjo5N30.Dbrd03NdQJu2Ko_vF8hONHP2Yk-LLJuDc5M2znBa4dI",
"type": "user"
}
}
4. Favorite Stations (expand for details)
- Returns user's favorite stations
request_body = {
"token": "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyNDd9.hSjNPgNbJdVtlIwtOkKqz1OKLxdmND1rvVbL5iZ7cxE"
}
Example response
{
"data": [
{
"id": null,
"type": "station",
"attributes": {
"api_id": 57896,
"name": "Aiso Street Parking Garage",
"distance": 0.17641,
"status": "Available",
"hours": "24 hours daily",
"ev_network": "eVgo Network",
"street_address": "101 Judge John Aiso St",
"city": "Los Angeles",
"state": "CA",
"zip_code": "90012",
"is_favorited": true
}
},
{
"id": null,
"type": "station",
"attributes": {
"api_id": 578908,
"name": "Nissan of Downtown Los Angeles",
"distance": 2.07951,
"status": "Available",
"hours": "Dealership business hours",
"ev_network": "Non-Networked",
"street_address": "635 W Washington Blvd",
"city": "Los Angeles",
"state": "CA",
"zip_code": "90015",
"is_favorited": true
}
}
]
}
- Saves a favorite_station for a user
request_body = {
"token": "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyNDd9.hSjNPgNbJdVtlIwtOkKqz1OKLxdmND1rvVbL5iZ7cxE",
"api_id": 152283
}
Example response
{
"data": {
"type": "favorite_station"
}
}
- Deletes a favorite_station for a user and returns 204 HTTP Status
request_body = {
"token": "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyNDd9.hSjNPgNbJdVtlIwtOkKqz1OKLxdmND1rvVbL5iZ7cxE",
"api_id": 152283
}