turingschool/johari_window_api

Name: johari_window_api

Owner: Turing School of Software & Design

Description: null

Forked from: Dpalazzari/johari_window_api

Created: 2017-05-09 18:51:57.0

Updated: 2017-06-06 18:46:29.0

Pushed: 2018-02-14 00:39:17.0

Homepage: null

Size: 115

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build StatusCode Climate

Johari Window API

Quick overview

This is a tool developed at the Turing School, based on the Johari Window Exercise developed in 1955 by Joseph Luft and Harrington Ingham. This particular portion of the app supplies an API and back-end database for the front-end Johari Window Project.

The production site can be located by clicking here and the live react app here.

Getting Started in Development Environment

To get this project running on your (mac) machine:

From the command line, in a directory of your choosing:

clone git@github.com:Dpalazzari/johari_window_api.git

Install gems:

bundle

Create database, migrate the database, seed and load the schema with this line:

Required environmental variables:

figaro install

Then copy and paste application.sample.yml into application.yml and fill in environment variables with their correct values. Contact developers to get access to environment variables.

rails db:{create,migrate,schema:load}

To seed the database

rails db:seed

To run test suite:

rspec

start the server to test out the endpoints.

rails s
API Endpoints

All responses are in JSON.

GET /adjectives

This request will return a list of 56 adjectives as described by the original Johari Window. The response will look like this:


ble",
ccepting",
.
ise",
itty"

GET /:id/assignments

For a given user id, this request will return the names and ids of people to be described. The format will look something like this:



user: {
    id: 70,
    name: "Rodrik Ryswell"
      },
completed?: true


user: {
    id: 119,
    name: "Jeyne Westerling"
      },
completed?: false


GET /users/:id

For a given user id, this request will return the name, id, created_at, and updated_at for a given user.


: 1,
me: "Mebble",
eated_at: "2017-03-29T00:37:58.779Z",
dated_at: "2017-03-29T00:37:58.779Z"

POST /:id/descriptions

For a given user id, this request will create descriptions for the user. The response body will contain a status of 204 if the POST is successful, and a 304 if the POST fails.

JSON objects need to be posted to the API in this format:


ohari => ["religious", "shy", "able", "self-assertive"], 
escriber_id => 2

POST /assignments

For given groups of users, this request will create unique assignments between each pair of users (as long as there is not an open assignment between them).

JSON objects need to be posted to the API in this format:


oup:   [
          [ {name: 'Drew', id: 0}, {name: 'Kyle', id: 1} ],
          [ {name: 'Lucy', id: 2}, {name: 'Annie', id: 3} ],
          [ {name: 'Drew', id: 0}, {name: 'Amy', id: 4}, {name: 'Kyle', id: 1} ]
        ] 

POST /users

To create a user through our API, make a post request to this endpoint with the following JSON:


name: 'Drew', 
github: 'Dpalazzari', 
token: 'KLDShglskhg324235msfn'

GET /cohorts

This will return JSON of all available cohorts.


{"id"=>1, "name"=>"1610backend", "created_at"=>"2017-04-05", "updated_at"=>"2017-04-05},
{"id"=>2, "name"=>"1610frontend", "created_at"=>"2017-04-05", "updated_at"=>"2017-04-05}

GET /cohorts/:cohort_id/users

For a given cohort, this endpoint will return JSON of all the users that belong to the cohort.


{
  "id"=>1, "name"=>"Drew", "created_at"=>"2017-04-05", "updated_at"=>"2017-04-05", "cohort_id"=>11
},
{
  "id"=>2, "name"=>"Kyle", "created_at"=>"2017-04-05", "updated_at"=>"2017-04-05", "cohort_id"=>1
}

GET /users/by_github?name=:name

For a given github username, this endpoint will return JSON of a matching user.


"id"=>1, "name"=>"Drew", "github: "Dpalazzari", created_at"=>"2017-04-05", "updated_at"=>"2017-04-05", "cohort_id"=>11

Production Environment

Any server in production environment will need to compensate for CORS. Gem gem 'rack-cors' in the gemfile adds a cors.rb file to config/initializers.

Also, Your app will need an access_token from Turing's Census App.

Customization

The seed file can be found in /db/seeds.rb. We made use of one of our favorite gems here: Faker. Check out the docs to see other possibilities and seed your own custom data for your test environment.

Going Forward
Primary Contributors

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.