Skip to content

sjruby/shoop-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

General Assembly Logo

Shoop API

Make your art dance with SHOOP.

About Shoop

Shoop allows users to generate random patters of two colors on a 28x28 grid. Further it allows users to animate the board according Conways Game Of Life Rules.

Data Model

The final ERD is below: Imgur

Tests

rspec testing has been set up for the Boards resources requests, routes,

Dependinces:

Local Setup

  1. Create a .env for sensitive settings (touch .env).
  2. Generate new development and test secrets (bundle exec rake secret).
  3. Store them in .env with keys SECRET_KEY_BASE_<DEVELOPMENT|TEST> respectively.

Authentication API

Below are the authentication actions and associated Sriptes

Authentication

Verb URI Pattern Controller#Action
POST /sign-up users#signup
POST /sign-in users#signin
PATCH /change-password/:id users#changepw
DELETE /sign-out/:id users#signout

POST /sign-up

Request:

curl http://localhost:4741/sign-up \
  --include \
  --request POST \
  --header "Content-Type: application/json" \
  --data '{
    "credentials": {
      "email": "'"${EMAIL}"'",
      "password": "'"${PASSWORD}"'",
      "password_confirmation": "'"${PASSWORD}"'"
    }
  }'
EMAIL=ava@bob.com PASSWORD=hannah scripts/sign-up.sh

Response:

HTTP/1.1 201 Created
Content-Type: application/json; charset=utf-8

{
  "user": {
    "id": 1,
    "email": "ava@bob.com"
  }
}

POST /sign-in

Request:

curl http://localhost:4741/sign-in \
  --include \
  --request POST \
  --header "Content-Type: application/json" \
  --data '{
    "credentials": {
      "email": "'"${EMAIL}"'",
      "password": "'"${PASSWORD}"'"
    }
  }'
EMAIL=ava@bob.com PASSWORD=hannah scripts/sign-in.sh

Response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "user": {
    "id": 1,
    "email": "ava@bob.com",
    "token": "BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f"
  }
}

PATCH /change-password/:id

Request:

curl --include --request PATCH "http://localhost:4741/change-password/$ID" \
  --header "Authorization: Token token=$TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "passwords": {
      "old": "'"${OLDPW}"'",
      "new": "'"${NEWPW}"'"
    }
  }'
ID=1 OLDPW=hannah NEWPW=elle TOKEN=BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f scripts/change-password.sh

Response:

HTTP/1.1 204 No Content

DELETE /sign-out/:id

Request:

curl http://localhost:4741/sign-out/$ID \
  --include \
  --request DELETE \
  --header "Authorization: Token token=$TOKEN"
ID=1 TOKEN=BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f scripts/sign-out.sh

Response:

HTTP/1.1 204 No Content

Users

Verb URI Pattern Controller#Action
GET /users users#index
GET /users/1 users#show

GET /users

Request:

curl http://localhost:4741/users \
  --include \
  --request GET \
  --header "Authorization: Token token=$TOKEN"
TOKEN=BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f scripts/users.sh

Response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "users": [
    {
      "id": 2,
      "email": "bob@ava.com"
    },
    {
      "id": 1,
      "email": "ava@bob.com"
    }
  ]
}

GET /users/:id

Request:

curl --include --request GET http://localhost:4741/users/$ID \
  --header "Authorization: Token token=$TOKEN"
ID=2 TOKEN=BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f scripts/user.sh

Response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "user": {
    "id": 2,
    "email": "bob@ava.com"
  }
}

Shoop API

Below are the actions associated with CRUDING on the Boards resource

