Install with bundle install
.
- bin/rails db:drop (if it already exists)
- bin/rails db:create
- bin/rails db:migrate
- bin/rails db:seed
- bin/rails db:examples
Note: Do this for each database you want to set up. Your local database and production (Heroku) database will both need to be set up in this way!
- Run the API server with
bin/rails server
orbundle exec rails server
.
Verb | URI Pattern | Controller#Action |
---|---|---|
POST | /work_spaces |
work_spaces#create |
POST | /reviews |
reviews#create |
GET | /work_spaces |
work_spaces#index |
GET | /reviews |
reviews#index |
GET | /work_spaces/:id |
workspaces#show |
GET | /reviews/:id |
reviews#show |
curl "http://localhost:4741/work_spaces" \
--include \
--request POST \
--header "Content-Type: application/json" \
--header "Authorization: Token token=${TOKEN}" \
--data '{
"work_space": {
"place_id": "'"${PLACE}"'",
"lat": "'"${LAT}"'",
"lng": "'"${LNG}"'"
}
}'
curl "http://localhost:4741/work_spaces/${ID}" \
--include \
--request GET \
--header "Content-Type: application/json" \
--header "Authorization: Token token=${TOKEN}" \
curl "http://localhost:4741/reviews" \
--include \
--request POST \
--header "Content-Type: application/json" \
--header "Authorization: Token token=${TOKEN}" \
--data '{
"review": {
"rating": "'"${RATING}"'",
"note": "'"${NOTE}"'",
"wifi": "'"${WIFI}"'",
"food": "'"${FOOD}"'",
"bathroom": "'"${BATH}"'",
"coffee": "'"${COFFEE}"'",
"seating": "'"${SEAT}"'",
"outlet": "'"${OUT}"'",
"noise": "'"${NOISE}"'",
"review": "'"${REV}"'",
"work_space_id": "'"${ID}"'"
}
}'
curl "http://localhost:4741/reviews/${ID}" \
--include \
--request GET \
--header "Content-Type: application/json" \
--header "Authorization: Token token=${TOKEN}" \
Verb | URI Pattern | Controller#Action |
---|---|---|
POST | /sign-up |
users#signup |
POST | /sign-in |
users#signin |
PATCH | /change-password |
users#changepw |
DELETE | /sign-out |
users#signout |
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 protected] PASSWORD=hannah curl-scripts/auth/sign-up.sh
Response:
HTTP/1.1 201 Created
Content-Type: application/json; charset=utf-8
{
"user": {
"id": 1,
"email": "[email protected]"
}
}
Request:
curl http://localhost:4741/sign-in \
--include \
--request POST \
--header "Content-Type: application/json" \
--data '{
"credentials": {
"email": "'"${EMAIL}"'",
"password": "'"${PASSWORD}"'"
}
}'
[email protected] PASSWORD=hannah curl-scripts/auth/sign-in.sh
Response:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
"user": {
"id": 1,
"email": "[email protected]",
"token": "BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f"
}
}
Request:
curl --include --request PATCH "http://localhost:4741/change-password" \
--header "Authorization: Token token=$TOKEN" \
--header "Content-Type: application/json" \
--data '{
"passwords": {
"old": "'"${OLDPW}"'",
"new": "'"${NEWPW}"'"
}
}'
OLDPW='hannah' NEWPW='elle' TOKEN='BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f' sh curl-scripts/auth/change-password.sh
Response:
HTTP/1.1 204 No Content
Request:
curl http://localhost:4741/sign-out \
--include \
--request DELETE \
--header "Authorization: Token token=$TOKEN"
TOKEN='BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f' sh curl-scripts/auth/sign-out.sh
Response:
HTTP/1.1 204 No Content
- All content is licensed under a CCBYNCSA 4.0 license.
- All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact [email protected].