Snack vending machines in offices are the worst. They are stocked with snacks that either unhealthy or old and stale - and they are always in dire need of a restock. Nobody gets a say in which snacks are stocked or when they should be rotated or re-stocked. With Snackify - the office snack subscription service and app - send your office snacktime woes packing faster than Janet from HR did to your annoying cubicle-mate last week!
| Request Type | Endpoint | Description |
|---|---|---|
| POST | /auth/register/organization | Creates New Organization |
| POST | /auth/register/employee | Creates Employee |
| POST | /auth/login/organization | Creates JWT* |
| POST | /auth/login/employee | Creates JWT* |
- JSON Web Tokens Used to Verify Users
Changing the role of employee by employee ID (Only accessible to those with the role of orgAdmins and organizations)
| Request Type | Endpoint | Description |
|---|---|---|
| PUT | /auth/:id/update-role | Changes role of an employee |
| Request Type | Endpoint | Description |
|---|---|---|
| GET | /snacks | Return All Snacks |
| GET | /snacks/:id/nutrition | Return Nutrition By Snack ID |
| POST | /snacks/nutrition | Creates Nutrition Fact |
| POST | /snacks | Creates Snack |
| PUT | /snacks/:id | Updates a Snack by Snack ID |
| PUT | /snacks/:id/nutrition | Updates Nutrition Fact by Nutrition Fact ID |
| DELETE | /snacks/:id | Remove Snack By ID |
| DELETE | /snacks/:id/nutrition | Remove Nutrition Fact By Nutrition Fact ID |
| Request Type | Endpoint | Description |
|---|---|---|
| GET | /subs | Return All Subscriptions |
| GET | /subs/:id/snacks | Return All Snacks For A Sub By Sub ID |
| POST | /subs | Adds New Subscription |
| PUT | /subs/:id | Update Subscription By Subscription ID |
| DELETE | /subs/:id | Remove Subscription By Subscription ID |
| Request Type | Endpoint | Description |
|---|---|---|
| GET | /purchase | Return All Purchases |
| POST /purchase | Adds New Purchase | |
| PUT | /purchase/:id | Update Purchase By Purchase ID |
| DELETE | /purchase/:id | Remove Purchase By Purchase ID |
| Request Type | Endpoint | Description |
|---|---|---|
| GET | /request | Return All Requests |
| POST | /request | Adds New Request |
| PUT | /request/:id | Update Request By Request ID |
| DELETE | /request/:id | Remove Request By Request ID |
A POST request to the /auth/register/organization endpoint expects to recieve an object as follows: (EVERY FIELD IS REQUIRED)
{
"username": "username"
"password": "password",
"email": "email@address.com",
"phoneNumber": "3453453534",
"streetAddress": "124 Ross",
"state": "Nowhere",
"zipcode": "12345",
"organizationName": "Org Name",
"contactPerson": "Fake Person",
"role": "organization"
}A POST request to the /auth/register/employee endpoint expects to recieve an object as follows: (EVERY FIELD IS REQUIRED)
{
"username": "username"
"password": "password",
"email": "email@address.com",
"phoneNumber": "3453453534",
"streetAddress": "124 Ross",
"state": "Nowhere",
"zipcode": "12345",
"fullName": "Full Name",
"contactPerson": "Fake Person",
"role": "employee", // OR "orgAdmin"
"orgId": Organization # goes here
}| Field | Type | Unique |
|---|---|---|
| username | String | true |
{
"username": "username",
"password": "happytree"
}{
"username": "username",
"password": "happytree"
}NOTE: If successful, a JSON Web Token will be returned. This must be stored and used as authentication for API calls to snacks, subscriptions and request endpoints.
[
{
"id": 1,
"username": "jonbash2",
"password": "$2a$10$Jk7zVyJU/wdgXvgNgxkIoOc4GT72OoQOH7ykmaHiGT8BT7rHxjtUi",
"email": "jonbash@protonmail.com",
"phoneNumber": "1234567890",
"streetAddress": "124 Ross",
"state": "Nowhere",
"zipcode": "12345",
"fullName": "Jon Bash",
"contactPerson": "Jon Bash",
"role": "Employee?",
"orgId": 1
},
{
"id": 2,
"username": "jonbash3",
"password": "$2a$10$GY1VaR9oTP2Wx/L3afjAJeXHh/xzcl6jm2J.vahOoFKcBtztkdQ8K",
"email": "jonbash@protonmail.com",
"phoneNumber": "1234567890",
"streetAddress": "124 Ross",
"state": "Nowhere",
"zipcode": "12345",
"fullName": "Jon Bash",
"contactPerson": "Jon Bash",
"role": "Employeeeeee?",
"orgId": 1
}
]{
"id": 1
"username": "username"
"password": "password",
"email": "email@address.com",
"phoneNumber": "3453453534",
"streetAddress": "124 Ross",
"state": "Nowhere",
"zipcode": "12345",
"fullName": "Full Name",
"contactPerson": "Fake Person",
"role": "organization",
"orgId": Organization # goes here
}A GET request to /auth/organizations will return all organizations
[
{
"id": 2,
"monthlyFee": 5,
"lengthOfSubscription": 4-4-4040,
"nameOfSubscription": "Name",
"orgId": 1
}
]NOTE: For PUT requests an object only containing the changed field is required, if the field is to remain the same it is not needed. An 'id' isn't needed for POST requests.
| Field | Type |
|---|---|
| monthlyFee | Float |
| lengthOfSubscription | Datetime |
| nameOfSubscription | String |
{
"id": 2,
"name": "Name",
"numberOfServings": 2,
"totalWeight": 1.5,
"price": 5.00,
"subId": 1
}NOTE: For PUT requests an object only containing the changed field is required, if the field is to remain the same it is not needed. An 'id' isn't needed for POST requests.
| Field | Type |
|---|---|
| name | string |
| numberOfServings | Integer |
| totalWeight | Float |
| price | Float |
{
"id": 2,
"calories": 2,
"totalFat": 2,
"totalSugars": 1.5 ,
"protein": 1,
"carbs": 1 1,
"allergens": "none",
"snackId": 1
}NOTE: For PUT requests an object only containing the changed field is required, if the field is to remain the same it is not needed. An 'id' isn't needed for POST requests.
| Field | Type |
|---|---|
| calories | Float |
| totalFat | Float |
| totalSugars | Float |
| protein | Float |
| carbs | Float |
| allergens | string |
{
"id": 2,
"snackName": "Name",
"subId": 1
}NOTE: For PUT requests an object only containing the changed field is required, if the field is to remain the same it is not needed. An 'id' isn't needed for POST requests.
{
"id": 2,
"snackName": "Name",
"subId": 1
}NOTE: For PUT requests an object only containing the changed field is required, if the field is to remain the same it is not needed. An 'id' isn't needed for POST requests.