Update function
(ctx *fiber.Ctx)
| 93 | |
| 94 | // Update function |
| 95 | func (teamEndpoint *TeamEndpoint) Update(ctx *fiber.Ctx) error { |
| 96 | me, _ := teamEndpoint.CurrentUser(ctx) |
| 97 | if can := teamEndpoint.Can(ctx, models.AdminRole); !can { |
| 98 | return ctx.Status(401).JSON(fiber.Map{ |
| 99 | "message": "You are not authorized to perform this action", |
| 100 | }) |
| 101 | } |
| 102 | |
| 103 | var inputMap = make(map[string]interface{}) |
| 104 | ctx.BodyParser(&inputMap) |
| 105 | |
| 106 | v := validate.Map(inputMap) |
| 107 | v.StringRule("name", "string") |
| 108 | |
| 109 | if !v.Validate() { |
| 110 | return ctx.Status(422).JSON(v.Errors) |
| 111 | } |
| 112 | |
| 113 | updateTeam, err := teamService.Update(ctx.Params("id"), me.AccountID, v.SafeData()) |
| 114 | if err != nil { |
| 115 | return ctx.Status(404).JSON(fiber.Map{ |
| 116 | "message": err.Error(), |
| 117 | }) |
| 118 | } |
| 119 | |
| 120 | showTeam := models.ShowTeamSerializer().Transform(updateTeam) |
| 121 | return ctx.JSON(showTeam) |
| 122 | } |
| 123 | |
| 124 | // Delete function |
| 125 | func (teamEndpoint *TeamEndpoint) Delete(ctx *fiber.Ctx) error { |
nothing calls this directly
no test coverage detected