From 9ecc041b0d5710915bdb910804e41f558668a675 Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Thu, 5 Jul 2018 13:52:20 +0200 Subject: [PATCH] add modules specs --- crm/docs/README.md | 80 +++++++++++++++++++++++++++++++++++++++++- crm/docs/src/spec.json | 61 ++++++++++++++++++++++++++++++++ crm/routes.go | 8 +++++ 3 files changed, 148 insertions(+), 1 deletion(-) diff --git a/crm/docs/README.md b/crm/docs/README.md index 7fe802d6a..a063bdbb7 100644 --- a/crm/docs/README.md +++ b/crm/docs/README.md @@ -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 | \ No newline at end of file +| 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 | \ No newline at end of file diff --git a/crm/docs/src/spec.json b/crm/docs/src/spec.json index 8abd49935..399e7a6e1 100644 --- a/crm/docs/src/spec.json +++ b/crm/docs/src/spec.json @@ -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" } + ] + } + } + ] } ] \ No newline at end of file diff --git a/crm/routes.go b/crm/routes.go index 22fdfdca6..4542061c8 100644 --- a/crm/routes.go +++ b/crm/routes.go @@ -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)