Use this API to store supermarket inventory data. Users must to sign in first to interact with API. All data returned from API actions is formatted as JSON and only belongs to the requested user.
Scripts are included in scripts to test built-in actions.
| Verb | URI Pattern | Controller#Action |
|---|---|---|
| GET | /inventories |
inventories#index |
| GET | /inventories/:id |
inventories#show |
| POST | /inventories |
inventories#create |
| PATCH | /inventories |
inventories#update |
| DELETE | /inventories |
inventories#destroy |
| Verb | URI Pattern | Controller#Action |
|---|---|---|
| GET | /orders |
orders#index |
| GET | /orders/:id |
orders#show |
| POST | /orders |
orders#create |
| PATCH | /orders |
orders#update |
| DELETE | /orders |
orders#destroy |
In main entity table, products, the elements are not able to be deleted, and updated.
| Verb | URI Pattern | Controller#Action |
|---|---|---|
| GET | /products |
products#index |
| GET | /products/:id |
products#show |
| POST | /products |
products#create |
| 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 |
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.shResponse:
HTTP/1.1 201 Created
Content-Type: application/json; charset=utf-8
{
"user": {
"id": 1,
"email": "ava@bob.com"
}
}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.shResponse:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
"user": {
"id": 1,
"email": "ava@bob.com",
"token": "BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f"
}
}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.shResponse:
HTTP/1.1 204 No ContentRequest:
curl http://localhost:4741/sign-out/$ID \
--include \
--request DELETE \
--header "Authorization: Token token=$TOKEN"ID=1 TOKEN=BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f scripts/sign-out.shResponse:
HTTP/1.1 204 No Content| Verb | URI Pattern | Controller#Action |
|---|---|---|
| GET | /users |
users#index |
| GET | /users/1 |
users#show |
Request:
curl http://localhost:4741/users \
--include \
--request GET \
--header "Authorization: Token token=$TOKEN"TOKEN=BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f scripts/users.shResponse:
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"
}
]
}Request:
curl --include --request GET http://localhost:4741/users/$ID \
--header "Authorization: Token token=$TOKEN"ID=2 TOKEN=BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f scripts/user.shResponse:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
"user": {
"id": 2,
"email": "bob@ava.com"
}
}