UpdateClient updates a client by its id. swagger:operation PUT /client/{id} client updateClient Update a client. --- consumes: [application/json] produces: [application/json] security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []] parameters:
(ctx *gin.Context)
| 82 | // schema: |
| 83 | // $ref: "#/definitions/Error" |
| 84 | func (a *ClientAPI) UpdateClient(ctx *gin.Context) { |
| 85 | withID(ctx, "id", func(id uint) { |
| 86 | client, err := a.DB.GetClientByID(id) |
| 87 | if success := successOrAbort(ctx, 500, err); !success { |
| 88 | return |
| 89 | } |
| 90 | if client != nil && client.UserID == auth.GetUserID(ctx) { |
| 91 | newValues := ClientParams{} |
| 92 | if err := ctx.Bind(&newValues); err == nil { |
| 93 | client.Name = newValues.Name |
| 94 | |
| 95 | if success := successOrAbort(ctx, 500, a.DB.UpdateClient(client)); !success { |
| 96 | return |
| 97 | } |
| 98 | ctx.JSON(200, client) |
| 99 | } |
| 100 | } else { |
| 101 | ctx.AbortWithError(404, fmt.Errorf("client with id %d doesn't exists", id)) |
| 102 | } |
| 103 | }) |
| 104 | } |
| 105 | |
| 106 | // CreateClient creates a client and returns the access token. |
| 107 | // swagger:operation POST /client client createClient |
nothing calls this directly
no test coverage detected