Skip to content

brisag/camping

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Camp Ground + Forecast Search

Heroku Badge

Brisa Garcia - June 2021

Contact Information

    

Table of Contents

Overview

Camp Ground + Forecast Search is an API Search/Filter application. We all move to Colorado to go camping right? How do I search for capgrounds? Whats the weather like? Can I just visit a park and not camp at it? The purpose of this app find the forecast of a given location, and search for parks, or campgrounds in parks!

Using request such as GET /api/v1/forecast?location=denver,co the app can

  • retrieve the weather for a national parks campsite,

The projects asks for T.D.D. (test driven development) to develop the project functionality. Gems such as simplecov, webmock, and vcr, among others help us drive this process.
The testing requirements expect 'sad path' path testing along with functionality. When user inputs a blank field or a nil result, user will get error json.

back to top


Specifications

This project runs on Rails: 6.1.3 and Ruby: 2.5.3

To check your current versions, run:

$ ruby -v
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin19]
$ rails -v
Rails 6.1.3


Gems

This project uses the following additional gems:
You can find the most current version at Rubygems.org

Production

  • bcrypt: The bcrypt Ruby gem provides a simple wrapper for safely handling passwords.
  • faraday: HTTP/REST API client library
  • figaro: Simple, Heroku-friendly Rails app configuration using ENV and a single YAML file
  • jsonapi-serializer: Fast, simple and easy to use JSON:API serialization library (also known as fast_jsonapi).

Test and Development

  • pry: Pry is a runtime developer console and IRB alternative that attempts to bring REPL driven programming to the Ruby language
  • rspec-rails: rspec-rails is a testing framework for Rails 5+
  • rubocop: RuboCop is a Ruby code style checking and code formatting tool. It aims to enforce the community-driven Ruby Style Guide.
  • simplecov: Code coverage for Ruby with a powerful configuration library and automatic merging of coverage across test suites
  • shoulda-matchers: Shoulda Matchers provides RSpec compatible one-liners to test common Rails functionality
  • webmock: WebMock allows stubbing HTTP requests and setting expectations on HTTP requests.
  • vcr: Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests

APIs

In this project we used the following APIs:

back to top


Installation

Test it Out In Postman

It is as easy as clicking on the orange button, cloning to your web or local computer, and running the test suite!

Run in Postman

back to top

Fork and Clone The Repo

Fork this Github repository: Camping

Clone your 'camping' repository using SSH:

  $ git clone git@github.com:<your-github-username>/camping.git

Initial Installation

In the command line run the following commands in order:

  1. $ rails db:{create,migrate}
  2. $ rails generate rspec:install
  3. $ bundle exec figaro install
  4. $ bundle install

Set Up API Keys

Find the application.yml file in the config folder and add your API keys example:

MAPQ_API_KEY: <api key here without strings>
WEATHER_API_KEY: <api key here without strings>
NPS_KEY: <api key here without strings>

back to top


Testing

RSpec

We can check the test on the spec folder by running rspec

In the command line run

$ bundle exec rspec

All tests should be passing.

If you get a nil or a vcr error, you may need to delete vcr_cassettes in the /spec/fixtures folder.

Simplecov

After running the tests simplecov gathers the coverage and neatly reports them in an html page.

In the command line you should see something like this:

Coverage report generated for RSpec to /Users/brisa/turing/three/projects/final_project/jackets/coverage. 749 / 752 LOC (99.6%) covered.

Rubocop

Rubocop helps us clean up the code.

In the command line run:

$ rubocop

Rubocop will highlight styling errors - according to rails standards - and make recommendations on how to improve the code.

back to top


API Endpoints

The exposing these endpoints is the chief purpose of this application. To test this out your self in your computer follow the instructions below.

Expose the endpoints in Postman

  1. Open the terminal in your computer and navigate to where camping is located and cd into it.
  2. Once in the directory run the following command in your terminal: $ rails server
  3. Open Postman and type the following in the address bar: 'https://polar-coast-94103.herokuapp.com/' or http://localhost:3000/
  4. Add the requests below to call each endpoint. example: http://localhost:3000/api/v1/parks?location=denver,co
  5. Change the verb to one corresponding to the call for example: Post
  6. Send your request by clicking Send

Notice that some of the call require you add the paramteres to the body. In postman:

  1. Click on body
  2. Select raw
  3. Select json (by default show as text)

Forecast

Retrieve weather for a city

Shows the current, hourly, and daily forecast for the location queried. It accepts city and state as parameters.

Request:

  • Content-Type: application/json
  • Accept: application/json

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


daily_weather

Test it Out In Postman

Run in Postman

back to top

Park by State Code

Retrieves national park by state code

Using National Parks Service API, retrieves all state parks from specific state from that json.

Request:

  • Content-Type: application/json
  • Accept: application/json

get api/v1/parks?stateCode=CO


park_statecode

Test it Out In Postman

Run in Postman

back to top

Park by State Code and Keyword

Retrieves national park by state code and or keyword

Using National Parks Service API, retrieves all state parks from specific state from that json.

Request:

  • Content-Type: application/json
  • Accept: application/json

get api/v1/campground?stateCode=CO&q=dinosaur


camp_query

Test it Out In Postman

Run in Postman

User Registration

Registers a new user

Registers a new user and generates a unique API key for the user

Request:

  • Content-Type: application/json
  • Accept: application/json

The params are passed on in the body of the request not in the uri:

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

post /api/v1/users


user_create

back to top

Test it Out In Postman

Run in Postman

User Login

Authenticates a User

This request authenticates a user and logs it into the application

Request:

  • Content-Type: application/json
  • Accept: application/json
{
  "email": "whatever@example.com",
  "password": "password"
}

post /api/v1/sessions

Test it Out In Postman

Run in Postman

Camping Weather Setup

Returns estimated travel time and arrival forecast for a camping trip

This request produces trip duration and destination weather forecast at eta.

Request:

  • Content-Type: application/json
  • Accept: application/json
{
  "origin": "Denver,CO",
  "destination": "sand dunes",
  "api_key": "jgn983hy48thw9begh98h4539h4"
}

post /api/v1/road_trip


weather_at_site

Test it Out In Postman

Run in Postman

back to top


Heroku API Endpoints

This api-application has been deployed to Heroku. You can test the endpoints in postman by following the link below and running postman in your browser.

Run in Postman

If you have postman installed locally you can run it in the app directly

https://polar-coast-94103.herokuapp.com/api/v1/<type here the desired endpoint>


back to top

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published