diff --git a/doc/regions.md b/doc/regions.md index c144cd2..05311ff 100644 --- a/doc/regions.md +++ b/doc/regions.md @@ -14,25 +14,22 @@ POST /regions ### Database ![](./regions.png) -for add, you need get company_id from companies tables - ### Headers Key | Value --- | --- Content-Type | application/json Accept | application/json +Email | application/json ### Request Payloads Name | Type | Example Value --- | --- | --- region_code | string | AMD name | string | Auto Moro Dewe -company_id | string | 12 ``` { "region_code": "AMD", "name": "Auto Moro Dewe" - "company_id": "12" } ``` @@ -40,9 +37,9 @@ company_id | string | 12 HTTP Code | Status | Description --- | --- | --- 400 | Bad Request | Bad request payload -404 | Not Found | User not found in database +404 | Not Found | Region not found in database 500 | Internal Server Error | some un-handle error in server -200 | OK | OK +201 | Created | Created ``` { "status_code": "CDC-400", @@ -53,14 +50,14 @@ HTTP Code | Status | Description ``` { - "status_code": "CDC-200", - "status_message": "OK", + "status_code": "CDC-201", + "status_message": "Created", "data": { - "id":"7", + "id":"5e6c4216-360c-11eb-8f39-5600024efe02", "region_code" : "AMD", "name" : "Auto Moro Dewe", "company_code" : "BKNINTEL", - "company_id" : "12", + "company_id" : "d58edc03-360c-11eb-8f39-5600024efe02", "created" : "2020-12-02 09:03:44", "modified" : "2020-12-02 09:03:44", } @@ -72,7 +69,6 @@ HTTP Code | Status | Description #### Validation - region_code : required and not empty - name: required and not empty -- company_id: required and not empty ### Scenario Test @@ -175,8 +171,7 @@ Response Payload: Request Payload ``` { - "region_code": "AMD", - "name": "Auto Moro Dewe" + "region_code": "INTL" } ``` @@ -186,70 +181,6 @@ Response Payload ``` { "status_code": "cdc-400", - "status_message": "company_id is required", - "data": null -} -``` - -#### Case : Negative Case 7 - -Request Payload : -``` -{ - "region_code": "AMD", - "name": "Auto Moro Dewe", - "company_id": "" -} -``` - -Response HTTP Status Code : 400 - -Response Payload: -``` -{ - "status_code": "cdc-400", - "status_message": "company_id is empty", - "data": null -} -``` - -#### Case : Negative Case 8 - -Request Payload -``` -{ - "region_code": "AMD", - "name": "Auto Moro Dewe", - "company_id": "ngasal" -} -``` - -Response HTTP Status Code : 404 - -Response Payload -``` -{ - "status_code": "cdc-404", - "status_message": "company_id not found", - "data": null -} -``` - -#### Case : Negative Case 9 - -Request Payload -``` -{ - "region_code": "INTL" -} -``` - -Response HTTP Status Code : 404 - -Response Payload -``` -{ - "status_code": "cdc-404", "status_message": "region_code already in use", "data": null } @@ -262,23 +193,22 @@ Request Payload : { "region_code": "AMD", "name": "Auto Moro Dewe" - "company_id": "12" } ``` -Response HTTP Status Code : 200 +Response HTTP Status Code : 201 Response Payload : ``` { - "status_code": "CDC-200", - "status_message": "OK", + "status_code": "CDC-201", + "status_message": "Created", "data": { - "id":"7", + "id":"5e6c4216-360c-11eb-8f39-5600024efe02", "region_code" : "AMD", "name" : "Auto Moro Dewe", "company_code" : "BKNINTEL", - "company_id" : "12", + "company_id" : "d58edc03-360c-11eb-8f39-5600024efe02", "created" : "2020-12-02 09:03:44", "modified" : "2020-12-02 09:03:44", } @@ -295,137 +225,35 @@ Key | Value --- | --- Content-Type | application/json Accept | application/json - -### Request Payloads -Name | Type | Example Value ---- | --- | --- -id | string | 7 -``` -{ - "id": "7", -} -``` +Email | application/json ### Response Payloads HTTP Code | Status | Description --- | --- | --- -400 | Bad Request | Bad request payload -404 | Not Found | User not found in database +404 | Not Found | Region not found in database 500 | Internal Server Error | some un-handle error in server 200 | OK | OK -``` -{ - "status_code": "CDC-400", - "status_message": "Bad Request", - "data": null -} -``` ``` { "status_code": "CDC-200", "status_message": "OK", "data": { - "id":"7", + "id":"5e6c4216-360c-11eb-8f39-5600024efe02", "region_code" : "AMD", "name" : "Auto Moro Dewe", "company_code" : "BKNINTEL", - "company_id" : "12", + "company_id" : "d58edc03-360c-11eb-8f39-5600024efe02", "created" : "2020-12-02 09:03:44", "modified" : "2020-12-02 09:03:44", } } ``` -### Logic - -#### Validation -- id : required and not empty - ### Scenario Test -#### Case : Negative Case 1 - -Request Payload : empty - -Response HTTP Status Code : 400 - -Response Payload : -``` -{ - "status_code": "cdc-400", - "status_message": "id is required", - "data": null -} -``` - -#### Case : Negative Case 2 - -Request Payload : -``` -{} -``` - -Response HTTP Status Code : 400 - -Response Payload : -``` -{ - "status_code": "cdc-400", - "status_message": "id is required", - "data": null -} -``` - -#### Case : Negative Case 3 - -Request payload : -``` -{ - "id": "" -} -``` - -Response HTTP Status Code : 400 - -Response Payload : -``` -{ - "status_code": "cdc-400", - "status_message": "id is empty", - "data": null -} -``` - -#### Case : Negative Case 4 - -Request Payload -``` -{ - "id": "ngasal" -} -``` - -Response HTTP Status Code : 404 - -Response Payload -``` -{ - "status_code": "cdc-404", - "status_message": "id not found", - "data": null -} -``` - #### Case : Positive Case -Request Payload : -``` -{ - "id": "7", -} -``` - Response HTTP Status Code : 200 Response Payload : @@ -434,11 +262,11 @@ Response Payload : "status_code": "CDC-200", "status_message": "OK", "data": { - "id":"7", + "id":"5e6c4216-360c-11eb-8f39-5600024efe02", "region_code" : "AMD", "name" : "Auto Moro Dewe", "company_code" : "BKNINTEL", - "company_id" : "12", + "company_id" : "d58edc03-360c-11eb-8f39-5600024efe02", "created" : "2020-12-02 09:03:44", "modified" : "2020-12-02 09:03:44", } @@ -455,20 +283,17 @@ Key | Value --- | --- Content-Type | application/json Accept | application/json +Email | application/json ### Request Payloads Name | Type | Example Value --- | --- | --- -id | string | 7 region_code | string | MMT name | string | Monggo Moro Tumbas -company_id | string | 12 ``` { - "id": "7", "region_code": "MMT", "name": "Monggo Moro Tumbas" - "company_id": "12" } ``` @@ -476,7 +301,7 @@ company_id | string | 12 HTTP Code | Status | Description --- | --- | --- 400 | Bad Request | Bad request payload -404 | Not Found | User not found in database +404 | Not Found | Region not found in database 500 | Internal Server Error | some un-handle error in server 200 | OK | OK ``` @@ -492,11 +317,11 @@ HTTP Code | Status | Description "status_code": "CDC-200", "status_message": "OK", "data": { - "id":"7", + "id":"5e6c4216-360c-11eb-8f39-5600024efe02", "region_code" : "MMT", "name" : "Monggo Moro Tumbas", "company_code" : "BKNINTEL", - "company_id" : "12", + "company_id" : "d58edc03-360c-11eb-8f39-5600024efe02", "created" : "2020-12-02 09:03:44", "modified" : "2020-12-02 09:03:44", } @@ -506,10 +331,8 @@ HTTP Code | Status | Description ### Logic #### Validation -- id : required and not empty -- region_code : not empty +- region_code : not empty and unique - name : not empty -- company_id : not empty ### Scenario Test @@ -523,7 +346,7 @@ Response Payload : ``` { "status_code": "cdc-400", - "status_message": "id is required", + "status_message": "region_code is required", "data": null } ``` @@ -541,151 +364,66 @@ Response Payload : ``` { "status_code": "cdc-400", - "status_message": "id is required", + "status_message": "region_code is required", "data": null } ``` #### Case : Negative Case 3 -Request payload : -``` -{ - "id": "" -} -``` - -Response HTTP Status Code : 400 - -Response Payload : -``` -{ - "status_code": "cdc-400", - "status_message": "id is empty", - "data": null -} -``` - -#### Case : Negative Case 4 - -Request Payload -``` -{ - "id": "ngasal" -} -``` - -Response HTTP Status Code : 404 - -Response Payload -``` -{ - "status_code": "cdc-404", - "status_message": "id not found", - "data": null -} -``` - -#### Case : Negative Case 5 - Request Payload ``` { - "id": "7", "region_code": "" } ``` -Response HTTP Status Code : 404 +Response HTTP Status Code : 400 Response Payload ``` { - "status_code": "cdc-404", + "status_code": "cdc-400", "status_message": "region_code is empty", "data": null } ``` -#### Case : Negative Case 6 +#### Case : Negative Case 4 Request Payload ``` { - "id": "7", "name": "" } ``` -Response HTTP Status Code : 404 +Response HTTP Status Code : 400 Response Payload ``` { - "status_code": "cdc-404", + "status_code": "cdc-400", "status_message": "name is empty", "data": null } ``` -#### Case : Negative Case 7 - -Request Payload -``` -{ - "id": "7", - "company_id": "" -} -``` - -Response HTTP Status Code : 404 - -Response Payload -``` -{ - "status_code": "cdc-404", - "status_message": "company_id is empty", - "data": null -} -``` - -#### Case : Negative Case 8 - -Request Payload -``` -{ - "id": "7", - "company_id": "ngarang" -} -``` - -Response HTTP Status Code : 404 - -Response Payload -``` -{ - "status_code": "cdc-404", - "status_message": "company_id not found", - "data": null -} -``` - -#### Case : Negative Case 9 +#### Case : Negative Case 5 Request Payload ``` { - "id": "7", "region_code": "INTL" } ``` -Response HTTP Status Code : 404 +Response HTTP Status Code : 400 Response Payload ``` { - "status_code": "cdc-404", + "status_code": "cdc-400", "status_message": "region_code already in use", "data": null } @@ -696,35 +434,6 @@ Response Payload Request Payload : ``` { - "id": "7", -} -``` - -Response HTTP Status Code : 200 - -Response Payload : -``` -{ - "status_code": "CDC-200", - "status_message": "OK", - "data": { - "id":"7", - "region_code" : "AMD", - "name" : "Auto Moro Dewe", - "company_code" : "BKNINTEL", - "company_id" : "12", - "created" : "2020-12-02 09:03:44", - "modified" : "2020-12-02 10:03:44", - } -} -``` - -#### Case : Positive Case 2 - -Request Payload : -``` -{ - "id": "7", "region_code": "MMT", } ``` @@ -737,23 +446,22 @@ Response Payload : "status_code": "CDC-200", "status_message": "OK", "data": { - "id":"7", + "id":"5e6c4216-360c-11eb-8f39-5600024efe02", "region_code" : "MMT", "name" : "Auto Moro Dewe", "company_code" : "BKNINTEL", - "company_id" : "12", + "company_id" : "d58edc03-360c-11eb-8f39-5600024efe02", "created" : "2020-12-02 09:03:44", "modified" : "2020-12-02 10:03:44", } } ``` -#### Case : Positive Case 3 +#### Case : Positive Case 2 Request Payload : ``` { - "id": "7", "name": "Monggo Moro Tumbas", } ``` @@ -766,40 +474,11 @@ Response Payload : "status_code": "CDC-200", "status_message": "OK", "data": { - "id":"7", + "id":"5e6c4216-360c-11eb-8f39-5600024efe02", "region_code" : "AMD", "name" : "Monggo Moro Tumbas", "company_code" : "BKNINTEL", - "company_id" : "12", - "created" : "2020-12-02 09:03:44", - "modified" : "2020-12-02 10:03:44", - } -} -``` - -#### Case : Positive Case 4 - -Request Payload : -``` -{ - "id": "7", - "company_id": "15", -} -``` - -Response HTTP Status Code : 200 - -Response Payload : -``` -{ - "status_code": "CDC-200", - "status_message": "OK", - "data": { - "id":"7", - "region_code" : "AMD", - "name" : "Monggo Moro Tumbas", - "company_code" : "RIJEN", - "company_id" : "15", + "company_id" : "d58edc03-360c-11eb-8f39-5600024efe02", "created" : "2020-12-02 09:03:44", "modified" : "2020-12-02 10:03:44", } @@ -814,138 +493,36 @@ DELETE /regions/:id ### Headers Key | Value --- | --- -Content-Type | application/json +Content-Type | * Accept | application/json - -### Request Payloads -Name | Type | Example Value ---- | --- | --- -id | string | 7 -``` -{ - "id": "7", -} -``` +Email | application/json ### Response Payloads HTTP Code | Status | Description --- | --- | --- -400 | Bad Request | Bad request payload -404 | Not Found | User not found in database +404 | Not Found | Region not found in database 500 | Internal Server Error | some un-handle error in server -200 | OK | OK -``` -{ - "status_code": "CDC-400", - "status_message": "Bad Request", - "data": null -} -``` +204 | No content | No content ``` { - "status_code": "CDC-200", - "status_message": "OK", + "status_code": "CDC-204", + "status_message": "No content", "data": null } ``` -### Logic - -#### Validation -- id : required and not empty - ### Scenario Test -#### Case : Negative Case 1 - -Request Payload : empty - -Response HTTP Status Code : 400 - -Response Payload : -``` -{ - "status_code": "cdc-400", - "status_message": "id is required", - "data": null -} -``` - -#### Case : Negative Case 2 - -Request Payload : -``` -{} -``` - -Response HTTP Status Code : 400 - -Response Payload : -``` -{ - "status_code": "cdc-400", - "status_message": "id is required", - "data": null -} -``` - -#### Case : Negative Case 3 - -Request payload : -``` -{ - "id": "" -} -``` - -Response HTTP Status Code : 400 - -Response Payload : -``` -{ - "status_code": "cdc-400", - "status_message": "id is empty", - "data": null -} -``` - -#### Case : Negative Case 4 - -Request Payload -``` -{ - "id": "ngasal" -} -``` - -Response HTTP Status Code : 404 - -Response Payload -``` -{ - "status_code": "cdc-404", - "status_message": "id not found", - "data": null -} -``` - #### Case : Positive Case -Request Payload : -``` -{ - "id": "7", -} -``` - -Response HTTP Status Code : 200 +Response HTTP Status Code : 204 Response Payload : ``` { - "status_code": "CDC-200", - "status_message": "OK", + "status_code": "CDC-204", + "status_message": "No content", "data": null } ``` \ No newline at end of file