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

[Backend] Feature Request: Pin Notes #541

Closed
PatilShreyas opened this issue Oct 5, 2022 · 13 comments · Fixed by #546, #558 or #559
Closed

[Backend] Feature Request: Pin Notes #541

PatilShreyas opened this issue Oct 5, 2022 · 13 comments · Fixed by #546, #558 or #559
Assignees
Labels
enhancement New feature or request hacktoberfest For partifipating in Hacktoberfest noty-api
Projects
Milestone

Comments

@PatilShreyas
Copy link
Owner

PatilShreyas commented Oct 5, 2022

This is regarding feature "pinning notes" as discussed here: #534

This also needs to be implemented on the backend side so that the state of the pinning of notes will be persisted.

Task

Create an API for updating the note's pin.

API Contract

Request

PUT /note/<NOTE_ID>/pin
Content-Type: application/json
Authorization: Bearer <TOKEN>

{
  "isPinned": true
}

Response

1. When note gets pinned/unpinned successfully

Response Code: 200

{
  "status": "SUCCESS",
  "message": "Note is pinned/unpinned successfully",
  "noteId": <NOTE ID>
}
2. When note note exist in system

Response Code: 404

{
  "status": "NOT_FOUND",
  "message": "Note not exist with ID '$noteId'"
}
3. When unauthorized user tries to update note pin

Response Code: 401

{
  "status": "UNAUTHORIZED",
  "message": "Access denied"
}
@PatilShreyas PatilShreyas added the hacktoberfest For partifipating in Hacktoberfest label Oct 5, 2022
@PatilShreyas PatilShreyas added this to the v2.1.0 milestone Oct 5, 2022
@PatilShreyas PatilShreyas added enhancement New feature or request noty-api labels Oct 5, 2022
@mrfamouskk7
Copy link
Contributor

Heyy @PatilShreyas I can take this up... should I start working on this feature??

@PatilShreyas
Copy link
Owner Author

PatilShreyas commented Oct 5, 2022

Thanks for showing interest in contributing this @mrfamouskk7. Sure, Assigning this to you.

@mrfamouskk7
Copy link
Contributor

Thanks for showing interest in contributing this @mrfamouskk7. Sure, Assigning this to you.

Thanks @PatilShreyas

@PatilShreyas
Copy link
Owner Author

Let me know if you need any help in setting up this project locally.

@mrfamouskk7
Copy link
Contributor

Actually, I am done with local setup.
I just had a question, so isPinned flag will be required while fetching notes as well right? So should I include that in same PR??

@PatilShreyas
Copy link
Owner Author

Yes, it'll be required to have isPinned flag in all notes response. If you're fine with doing it in the same PR, then okay. Otherwise we can also have a dedicated PR for that.

@PatilShreyas
Copy link
Owner Author

@mrfamouskk7 Current API looks good to you?

Otherwise, we can also have two API endpoints for pin and unpin operations.

Like,

  • PUT /note/{noteId}/pin
  • PUT /note/{noteId}/unpin

This will not require a request body.

WDYT?

@mrfamouskk7
Copy link
Contributor

I think both the ways should okay:

  • Single API with body
  • Separate APIs without body

But it seems unusual/unconventional to have PUT/POST request without body.
Single API with body should be the ideal way to implement.

@mrfamouskk7
Copy link
Contributor

Yes, it'll be required to have isPinned flag in all notes response. If you're fine with doing it in the same PR, then okay. Otherwise we can also have a dedicated PR for that.

I will include in the same PR

@PatilShreyas
Copy link
Owner Author

I think both the ways should okay:

  • Single API with body
  • Separate APIs without body

But it seems unusual/unconventional to have PUT/POST request without body.
Single API with body should be the ideal way to implement.

Makes sense!

@mrfamouskk7
Copy link
Contributor

mrfamouskk7 commented Oct 6, 2022

Heyy Shreyash, so I have a couple of suggestions:

  • Pinning API can be changed from PUT request to a PATCH request. PATCH is more suitable because we are not updating the complete resource here.
  • A new field updated can be added to notes so that the most recent pinned note will be at the top

WDYT?

@PatilShreyas
Copy link
Owner Author

@mrfamouskk7 this sounds good to me. Definitely we can have updated field

@mrfamouskk7
Copy link
Contributor

Sure... I will add those changes in the same PR 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest For partifipating in Hacktoberfest noty-api
Projects
No open projects
NotyKT
Awaiting triage
2 participants