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 implementation for DELETE /users/:userId/saved-opportunities/:oppId #3304

Open
1 of 4 tasks
chouinar opened this issue Dec 18, 2024 · 1 comment
Open
1 of 4 tasks
Assignees

Comments

@chouinar
Copy link
Collaborator

chouinar commented Dec 18, 2024

Summary

This endpoint should follow the standard pattern for our API endpoints. We should put the business logic in a separate service file, the API implementation itself should be as simple as shown below.

... other decorators
@user_blueprint.auth_required(api_jwt_auth)
@flask_db.with_db_session()
def my_endpoint(db_session: db.Session, user_id) -> response.ApiResponse:
     user_token_session: UserTokenSession = api_jwt_auth.current_user  # type: ignore

     if user_token_session.user_id != user_id:
           raise_flask_error(401, "Unauthorized user)

     with db_session.begin():
          data = some_function_in_service_file(db_session, user_id)

     return response.ApiResponse("Success", data=data)    

Acceptance criteria

  • Error if the user_id of the authenticated user does not match the one from the path (only a user can access their own data)
  • Error if the record does not exist in the table (404)
  • Deletes the record
  • Unit tests added for error cases and happy cases
@chouinar chouinar changed the title Add implementation for DELETE /users/saved-opportunities Add implementation for DELETE /users/:userId/saved-opportunities/:oppId Dec 18, 2024
@mikehgrantsgov mikehgrantsgov self-assigned this Dec 27, 2024
@mikehgrantsgov mikehgrantsgov moved this from Icebox to In Review in Simpler.Grants.gov Product Backlog Dec 27, 2024
@mikehgrantsgov
Copy link
Collaborator

This is covered in PR 3358

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

No branches or pull requests

2 participants