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

[RFC] Modify "Archive users not In discord" API endpoint name #149

Open
manish591 opened this issue Aug 17, 2023 · 6 comments
Open

[RFC] Modify "Archive users not In discord" API endpoint name #149

manish591 opened this issue Aug 17, 2023 · 6 comments
Assignees
Labels

Comments

@manish591
Copy link
Contributor

Summary

The API that deals with updating the Archived role to true if the user is not in our discord was put under the PATCH /users endpoint with a request body differentiating it from the previous API that exists for the same route.

But, this API is not following the best API naming convention as it is not representing the resources it is modifying correctly.

This RFC aims at finding the API name that follows a better API naming convention.

Description

We have created a new API that will mark all the users Archived that are not in our discord i.e. set the archived=true for users that have in_discord=false.

Initially, the API name was PATCH /users/update-archived. As this is not correct because the verb is defined by the action PATCH so adding update in the endpoint is not correct.

Then, possible route names are proposed.

  1. PATCH /users/archived
  2. PATCH /users/archivedUsers

As in these routes archived is not representing a resource another solution proposed was,

Put the API under PATCH /users by defining the proper body. This is the current implementation.

Here is the API contact: https://github.com/Real-Dev-Squad/website-api-contracts/tree/main/users#patch-users

@manish591 manish591 added the RFC label Aug 17, 2023
@manish591 manish591 self-assigned this Aug 17, 2023
@manish591
Copy link
Contributor Author

@RitikJaiswal75 @apurvkhare @prakashchoudhary07 @sahsisunny @DashDeipayan @heyrandhir Please share your thoughts on this.

@RitikJaiswal75
Copy link

APIs Should represent the resource they are accessing I think it should just be
POST as PATCH here is used for a singular update, but the functionality of the API is to update multiple users

I would prefer the API name to be POST on `/users'
any action that it performs can go into the request body
something like

{
    action: "archive"
    on: "in_discord"
}

@manish591
Copy link
Contributor Author

APIs Should represent the resource they are accessing I think it should just be POST as PATCH here is used for a singular update, but the functionality of the API is to update multiple users

I would prefer the API name to be POST on `/users' any action that it performs can go into the request body something like

{
    action: "archive"
    on: "in_discord"
}

There exists another API on the same endpoint /users. This API marks users unverified. If we go with this approach again we have to update the previously implemented API definition as well.

@prakashchoudhary07 @heyrandhir @apurvkhare What's you thoughts on this?

@manish591
Copy link
Contributor Author

manish591 commented Aug 18, 2023

APIs Should represent the resource they are accessing I think it should just be POST as PATCH here is used for a singular update, but the functionality of the API is to update multiple users

I would prefer the API name to be POST on `/users' any action that it performs can go into the request body something like

{
    action: "archive"
    on: "in_discord"
}

Also, I don't understand why we used POST here. POST is supposed to be used when we are creating new resources. But, here we are just updating the existing archived property on the user's resources. Can you please explain?

@heyrandhir
Copy link
Contributor

There exists another API on the same endpoint /users. This API marks users unverified. If we go with this approach again we have to update the previously implemented API definition as well.

I think we would need to update the previous api then. Based on request body it should perform the unverified action. while as @RitikJaiswal75 suggested based on specific key such as

{
    action: "archive"
    on: "in_discord"
}

you can perform your action and similarly assign some other key for unverified action.

@manish591
Copy link
Contributor Author

manish591 commented Aug 19, 2023

Based on this Discussion:

  1. For archive users not in discord API
  POST /users

  Request Body

  {
    "action": "archive",
    "on": "in_discord"
  }
  1. For marking users unverified in discord API
  POST /users

  Request Body

  {
    "action": "unverified",
    "on": "discord_unlinked"
  }

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

No branches or pull requests

3 participants