add modules specs

This commit is contained in:
Tit Petric
2018-07-05 13:52:20 +02:00
parent 1e46a4549a
commit 9ecc041b0d
3 changed files with 148 additions and 1 deletions
+79 -1
View File
@@ -27,4 +27,82 @@ Types are building blocks for module forms
| Parameter | Type | Method | Description | Default | Required? |
| --------- | ---- | ------ | ----------- | ------- | --------- |
| id | string | PATH | Type ID | N/A | YES |
| id | string | PATH | Type ID | N/A | YES |
# Modules
CRM module definitions
## List defined modules
#### Method
| URI | Protocol | Method | Authentication |
| --- | -------- | ------ | -------------- |
| `/modules/list` | HTTP/S | GET | |
#### Request parameters
| Parameter | Type | Method | Description | Default | Required? |
| --------- | ---- | ------ | ----------- | ------- | --------- |
| id | string | GET | Module ID | N/A | NO |
## Add/edit module
#### Method
| URI | Protocol | Method | Authentication |
| --- | -------- | ------ | -------------- |
| `/modules/edit` | HTTP/S | POST | |
#### Request parameters
| Parameter | Type | Method | Description | Default | Required? |
| --------- | ---- | ------ | ----------- | ------- | --------- |
| id | uint64 | POST | Module ID | N/A | NO |
| name | string | POST | Module Name | N/A | YES |
## List contents from module section
#### Method
| URI | Protocol | Method | Authentication |
| --- | -------- | ------ | -------------- |
| `/modules/content/list` | HTTP/S | GET | |
#### Request parameters
| Parameter | Type | Method | Description | Default | Required? |
| --------- | ---- | ------ | ----------- | ------- | --------- |
## Add/update contents in module section
#### Method
| URI | Protocol | Method | Authentication |
| --- | -------- | ------ | -------------- |
| `/modules/content/edit` | HTTP/S | POST | |
#### Request parameters
| Parameter | Type | Method | Description | Default | Required? |
| --------- | ---- | ------ | ----------- | ------- | --------- |
| id | uint64 | POST | Content ID | N/A | NO |
| payload | string | POST | Content JSON | N/A | YES |
## Delete content row from module section
#### Method
| URI | Protocol | Method | Authentication |
| --- | -------- | ------ | -------------- |
| `/modules/content/delete` | HTTP/S | DELETE | |
#### Request parameters
| Parameter | Type | Method | Description | Default | Required? |
| --------- | ---- | ------ | ----------- | ------- | --------- |
| id | uint64 | POST | Content ID | N/A | YES |
+61
View File
@@ -25,5 +25,66 @@
}
}
]
},
{
"title": "Modules",
"description": "CRM module definitions",
"package": "crm",
"entrypoint": "modules",
"path": "modules",
"authentication": [],
"struct": [
{ "name": "id", "type": "uint64" },
{ "name": "name", "type": "string" }
],
"apis": [
{
"name": "list",
"method": "GET",
"title": "List defined modules",
"parameters": {
"get": [
{ "type": "string", "name": "id", "title": "Module ID" }
]
}
},
{
"name": "edit",
"method": "POST",
"title": "Add/edit module",
"parameters": {
"post": [
{ "type": "uint64", "name": "id", "required": false, "title": "Module ID" },
{ "type": "string", "name": "name", "required": true, "title": "Module Name" }
]
}
},
{
"name": "content/list",
"method": "GET",
"title": "List contents from module section"
},
{
"name": "content/edit",
"method": "POST",
"title": "Add/update contents in module section",
"parameters": {
"post": [
{ "type": "uint64", "name": "id", "required": false, "title": "Content ID" },
{ "type": "string", "name": "payload", "required": true, "title": "Content JSON" }
]
}
},
{
"name": "content/delete",
"method": "DELETE",
"title": "Delete content row from module section",
"parameters": {
"post": [
{ "type": "uint64", "name": "id", "required": true, "title": "Content ID" }
]
}
}
]
}
]
+8
View File
@@ -5,7 +5,15 @@ import (
)
func MountRoutes(r chi.Router) {
modules := ModulesHandlers{}.new()
types := TypesHandlers{}.new()
r.Route("/modules", func(r chi.Router) {
r.Get("/list", modules.List)
r.Post("/edit", modules.Edit)
r.Get("/content/list", modules.ContentList)
r.Post("/content/edit", modules.ContentEdit)
r.Delete("/content/delete", modules.ContentDelete)
})
r.Route("/types", func(r chi.Router) {
r.Get("/list", types.List)
r.Get("/type/{id}", types.Type)