diff --git a/app/module/article_approval_flows/article_approval_flows.module.go b/app/module/article_approval_flows/article_approval_flows.module.go index 78ecbca..75d3bf5 100644 --- a/app/module/article_approval_flows/article_approval_flows.module.go +++ b/app/module/article_approval_flows/article_approval_flows.module.go @@ -56,6 +56,7 @@ func (_i *ArticleApprovalFlowsRouter) RegisterArticleApprovalFlowsRoutes() { router.Get("/:id/next-steps-preview", articleApprovalFlowsController.GetNextStepsPreview) router.Post("/submit", articleApprovalFlowsController.SubmitForApproval) router.Post("/:id/multi-branch-approve", articleApprovalFlowsController.ProcessMultiBranchApproval) + router.Post("/articles/:articleId/approve", articleApprovalFlowsController.ApproveArticleByFlow) router.Put("/:id/approve", articleApprovalFlowsController.Approve) router.Put("/:id/reject", articleApprovalFlowsController.Reject) router.Put("/:id/request-revision", articleApprovalFlowsController.RequestRevision) diff --git a/app/module/article_approval_flows/controller/article_approval_flows.controller.go b/app/module/article_approval_flows/controller/article_approval_flows.controller.go index b044970..20898a3 100644 --- a/app/module/article_approval_flows/controller/article_approval_flows.controller.go +++ b/app/module/article_approval_flows/controller/article_approval_flows.controller.go @@ -39,6 +39,9 @@ type ArticleApprovalFlowsController interface { // Multi-branch support methods ProcessMultiBranchApproval(c *fiber.Ctx) error GetNextStepsPreview(c *fiber.Ctx) error + + // Simplified approval by article ID + ApproveArticleByFlow(c *fiber.Ctx) error } func NewArticleApprovalFlowsController(articleApprovalFlowsService service.ArticleApprovalFlowsService, usersRepo usersRepository.UsersRepository, log zerolog.Logger) ArticleApprovalFlowsController { @@ -748,3 +751,70 @@ func (_i *articleApprovalFlowsController) GetNextStepsPreview(c *fiber.Ctx) erro }, }) } + +// ApproveArticleByFlow approves an article using its active approval flow +// @Summary Approve article by its active approval flow +// @Description API for approving an article using its currently active approval flow (simplified version) +// @Tags ArticleApprovalFlows +// @Security Bearer +// @Param Authorization header string true "Insert the Authorization" +// @Param articleId path int true "Article ID" +// @Param payload body request.ApprovalActionRequest true "Required payload" +// @Success 200 {object} response.Response +// @Failure 400 {object} response.BadRequestError +// @Failure 401 {object} response.UnauthorizedError +// @Failure 500 {object} response.InternalServerError +// @Router /article-approval-flows/articles/{articleId}/approve [post] +func (_i *articleApprovalFlowsController) ApproveArticleByFlow(c *fiber.Ctx) error { + articleId, err := strconv.Atoi(c.Params("articleId")) + if err != nil { + return utilRes.ErrorBadRequest(c, "Invalid article ID format") + } + + req := new(request.ApprovalActionRequest) + if err := c.BodyParser(req); err != nil { + return utilRes.ErrorBadRequest(c, "Invalid request body") + } + + if err := utilVal.ParseAndValidate(c, req); err != nil { + return err + } + + // Get Authorization token from header + authToken := c.Get("Authorization") + if authToken == "" { + return utilRes.ErrorBadRequest(c, "Authorization token required") + } + + user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) + if user == nil { + return utilRes.ErrorBadRequest(c, "Invalid authorization token") + } + + // Find active approval flow for the article + activeFlow, err := _i.articleApprovalFlowsService.FindActiveByArticleId(uint(articleId)) + if err != nil { + return utilRes.Resp(c, utilRes.Response{ + Success: false, + Messages: utilRes.Messages{"No active approval flow found for this article"}, + }) + } + + // Process approval using multi-branch logic + err = _i.articleApprovalFlowsService.ProcessMultiBranchApproval(authToken, activeFlow.ID, user.ID, req.Message) + if err != nil { + return err + } + + return utilRes.Resp(c, utilRes.Response{ + Success: true, + Messages: utilRes.Messages{"Article successfully approved through active approval flow"}, + Data: map[string]interface{}{ + "article_id": articleId, + "flow_id": activeFlow.ID, + "current_step": activeFlow.CurrentStep, + "current_branch": activeFlow.CurrentBranch, + "workflow_id": activeFlow.WorkflowId, + }, + }) +} diff --git a/app/module/article_approval_flows/service/article_approval_flows.service.go b/app/module/article_approval_flows/service/article_approval_flows.service.go index 145849a..61899cc 100644 --- a/app/module/article_approval_flows/service/article_approval_flows.service.go +++ b/app/module/article_approval_flows/service/article_approval_flows.service.go @@ -67,6 +67,7 @@ type ArticleApprovalFlowsService interface { IsStepApplicableForLevel(step *entity.ApprovalWorkflowSteps, submitterLevelId uint) (isApplicable bool, err error) ProcessParallelBranches(authToken string, flow *entity.ArticleApprovalFlows, nextSteps []*entity.ApprovalWorkflowSteps, approvedById uint, message string) (err error) GetUserLevelId(authToken string, userId uint) (userLevelId uint, err error) + FindActiveByArticleId(articleId uint) (flow *entity.ArticleApprovalFlows, err error) } func NewArticleApprovalFlowsService( @@ -1377,3 +1378,7 @@ func (_i *articleApprovalFlowsService) completeApprovalFlow(flow *entity.Article func (_i *articleApprovalFlowsService) GetUserLevelId(authToken string, userId uint) (userLevelId uint, err error) { return _i.getUserLevelId(authToken, userId) } + +func (_i *articleApprovalFlowsService) FindActiveByArticleId(articleId uint) (flow *entity.ArticleApprovalFlows, err error) { + return _i.ArticleApprovalFlowsRepository.FindActiveByArticleId(articleId) +} diff --git a/docs/API_APPROVE_ARTICLE_BY_FLOW.md b/docs/API_APPROVE_ARTICLE_BY_FLOW.md new file mode 100644 index 0000000..7d06140 --- /dev/null +++ b/docs/API_APPROVE_ARTICLE_BY_FLOW.md @@ -0,0 +1,206 @@ +# API Approve Article by Active Flow + +## ๐Ÿš€ **Overview** + +API ini adalah versi yang disederhanakan dari approval process. User cukup memasukkan article ID dan sistem akan otomatis menggunakan approval flow yang sedang aktif untuk artikel tersebut. Tidak perlu mengetahui flow ID atau step yang sedang berjalan. + +## ๐Ÿ“‹ **Endpoint** + +``` +POST /api/article-approval-flows/articles/{articleId}/approve +``` + +## ๐Ÿ”ง **Request Body** + +```json +{ + "message": "Article looks good, approved for next level" +} +``` + +## ๐Ÿ“ **Field Descriptions** + +- `message` (optional): Pesan approval yang akan dicatat dalam log + +## ๐Ÿ“ค **Response** + +### **Success Response (200):** +```json +{ + "success": true, + "messages": ["Article successfully approved through active approval flow"], + "data": { + "article_id": 123, + "flow_id": 456, + "current_step": 2, + "current_branch": "Branch_A", + "workflow_id": 1 + } +} +``` + +### **Error Response (400) - No Active Flow:** +```json +{ + "success": false, + "messages": ["No active approval flow found for this article"] +} +``` + +### **Error Response (400) - Invalid Article ID:** +```json +{ + "success": false, + "messages": ["Invalid article ID format"] +} +``` + +## ๐Ÿงช **Curl Examples** + +### **1. Approve Article dengan Message:** +```bash +curl -X POST "http://localhost:8080/api/article-approval-flows/articles/123/approve" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer YOUR_TOKEN" \ + -d '{ + "message": "Article content is good, approved for next level" + }' +``` + +### **2. Approve Article tanpa Message:** +```bash +curl -X POST "http://localhost:8080/api/article-approval-flows/articles/123/approve" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer YOUR_TOKEN" \ + -d '{}' +``` + +### **3. Approve Article dengan Message Spesifik:** +```bash +curl -X POST "http://localhost:8080/api/article-approval-flows/articles/123/approve" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer YOUR_TOKEN" \ + -d '{ + "message": "Reviewed and approved. Content meets quality standards." + }' +``` + +## ๐Ÿ”„ **How It Works** + +1. **Input**: User hanya perlu memberikan article ID +2. **Find Active Flow**: Sistem mencari approval flow yang aktif untuk artikel tersebut +3. **Multi-Branch Logic**: Sistem menggunakan multi-branch approval logic yang sudah ada +4. **Process Approval**: Approval diproses sesuai dengan workflow yang sedang berjalan +5. **Response**: Return informasi tentang approval yang telah diproses + +## ๐ŸŽฏ **Benefits** + +### **Before (Complex):** +```bash +# User perlu tahu flow ID dan step +curl -X POST "http://localhost:8080/api/article-approval-flows/456/multi-branch-approve" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer YOUR_TOKEN" \ + -d '{"message": "Approved"}' +``` + +### **After (Simple):** +```bash +# User hanya perlu tahu article ID +curl -X POST "http://localhost:8080/api/article-approval-flows/articles/123/approve" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer YOUR_TOKEN" \ + -d '{"message": "Approved"}' +``` + +## ๐Ÿ”’ **Authentication** + +API ini memerlukan authentication token. Token harus disertakan di header: + +``` +Authorization: Bearer YOUR_JWT_TOKEN +``` + +## โš ๏ธ **Important Notes** + +1. **Active Flow Required**: Artikel harus memiliki approval flow yang aktif +2. **Multi-Branch Support**: Menggunakan multi-branch approval logic yang sudah ada +3. **Automatic Detection**: Sistem otomatis mendeteksi flow yang sedang aktif +4. **User Level Validation**: Approval hanya bisa dilakukan oleh user dengan level yang sesuai +5. **Workflow Progression**: Approval akan mengikuti workflow yang sudah dikonfigurasi + +## ๐Ÿšจ **Error Handling** + +### **Common Errors:** + +1. **No Active Flow (400)**: + - Artikel tidak memiliki approval flow yang aktif + - Approval flow sudah selesai atau dibatalkan + +2. **Invalid Article ID (400)**: + - Article ID tidak valid atau tidak ditemukan + +3. **Authentication Error (401)**: + - Invalid atau missing token + - Expired token + +4. **Authorization Error (403)**: + - User tidak memiliki permission untuk approve artikel ini + - User level tidak sesuai dengan step yang sedang berjalan + +5. **Server Error (500)**: + - Database error + - Workflow processing error + +## ๐Ÿ”„ **Workflow Integration** + +API ini terintegrasi dengan: + +- โœ… **Multi-Branch Approval Logic** +- โœ… **User Level Validation** +- โœ… **Workflow Step Progression** +- โœ… **Approval History Logging** +- โœ… **Notification System** + +## ๐Ÿ“Š **Use Cases** + +1. **Simple Approval**: User yang tidak perlu tahu detail workflow +2. **Mobile App**: Interface yang sederhana untuk mobile +3. **Bulk Operations**: Approve multiple articles dengan script +4. **Third-party Integration**: API yang mudah digunakan oleh sistem eksternal + +## ๐Ÿ”„ **Comparison with Existing APIs** + +| Feature | Old API | New API | +|---------|---------|---------| +| **Complexity** | High (need flow ID) | Low (only article ID) | +| **User Experience** | Complex | Simple | +| **Error Handling** | Manual flow detection | Automatic | +| **Multi-Branch** | โœ… Supported | โœ… Supported | +| **Workflow Logic** | โœ… Full control | โœ… Automatic | + +## ๐ŸŽ‰ **Migration Guide** + +### **From Old API:** +```bash +# Old way +curl -X POST "http://localhost:8080/api/article-approval-flows/456/multi-branch-approve" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer YOUR_TOKEN" \ + -d '{"message": "Approved"}' +``` + +### **To New API:** +```bash +# New way (simpler) +curl -X POST "http://localhost:8080/api/article-approval-flows/articles/123/approve" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer YOUR_TOKEN" \ + -d '{"message": "Approved"}' +``` + +--- + +**๐ŸŽ‰ API ini memberikan pengalaman yang lebih sederhana dan user-friendly untuk proses approval artikel!** + +User tidak perlu lagi mengetahui flow ID atau step yang sedang berjalan - cukup masukkan article ID dan sistem akan menangani sisanya secara otomatis. ๐Ÿš€ diff --git a/docs/SIMPLIFIED_APPROVAL_API_GUIDE.md b/docs/SIMPLIFIED_APPROVAL_API_GUIDE.md new file mode 100644 index 0000000..84cd3bd --- /dev/null +++ b/docs/SIMPLIFIED_APPROVAL_API_GUIDE.md @@ -0,0 +1,251 @@ +# Simplified Article Approval API - Usage Guide + +## ๐ŸŽฏ **Overview** + +API baru ini menyederhanakan proses approval artikel. Sebelumnya user perlu mengetahui flow ID dan step yang sedang berjalan, sekarang cukup dengan article ID saja. + +## ๐Ÿ”„ **Before vs After** + +### **โŒ Before (Complex):** +```bash +# User perlu tahu flow ID (456) dan step yang sedang berjalan +curl -X POST "http://localhost:8080/api/article-approval-flows/456/multi-branch-approve" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer YOUR_TOKEN" \ + -d '{"message": "Approved"}' +``` + +### **โœ… After (Simple):** +```bash +# User hanya perlu tahu article ID (123) +curl -X POST "http://localhost:8080/api/article-approval-flows/articles/123/approve" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer YOUR_TOKEN" \ + -d '{"message": "Approved"}' +``` + +## ๐Ÿš€ **New Endpoint** + +``` +POST /api/article-approval-flows/articles/{articleId}/approve +``` + +## ๐Ÿ“‹ **Request Format** + +```json +{ + "message": "Your approval message here" +} +``` + +## ๐Ÿงช **Practical Examples** + +### **1. Approve Article dari User Level 3 (Branch A):** +```bash +curl -X POST "http://localhost:8080/api/article-approval-flows/articles/10/approve" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer USER_LEVEL_3_TOKEN" \ + -d '{ + "message": "Content reviewed and approved. Ready for final approval." + }' +``` + +**Expected Response:** +```json +{ + "success": true, + "messages": ["Article successfully approved through active approval flow"], + "data": { + "article_id": 10, + "flow_id": 1, + "current_step": 2, + "current_branch": "Final_Approval", + "workflow_id": 1 + } +} +``` + +### **2. Approve Article dari User Level 2 (Final Approval):** +```bash +curl -X POST "http://localhost:8080/api/article-approval-flows/articles/10/approve" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer USER_LEVEL_2_TOKEN" \ + -d '{ + "message": "Final approval granted. Article ready for publication." + }' +``` + +**Expected Response:** +```json +{ + "success": true, + "messages": ["Article successfully approved through active approval flow"], + "data": { + "article_id": 10, + "flow_id": 1, + "current_step": 3, + "current_branch": "Final_Approval", + "workflow_id": 1 + } +} +``` + +### **3. Approve Article tanpa Message:** +```bash +curl -X POST "http://localhost:8080/api/article-approval-flows/articles/10/approve" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer YOUR_TOKEN" \ + -d '{}' +``` + +## ๐Ÿ” **How It Works Internally** + +1. **Input**: Article ID (123) +2. **Find Active Flow**: + ```sql + SELECT * FROM article_approval_flows + WHERE article_id = 123 AND status_id = 1 + ``` +3. **Get Flow Info**: + - Flow ID: 456 + - Current Step: 2 + - Current Branch: "Branch_A" + - Workflow ID: 1 +4. **Process Approval**: Menggunakan multi-branch logic +5. **Update Flow**: Step dan branch diupdate sesuai workflow +6. **Response**: Return informasi yang relevan + +## ๐ŸŽฏ **Benefits** + +### **1. Simplified User Experience** +- โœ… Tidak perlu tahu flow ID +- โœ… Tidak perlu tahu step yang sedang berjalan +- โœ… Tidak perlu tahu branch yang aktif +- โœ… Cukup masukkan article ID + +### **2. Reduced Complexity** +- โœ… API call lebih sederhana +- โœ… Error handling lebih mudah +- โœ… Integration lebih straightforward +- โœ… Maintenance lebih mudah + +### **3. Better Error Messages** +- โœ… "No active approval flow found" - jelas dan informatif +- โœ… "Invalid article ID format" - mudah dipahami +- โœ… Automatic flow detection - tidak perlu manual check + +## ๐Ÿ”„ **Integration Examples** + +### **Frontend Integration:** +```javascript +// Simple approval function +async function approveArticle(articleId, message = '') { + const response = await fetch(`/api/article-approval-flows/articles/${articleId}/approve`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${token}` + }, + body: JSON.stringify({ message }) + }); + + const result = await response.json(); + return result; +} + +// Usage +approveArticle(123, 'Content looks good!'); +``` + +### **Mobile App Integration:** +```javascript +// React Native example +const approveArticle = async (articleId) => { + try { + const response = await fetch(`${API_BASE}/article-approval-flows/articles/${articleId}/approve`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${userToken}` + }, + body: JSON.stringify({ + message: 'Approved from mobile app' + }) + }); + + const result = await response.json(); + if (result.success) { + Alert.alert('Success', 'Article approved successfully!'); + } else { + Alert.alert('Error', result.messages[0]); + } + } catch (error) { + Alert.alert('Error', 'Failed to approve article'); + } +}; +``` + +## ๐Ÿšจ **Error Scenarios** + +### **1. No Active Flow:** +```bash +curl -X POST "http://localhost:8080/api/article-approval-flows/articles/999/approve" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer YOUR_TOKEN" \ + -d '{"message": "Approved"}' +``` + +**Response:** +```json +{ + "success": false, + "messages": ["No active approval flow found for this article"] +} +``` + +### **2. Invalid Article ID:** +```bash +curl -X POST "http://localhost:8080/api/article-approval-flows/articles/invalid/approve" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer YOUR_TOKEN" \ + -d '{"message": "Approved"}' +``` + +**Response:** +```json +{ + "success": false, + "messages": ["Invalid article ID format"] +} +``` + +## ๐Ÿ“Š **Testing Scenarios** + +### **Test Case 1: Normal Approval Flow** +1. Create article dengan user level 5 +2. Article otomatis masuk ke Branch A (Level 2 A Branch) +3. User level 3 approve โ†’ masuk ke Final Approval +4. User level 2 approve โ†’ artikel published + +### **Test Case 2: Branch B Flow** +1. Create article dengan user level 6 +2. Article otomatis masuk ke Branch B (Level 2 B Branch) +3. User level 4 approve โ†’ masuk ke Final Approval +4. User level 2 approve โ†’ artikel published + +### **Test Case 3: Error Handling** +1. Try approve artikel yang tidak ada approval flow +2. Try approve dengan user level yang tidak sesuai +3. Try approve artikel yang sudah selesai + +## ๐ŸŽ‰ **Summary** + +API baru ini memberikan: + +- โœ… **Simplified Interface**: Cukup article ID +- โœ… **Automatic Flow Detection**: Sistem otomatis cari flow aktif +- โœ… **Multi-Branch Support**: Tetap mendukung multi-branch logic +- โœ… **Better UX**: User experience yang lebih baik +- โœ… **Easy Integration**: Mudah diintegrasikan dengan frontend/mobile + +**Sekarang user tidak perlu lagi repot dengan flow ID atau step yang sedang berjalan - cukup masukkan article ID dan sistem akan menangani sisanya!** ๐Ÿš€ diff --git a/docs/swagger/docs.go b/docs/swagger/docs.go index 0e34ccd..5e57c5f 100644 --- a/docs/swagger/docs.go +++ b/docs/swagger/docs.go @@ -2471,6 +2471,71 @@ const docTemplate = `{ } } }, + "/article-approval-flows/articles/{articleId}/approve": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for approving an article using its currently active approval flow (simplified version)", + "tags": [ + "ArticleApprovalFlows" + ], + "summary": "Approve article by its active approval flow", + "parameters": [ + { + "type": "string", + "description": "Insert the Authorization", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "integer", + "description": "Article ID", + "name": "articleId", + "in": "path", + "required": true + }, + { + "description": "Required payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.ApprovalActionRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.UnauthorizedError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.InternalServerError" + } + } + } + } + }, "/article-approval-flows/dashboard-stats": { "get": { "security": [ @@ -9644,6 +9709,64 @@ const docTemplate = `{ } } }, + "/clients/with-user": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for creating a client and its admin user in a single request", + "tags": [ + "Clients" + ], + "summary": "Create client with admin user", + "parameters": [ + { + "type": "string", + "default": "Bearer \u003cAdd access token here\u003e", + "description": "Insert your access token", + "name": "Authorization", + "in": "header" + }, + { + "description": "Required payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.ClientWithUserCreateRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.UnauthorizedError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.InternalServerError" + } + } + } + } + }, "/clients/{id}": { "get": { "security": [ @@ -16247,6 +16370,59 @@ const docTemplate = `{ } } }, + "request.AdminUserCreateRequest": { + "type": "object", + "required": [ + "email", + "fullname", + "password", + "username" + ], + "properties": { + "address": { + "type": "string" + }, + "dateOfBirth": { + "type": "string" + }, + "email": { + "type": "string" + }, + "fullname": { + "type": "string" + }, + "genderType": { + "type": "string" + }, + "identityGroup": { + "type": "string" + }, + "identityGroupNumber": { + "type": "string" + }, + "identityNumber": { + "type": "string" + }, + "identityType": { + "type": "string" + }, + "lastEducation": { + "type": "string" + }, + "password": { + "type": "string" + }, + "phoneNumber": { + "type": "string" + }, + "username": { + "type": "string" + }, + "workType": { + "type": "string" + } + } + }, "request.AdvertisementCreateRequest": { "type": "object", "required": [ @@ -17035,6 +17211,31 @@ const docTemplate = `{ } } }, + "request.ClientWithUserCreateRequest": { + "type": "object", + "required": [ + "adminUser", + "client" + ], + "properties": { + "adminUser": { + "description": "Admin user information", + "allOf": [ + { + "$ref": "#/definitions/request.AdminUserCreateRequest" + } + ] + }, + "client": { + "description": "Client information", + "allOf": [ + { + "$ref": "#/definitions/request.ClientsCreateRequest" + } + ] + } + } + }, "request.ClientsCreateRequest": { "type": "object", "required": [ diff --git a/docs/swagger/swagger.json b/docs/swagger/swagger.json index 7f160bd..88166db 100644 --- a/docs/swagger/swagger.json +++ b/docs/swagger/swagger.json @@ -2460,6 +2460,71 @@ } } }, + "/article-approval-flows/articles/{articleId}/approve": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for approving an article using its currently active approval flow (simplified version)", + "tags": [ + "ArticleApprovalFlows" + ], + "summary": "Approve article by its active approval flow", + "parameters": [ + { + "type": "string", + "description": "Insert the Authorization", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "integer", + "description": "Article ID", + "name": "articleId", + "in": "path", + "required": true + }, + { + "description": "Required payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.ApprovalActionRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.UnauthorizedError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.InternalServerError" + } + } + } + } + }, "/article-approval-flows/dashboard-stats": { "get": { "security": [ @@ -9633,6 +9698,64 @@ } } }, + "/clients/with-user": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "API for creating a client and its admin user in a single request", + "tags": [ + "Clients" + ], + "summary": "Create client with admin user", + "parameters": [ + { + "type": "string", + "default": "Bearer \u003cAdd access token here\u003e", + "description": "Insert your access token", + "name": "Authorization", + "in": "header" + }, + { + "description": "Required payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.ClientWithUserCreateRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.BadRequestError" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.UnauthorizedError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.InternalServerError" + } + } + } + } + }, "/clients/{id}": { "get": { "security": [ @@ -16236,6 +16359,59 @@ } } }, + "request.AdminUserCreateRequest": { + "type": "object", + "required": [ + "email", + "fullname", + "password", + "username" + ], + "properties": { + "address": { + "type": "string" + }, + "dateOfBirth": { + "type": "string" + }, + "email": { + "type": "string" + }, + "fullname": { + "type": "string" + }, + "genderType": { + "type": "string" + }, + "identityGroup": { + "type": "string" + }, + "identityGroupNumber": { + "type": "string" + }, + "identityNumber": { + "type": "string" + }, + "identityType": { + "type": "string" + }, + "lastEducation": { + "type": "string" + }, + "password": { + "type": "string" + }, + "phoneNumber": { + "type": "string" + }, + "username": { + "type": "string" + }, + "workType": { + "type": "string" + } + } + }, "request.AdvertisementCreateRequest": { "type": "object", "required": [ @@ -17024,6 +17200,31 @@ } } }, + "request.ClientWithUserCreateRequest": { + "type": "object", + "required": [ + "adminUser", + "client" + ], + "properties": { + "adminUser": { + "description": "Admin user information", + "allOf": [ + { + "$ref": "#/definitions/request.AdminUserCreateRequest" + } + ] + }, + "client": { + "description": "Client information", + "allOf": [ + { + "$ref": "#/definitions/request.ClientsCreateRequest" + } + ] + } + } + }, "request.ClientsCreateRequest": { "type": "object", "required": [ diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index 43403fc..f9dac0d 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -69,6 +69,42 @@ definitions: - id - url type: object + request.AdminUserCreateRequest: + properties: + address: + type: string + dateOfBirth: + type: string + email: + type: string + fullname: + type: string + genderType: + type: string + identityGroup: + type: string + identityGroupNumber: + type: string + identityNumber: + type: string + identityType: + type: string + lastEducation: + type: string + password: + type: string + phoneNumber: + type: string + username: + type: string + workType: + type: string + required: + - email + - fullname + - password + - username + type: object request.AdvertisementCreateRequest: properties: description: @@ -612,6 +648,20 @@ definitions: - id - prov_id type: object + request.ClientWithUserCreateRequest: + properties: + adminUser: + allOf: + - $ref: '#/definitions/request.AdminUserCreateRequest' + description: Admin user information + client: + allOf: + - $ref: '#/definitions/request.ClientsCreateRequest' + description: Client information + required: + - adminUser + - client + type: object request.ClientsCreateRequest: properties: clientType: @@ -3384,6 +3434,49 @@ paths: summary: Get approval analytics tags: - ArticleApprovalFlows + /article-approval-flows/articles/{articleId}/approve: + post: + description: API for approving an article using its currently active approval + flow (simplified version) + parameters: + - description: Insert the Authorization + in: header + name: Authorization + required: true + type: string + - description: Article ID + in: path + name: articleId + required: true + type: integer + - description: Required payload + in: body + name: payload + required: true + schema: + $ref: '#/definitions/request.ApprovalActionRequest' + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/response.UnauthorizedError' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.InternalServerError' + security: + - Bearer: [] + summary: Approve article by its active approval flow + tags: + - ArticleApprovalFlows /article-approval-flows/dashboard-stats: get: description: API for getting dashboard statistics @@ -7931,6 +8024,43 @@ paths: summary: Bulk create sub-clients tags: - Clients + /clients/with-user: + post: + description: API for creating a client and its admin user in a single request + parameters: + - default: Bearer + description: Insert your access token + in: header + name: Authorization + type: string + - description: Required payload + in: body + name: payload + required: true + schema: + $ref: '#/definitions/request.ClientWithUserCreateRequest' + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.BadRequestError' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/response.UnauthorizedError' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.InternalServerError' + security: + - Bearer: [] + summary: Create client with admin user + tags: + - Clients /custom-static-pages: get: description: API for getting all CustomStaticPages