Verb URI Pattern Controller#Action
GET `/list-boards' boards#index
GET /boards/1 boards#show
POST /boards boards#create
PATCH /boards/1 boards#show
DELETE /boards/1 boards#show

GET /boards

Request:

curl --include --request GET https://protected-ridge-58465.herokuapp.com/boards \
  --header "Authorization: Token token=3481054d61508f98d6c40aeccfeacaa2" \

Response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "boards": [
    {
      "id": 2,
      "title": "test"
      "cells":"[[{\"xCord\":0,\"yCord\":0,\"intialValue\":2},{\"xCord\":0,\"yCord\":1,\"intialValue\":1},{\"xCord\":0,\"yCord\":2,\"intialValue\":2}]]"
    },

      {
        "id": 2,
        "title": "NewBoard"
        "cells":"[[{\"xCord\":0,\"yCord\":0,\"intialValue\":2},{\"xCord\":0,\"yCord\":1,\"intialValue\":1},{\"xCord\":0,\"yCord\":2,\"intialValue\":2}]]"
      }
  ]
}

Shoop API

Below are the actions associated with CRUDING on the Boards resource

Verb URI Pattern Controller#Action
GET /boards boards#index
GET /boards/1 boards#show
POST /boards boards#create
PATCH /boards/1 boards#show
DELETE /boards/1 boards#show

GET /boards

Request:

curl --include --request GET https://protected-ridge-58465.herokuapp.com/boards \
  --header "Authorization: Token token=3481054d61508f98d6c40aeccfeacaa2" \

Response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "boards": [
    {
      "id": 2,
      "title": "test"
      "cells":"[[{\"xCord\":0,\"yCord\":0,\"intialValue\":2},{\"xCord\":0,\"yCord\":1,\"intialValue\":1},{\"xCord\":0,\"yCord\":2,\"intialValue\":2}]]"
    },

      {
        "id": 2,
        "title": "NewBoard"
        "cells":"[[{\"xCord\":0,\"yCord\":0,\"intialValue\":2},{\"xCord\":0,\"yCord\":1,\"intialValue\":1},{\"xCord\":0,\"yCord\":2,\"intialValue\":2}]]"
      }
  ]
}

GET /boards/:id

Request:

curl --include --request GET https://protected-ridge-58465.herokuapp.com/boards/2 \
  --header "Authorization: Token token=3481054d61508f98d6c40aeccfeacaa2" \

Response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
"board": [
  {
    "id": 2,
    "title": "test"
    "cells":"[[{\"xCord\":0,\"yCord\":0,\"intialValue\":2},{\"xCord\":0,\"yCord\":1,\"intialValue\":1},{\"xCord\":0,\"yCord\":2,\"intialValue\":2}]]"
  }
  }

POST /boards

Request:

curl --include --request POST https://protected-ridge-58465.herokuapp.com/boards \
  --header "Authorization: Token token=3481054d61508f98d6c40aeccfeacaa2" \
 --data '{
      "board": {
        "title": "Ima board",
        "cells": ""[[{\"xCord\":0,\"yCord\":0,\"intialValue\":2},{\"xCord\":0,\"yCord\":1,\"intialValue\":1},{\"xCord\":0,\"yCord\":2,\"intialValue\":2}]]""
      }
    }'

Response:

HTTP/1.1 201 Created
Content-Type: application/json; charset=utf-8


{
     "board": {
       "title": "Ima board",
       "cells": "[[{\"xCord\":0,\"yCord\":0,\"intialValue\":2},{\"xCord\":0,\"yCord\":1,\"intialValue\":1},{\"xCord\":0,\"yCord\":2,\"intialValue\":2}]]"
     }
   }

PATCH /boards/1

Request:

curl --include --request PATCH https://protected-ridge-58465.herokuapp.com/boards \
  --header "Authorization: Token token=3481054d61508f98d6c40aeccfeacaa2" \
 --data '{
      "board": {
        "title": "Ima UPDATED BOARD",
        "cells": ""[[{\"xCord\":0,\"yCord\":0,\"intialValue\":2},{\"xCord\":0,\"yCord\":1,\"intialValue\":1},{\"xCord\":0,\"yCord\":2,\"intialValue\":2}]]""
      }
    }'

Response:

HTTP/1.1 204 No Content

DELETE /boards/1

Request:

curl --include --request DELETE https://protected-ridge-58465.herokuapp.com/boards/1 \
  --header "Authorization: Token token=3481054d61508f98d6c40aeccfeacaa2" \

Response:

HTTP/1.1 204 No Content

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published