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.
To get this project running on your (mac) machine:
From the command line, in a directory of your choosing:
git clone git@github.com:Dpalazzari/johari_window_api.git
Install gems:
Create database, migrate the database, seed and load the schema with this line:
Required environmental variables:
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.
To seed the database
To run test suite:
start the server to test out the endpoints.
All responses are in JSON.
This request will return a list of 56 adjectives as described by the original Johari Window. The response will look like this:
[
"able",
"accepting",
...
"wise",
"witty"
]
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
}
]
For a given user id, this request will return the name, id, created_at, and updated_at for a given user.
{
id: 1,
name: "Mebble",
created_at: "2017-03-29T00:37:58.779Z",
updated_at: "2017-03-29T00:37:58.779Z"
}
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:
{
:johari => ["religious", "shy", "able", "self-assertive"],
:describer_id => 2
}
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:
{
group: [
[ {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} ]
]
}
To create a user through our API, make a post request to this endpoint with the following JSON:
{
name: 'Drew',
github: 'Dpalazzari',
token: 'KLDShglskhg324235msfn'
}
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}
]
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
}
]
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
}
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.
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.
-
Our Johari Window API will pull all Turing student data down from Census. The Johari Window React App will authenticate users through github, which will allow the front-end app to send a github username to the census API and find each student's user object from the database. Turing students will need to sign in through the react APP just once to be added to the API database.
-
We want two rake tasks:
- Rake task that updates students with the cohort they are in.
- Rake Task that generates a new access_token from Census (which expires every 90 days).
-
These two Rake Tasks should make it easier for Allison to use.