Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#7] Add and Get All Groups API Docs #21

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
314 changes: 314 additions & 0 deletions doc/groups.md
Original file line number Diff line number Diff line change
@@ -1 +1,315 @@
# Groups Module
Module | HTTP Method | URL | Description
--- | --- | --- | ---
[Add Groups](#add) | POST | /groups-add | Add Groups API
lukman134 marked this conversation as resolved.
Show resolved Hide resolved
[Edit Groups](#edit) | PUT | /groups-edit/{id} | Edit Groups API
lukman134 marked this conversation as resolved.
Show resolved Hide resolved
[View All Groups](#view) | GET | /groups | View Groups API
[Delete Groups](#delete) | DELETE | /groups-delete/{id} | Delete Groups API
lukman134 marked this conversation as resolved.
Show resolved Hide resolved

jacky-htg marked this conversation as resolved.
Show resolved Hide resolved

### Database
![](./groups-layer.png)
jacky-htg marked this conversation as resolved.
Show resolved Hide resolved

*For [Add Groups](#add) and [Edit Groups](#edit), you need get aros to set aros_id.*

## <a name="add"></a>Add Groups

### Endpoint
POST /groups-add

### Headers
Key | Value
--- | ---
Content-Type | application/json
Accept | application/json

lukman134 marked this conversation as resolved.
Show resolved Hide resolved
### Request Payloads
Name | Type | Example Value
--- | --- | ---
title | string | Admin
description | string | Administrator
aros_id | int | 1
lukman134 marked this conversation as resolved.
Show resolved Hide resolved
```
{
"title": "Admin",
"description": "Administrator",
"aros": {
"aros_id": "1"
}
}

```

### Response Payloads
HTTP Code | Status | Description
--- | --- | ---
400 | Bad Request | Bad request payload
404 | Not Found | User not found in database
lukman134 marked this conversation as resolved.
Show resolved Hide resolved
500 | Internal Server Error | some un-handle error in server
201 | Created | Created
```
{
"status_code": "CDC-400",
"status_message": "Bad Request",
"data": null
}
```

```
{
"status_code": "CDC-200",
"status_message": "OK",
"data": {
"id": "1",
lukman134 marked this conversation as resolved.
Show resolved Hide resolved
"title": "Admin",
"description": "Administrator",
"created": "2020-12-01 00:00:00",
"modified": "2020-12-01 00:00:00",
"aros_id": "1"
}
}
```

### Logic

lukman134 marked this conversation as resolved.
Show resolved Hide resolved
#### Validation
- title : required and not empty
- description : required and not empty
- aros_id : required and not empty
lukman134 marked this conversation as resolved.
Show resolved Hide resolved

*if any special logic, please write down the logic here. thanks*

### Scenario Test

#### Case : Negative Case 1

Request Payload : empty

Response HTTP Status Code : 400

Response Payload :
```
{
"status_code": "cdc-400",
"status_message": "title is required",
"data": null
}
```

#### Case : Negative Case 2

Request Payload :
```
{}
```

Response HTTP Status Code : 400

Response Payload :
```
{
"status_code": "cdc-400",
"status_message": "title is required",
"data": null
}
```

#### Case : Negative Case 3

Request payload :
```
{
"title": ""
}
```

Response HTTP Status Code : 400

Response Payload :
```
{
"status_code": "cdc-400",
"status_message": "title is empty",
"data": null
}
```

#### Case : Negative Case 4

Request Payload :
```
{
"title": "Coba"
}
```

Response HTTP Status Code : 400

Response Payload :
```
{
"status_code": "cdc-400",
"status_message": "description is required",
"data": null
}
```

#### Case : Negative Case 5

Request Payload :
```
{
"title": "Coba",
"description": ""
}
```

Response HTTP Status Code : 400

Response Payload:
```
{
"status_code": "cdc-400",
"status_message": "description is empty",
"data": null
}
```

#### Case : Negative Case 6

Request Payload :
```
{
"title": "Coba",
"description": "Coba coba"
}
```

Response HTTP Status Code : 400

Response Payload:
```
{
"status_code": "cdc-400",
"status_message": "aros_id is required"
"data": null
}
```

#### Case : Negative Case 7

Request Payload :
```
{
"title": "Coba",
"description": "Coba coba",
"aros" : {
"aros_id": ""
}
}
```

Response HTTP Status Code : 400

Response Payload:
```
{
"status_code": "cdc-400",
"status_message": "aros_id is empty"
"data": null
}
```
#### Case : Positive Case

Request Payload :
```
{
"title": "Sales",
"description": "Sales Position"
"aros": {
"aros_id": "2"
}
}
```

Response HTTP Status Code : 200

Response Payload :
```
{
"status_code": "CDC-200",
"status_message": "OK",
"data": {
"id": "2",
"title": "Sales",
"description": "Sales Position",
"created": "2020-12-01 00:00:00",
"modified": "2020-12-01 00:00:00",
"aros_id": "2"
}
}
```

## <a name="edit"></a>Edit Groups

### Endpoint
PUT /groups-edit/{id}

## <a name="view"></a>View All Groups

### Endpoint
GET /groups

### Headers
Key | Value
--- | ---
Content-Type | *
Accept | application/json

### Request Payload

No Request Payload

### Response Payloads
HTTP Code | Status | Description
--- | --- | ---
400 | Bad Request | Bad request payload
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no bad request. remove this response.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove 400 response on GET /groups

404 | Not Found | User not found in database
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no 404. remove this response.
if no data, please provide empty array

{
    "status_code": "cdc-200",
    "status_message": "success or data is empty or whatever you want",
    "data": []
}

500 | Internal Server Error | some un-handle error in server
200 | OK | OK
```
{
"status_code": "CDC-400",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cdc-500

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no bad request on GET /groups
please change with 500 internal server error for example of error response

"status_message": "Bad Request",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"status_message": "Internal Server Error",

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no bad request on GET /groups
please change with 500 internal server error for example of error response

"data": null
}
```

```
{
"status_code": "CDC-200",
"status_message": "OK",
"data": [
{
"id": "1",
"title": "Admin",
"description": "Administrator",
"created": "2020-12-01 00:00:00",
"modified": "2020-12-01 00:00:00",
"aros_id": "1"
},
{
"id": "2",
"title": "Sales",
"description": "Sales Admin",
"created": "2020-12-01 00:00:00",
"modified": "2020-12-01 00:00:00",
"aros_id": "2"
}
}
```

## <a name="delete"></a>Delete Groups

### Endpoint
DELETE /groups-delete/{id}