Skip to content

Latest commit

 

History

History
292 lines (191 loc) · 9.05 KB

MinimalAPIdocs.md

File metadata and controls

292 lines (191 loc) · 9.05 KB

Minimal api docs

This contains bare minimum documentation for api endpoints

Note: All the endpoints require the user to be logged in. Only exception is user login and organization register.

Organization /api/organization/

This api end point handles user registration, organization profile and deleting an employee account that belongs to the organization.

GET /api/organization/profile

It will respond with information about the organization account keys of json object are email, id, firstName, lastName, role, createdAt, name, numberOfEmployees, city and country.

POST /api/organization/register

Note: User with role ORGANIZATION or ADMIN can create accounts. When organization user creates an account the user will belong to that organization.

Creates user account with value of role EMPLOYEE in the backend with the specified data

Required keys of json data in the body:

{
	"name": "ABC",
	"email": "[email protected]",
	"password": "Abcd@1234",
	"confirmPassword": "Abcd@1234",
	"numberOfEmployees": 9,
	"city": "Jyvaskyla",
	"country": "Finland" # Optional default is Finland
}

POST /api/organization/deleteEmployee

Note: Allowed for users having role ORGANIZATION

This endpoint will delete the employee the user account of the user by email, if the user belongs to the organization

Required keys of json data in the body:

{
	"email": "[email protected]"
}

User /api/user/

This api end point handles user registration, login, logout, getting user profile and giving user admin permission.

Note: only admins can create, update and delete languages. Others can only read.

GET /api/user/profile

It will respond with information about the user account keys of json object are firstName, lastName, email, role, createdAt and worksAtOrganizationId.

POST /api/user/register

Note: User with role ORGANIZATION or ADMIN can create accounts. When organization user creates an account the user will belong to that organization.

Creates user account with value of role EMPLOYEE in the backend with the specified data

Required keys of json data in the body:

{
	"firstName": "ABC",
	"lastName": "DEF",
	"email": "[email protected]",
	"password": "Abcd@1234",
	"confirmPassword": "Abcd@1234"
}

POST /api/user/login

Logs in a user by setting http only cookie using set-cookie header. It will return with http status code 204 No Content when successful.

Required keys of json data in the body:

{
	"email": "[email protected]",
	"password": "Abcd@1234"
}

POST /api/user/logout

Logs out a logged in user by clearing the http only cookie.

POST /api/user/makeUserAdmin

Note: Allowed for only admin users.

This endpoint will make a pre existing normal user(eg. role="EMPLOYEE") account to admin.

Required keys of json data in the body:

{
	"email": "[email protected]"
}

Language /api/language/

This api end point handles CRUD operations for languages in database.

Note: only admins can create, update and delete languages. Others can only read.

GET /api/language/

It will respond with all languages from database

GET /api/language/{id}

It will respond with the language that has the specified id. Will respond with 404 http status code if the language does not exist.

POST /api/language/

Creates language in the backend with the specified data

Required keys of json data in the body:

{
	"name": "string",
	"code": "language code",
	"unicodeFlag": "🇧🇩"
}

PUT /api/language/{id}

Updates a language by id and currently requires the keys same as POST request

DELETE /api/language/{id}

Deletes a language by id.

Category /api/category/

This api end point handles CRUD operations for categories in database.

Note: only admins can create, update and delete categories. Others can only read.

GET /api/category/

It will respond with all categories from database

GET /api/category/{id}

It will respond with the category that has the specified id. Will respond with 404 http status code if the category does not exist.

POST /api/category/

Creates category in the backend with the specified data

Required keys of json data in the body:

{
	"languageId": 1,
	"name": "Organization",
	"Description": "Organization level objectives should be under this category"
}

Here languageId should be provided from data acquired from language api endpoint

PUT /api/category/{id}

Updates a category by id and currently requires the keys same as POST request

DELETE /api/category/{id}

Deletes a category by id.

SubCategory /api/subCategory/

This api end point handles CRUD operations for SubCategories in database.

Note: only admins can create, update and delete SubCategories which will be visible to all users. These can't be modified by anyone but other admins. Organization or a user belonging to an organization can create sub categories which will be visible to the users belonging to the same organization.

GET /api/subCategory/

It will respond with all SubCategories from database that are either created by admins or the organization the user belongs to or the user is.

GET /api/subCategory/{id}

It will respond with the subCategory that has the specified id. Will respond with 404 http status code if the subCategory does not exist. Or respond with 401 when user does not have permission to the subCategory.

POST /api/subCategory/

Creates subCategory in the backend with the specified data.

Required keys of json data in the body:

{
	"categoryId": 1,
	"name": "Administrative",
	"Description": "Objectives related to management should be under this sub category"
}

Here categoryId should be provided from data acquired from category api endpoint

PUT /api/subCategory/{id}

Updates a subCategory by id and currently requires the keys same as POST request

DELETE /api/subCategory/{id}

Deletes a subCategory by id.

objective /api/objective/

This api end point handles CRUD operations for objectives in database.

Note: Objectives that are created by admins will be visible to all users. These can't be modified by anyone but other admins. Organization or a user belonging to an organization can create objectives which will be visible to the users belonging to the same organization.

GET /api/objective/

It will respond with all objectives from database that are either created by admins or the organization the user belongs to or the user is.

GET /api/objective/{id}

It will respond with the objective that has the specified id. Will respond with 404 http status code if the objective does not exist. Or respond with 401 when user does not have permission to the objective.

POST /api/objective/

Creates objective in the backend with the specified data.

Required keys of json data in the body:

{
	"subCategoryId": 1,
	"name": "objective 1",
	"Description": "Description for objective"
}

Here subCategoryId should be provided from data acquired from subCategory api endpoint

PUT /api/objective/{id}

Updates a objective by id and currently requires the keys same as POST request

DELETE /api/objective/{id}

Deletes a objective by id.