OBGM-570 Fix replenishment not being saved on next step of replenishment workflow#4167
Conversation
| "/api/replenishments/$id/"(parseRequest: true) { | ||
| controller = { "replenishmentApi" } | ||
| action = [GET: "read", POST: "create", PUT: "update"] | ||
| action = [GET: "read", POST: "update"] |
There was a problem hiding this comment.
I'd rather change on the frontend side, that update method is called with PUT, instead of changing the mapping for not correct one regarding REST standards
There was a problem hiding this comment.
sure, I guess PUT for an update makes much more sense than a POST.
I didn't want to do it since it does change the API a little bit and it seems that previously the POST method was used for update
| if (jsonObject.status) { | ||
| replenishment.status = ReplenishmentStatus.valueOf(jsonObject.status) | ||
| } | ||
|
|
There was a problem hiding this comment.
out of curiosity - what problem did it cause? Is it binded correctly without that?
|
|
||
| order.save(failOnError: true) | ||
| if (order.hasErrors() || !order.save(failOnError: true)) { | ||
| throw new grails.validation.ValidationException("Invalid order", order.errors) |
There was a problem hiding this comment.
let's import the exception on top of the file, and call it throw new ValidationException for better visibility ;)
There was a problem hiding this comment.
makes sense, will do
|
@drodzewicz don't forget about these mappings |
| "/api/replenishments/$id/"(parseRequest: true) { | ||
| controller = { "replenishmentApi" } | ||
| action = [GET: "read", POST: "create", PUT: "update"] | ||
| action = [GET: "read", PUT: "update"] |
There was a problem hiding this comment.
Change POST to link to "update" action. It's not REST-compliant but it's what a developer would expect if they posted to an endpoint for a resource with an ID.
| const url = `/api/replenishments/${this.props.match.params.replenishmentId}`; | ||
| const payload = { status: 'COMPLETED' }; | ||
| apiClient.post(url, flattenRequest(payload)) | ||
| apiClient.put(url, flattenRequest(payload)) |
There was a problem hiding this comment.
I'm ok with either post or put here, but we can tech-huddle this if necessary. Lazy developers like myself will exclusively use GET and POST when testing an API so I don't mind supporting that.
However, there are some resources where this would be confusing and unexpected so we should definitely be conscious of what we're doing and explicit / restrictive where possible.
Here's another long-winded argument for supporting either approach.
I don't yet know where I stand.
|
@drodzewicz @awalkowiak @kchelstowski @alannadolny FWIW, you can regenerate a report of all URL mappings. However, I don't think this is any more helpful than the UrlMappings.groovy class. |

No description provided.