Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Resource Completion Status Update Endpoint for Cooperations #1005

Merged
merged 14 commits into from
Dec 3, 2024

Conversation

luiqor
Copy link
Contributor

@luiqor luiqor commented Nov 27, 2024

Add Resource Completion Status Update Endpoint for student to be able to mark cooperation as 'completed' or 'active'

PR where completionStatus field was added to model: #966

API Endpoint

PATCH /cooperations/{id}/{resourceId}/completionStatus

Changes

  • add a method in a service
  • add a method in a controller
  • add a validation schema
  • add integration tests for the endpoint
  • add swagger documentation for the endpoint

Previews

Successful update:

bandicam.2024-11-27.19-09-35-038.mp4

Not valid completionStatus error preview:

image

An clear error message indicating that this action is restricted to the student role:

  • It is not a secret and should be known that only students can perform this action

image-1

@luiqor luiqor added documentation Improvements or additions to documentation enhancement New feature or request Backend labels Nov 27, 2024
@luiqor luiqor self-assigned this Nov 27, 2024
@@ -69,17 +71,8 @@ const cooperationService = {
throw createError(409, VALIDATION_ERROR('You can change only either the status or the price in one operation'))
}

const cooperation = await Cooperation.findById(id).exec()
if (!cooperation) {
Copy link
Contributor Author

@luiqor luiqor Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this check because we already have middleware for patch coopeation/{id} endpoint that performs the same validation, but returns a 400 error instead:

{
  "status": 400,
  "code": "INVALID_ID",
  "message": "ID is invalid."
}

src/services/cooperation.js Outdated Show resolved Hide resolved
@nebby2105 nebby2105 self-requested a review December 3, 2024 16:07
@luiqor luiqor merged commit 38ab22e into develop Dec 3, 2024
3 checks passed
@luiqor luiqor deleted the feature/958/endpoint-for-cooperation-resource-status branch December 3, 2024 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(SP: 3) Add an endpoint for changing cooperation resource status
4 participants