jesse-spevack / checkmeplease

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Med Card REST API

Created By Ben Ghalami

This is an API with the ability to Create, View, Delete, and Edit Users, as well as Create, View, Delete, and Edit those Users Med Cards and State IDs

See the app in action at HERE!

Schema

Endpoints

GET '/api/v1/users'  
	- See all Users
POST '/api/v1/users'  
	- Create a new User
	- Takes the following as JSON in the BODY
	- NONE of the fields can be empty
	- {    
	    "name": {VARCHAR},  
	    "email_address": {VARCHAR},
	    "date_of_birth": {YYYY-MM-DD}
	  }
    - MUST include HTTP header:
      `Content-Type` with value `application/json`
GET '/api/v1/users/:id'  
	- Show a single User with State ID and Medical Recommendation
	- EXAMPLE:
	  {
	    id: 1,
	    name: "Ben",
	    email_address: "ben@ben.com",
	    date_of_birth: "1992-08-05",
	    state_id: {
		  id_number: 4,
	      state: "Kansas",
	      expiration_date: "1995-08-05(EXPIRED)",
	      path_to_image: "/file/file/file/file.jpg"
	    },
	    medical_recommendation: {
		  recommendation_number:  4,
	      issuer: "A Doctor",
		  state: "Kansas",
	      expiration_date: "1995-08-05(EXPIRED)",
		  path_to_image: "/file/file/file/file.jpg"
       }
	}
PUT '/api/v1/users:id'  
	- Update an existing User
	- Takes any combination of the following JSON
	- {    
	  "name": {VARCHAR},  
	  "email_address": {VARCHAR},
	  "date_of_birth": {YYYY-MM-DD}
	  }
	- MUST include HTTP header:
      `Content-Type` with value `application/json`
DELETE '/api/v1/users:id'
	- Permanantly deletes a User and associated State ID and
	  Medical Recommendation from the database


GET '/api/v1/users/:user_id/state_id'
	- View a Users State ID info
	- EXAMPLE:
	  {
		id_number: 4,
	    state: "Kansas",
	    expiration_date: "1995-08-05(EXPIRED)",
	    path_to_image: "/file/file/file/file.jpg"
	  }
POST '/api/v1/users/:user_id/state_id'
	- Create a State ID for a User
	- Takes the following as JSON in the BODY
	- NONE of the fields can be empty
	- {    
	  "id_number": {INTEGER},
	  "state": {VARCHAR},
	  "expiration_date": {YYYY-MM-DD},
	  "path_to_image": {VARCHAR}
	  }
    - MUST include HTTP header:
      `Content-Type` with value `application/json`
PUT '/api/v1/users/:user_id/state_id'  
	- Edit an existing User State ID
	- Takes any combination of the following JSON
	- {    
	  "id_number": {INTEGER},
	  "state": {VARCHAR},
	  "expiration_date": {YYYY-MM-DD},
	  "path_to_image": {VARCHAR}
	  }
	- MUST include HTTP header:
      `Content-Type` with value `application/json`
DELETE '/api/v1/users/:user_id/state_id'
	- Permanently deletes a Users State ID


GET '/api/v1/users/:user_id/medical_recommendation'
	- View a Users Medical Recommendation
	- EXAMPLE:
	    {
		  recommendation_number: 4,
		  issuer: "A Doctor",
		  state: "Kansas",
		  expiration_date: "1995-08-05(EXPIRED)",
		  path_to_image: "/file/file/file/file.jpg"
	    }
POST '/api/v1/users/:user_id/medical_recommendation'  
	- Create a Medical Recommendation for a User
	- Takes the following as JSON in the BODY
	- NONE of the fields can be empty
	- {
		recommendation_number: {INTEGER},
		issuer: {VARCHAR},
		state: {VARCHAR},
		expiration_date: {YYYY-MM-DD},
		path_to_image: {VARCHAR}
	  }
    - MUST include HTTP header:
      `Content-Type` with value `application/json`
PUT '/api/v1/users/:user_id/medical_recommendation'  
	- Edit an existing User Medical Recommendation
	- Takes any combination of the following JSON
	- {
		recommendation_number: {INTEGER},
		issuer: {VARCHAR},
		state: {VARCHAR},
		expiration_date: {YYYY-MM-DD},
		path_to_image: {VARCHAR}
	  }
	- MUST include HTTP header:
      `Content-Type` with value `application/json`
DELETE '/api/v1/users/:user_id/medical_recommendation'
	- Permanently deletes a Users Medical Recommendation
	  from the DataBase

Initial Setup

  1. Clone the repository into a directory of your choosing:
git clone git@github.com:GhostGroup/api-test-beng.git
  1. Navigate into the new directory.
  2. Merge my Dev branch
  git pull origin dev
  1. Install the dependencies:
bundle install
  1. Run the following command to create, migrate, and seed the database
rake db:create db:migrate db:seed

Running the Test Suite

  1. After Initial Setup run
rspec
  1. To see test coverage run
open coverage/index.html

Running the Server Locally

To see your code in action locally, you need to fire up a development server. From the root of the project
use the command:

rails server

Once the server is running, visit in your browser, or with PostMan:

  • http://localhost:3000/ to run your application.

  • The DB should be populated with 3 test Users for you to play around with

  • To quit the server simply press Ctrl + C to shut it down.

Built With

Tech

Gems

Organic

About


Languages

Language:HTML 76.4%Language:Ruby 22.9%Language:JavaScript 0.5%Language:CSS 0.3%