|
| 1 | +# discord-actions |
| 2 | + |
| 3 | +## **Requests** |
| 4 | + |
| 5 | +| Route | Description | |
| 6 | +| :-----------------------------------------------------: | :------------------------------: | |
| 7 | +| [GET /discord-actions/invites](#get-discord-actions-invites) | return all the invites generated | |
| 8 | +| [POST /discord-actions/invites](#post-discord-actions-invites) | generates a invite for a user | |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +## **GET /discord-actions/invite** |
| 13 | + |
| 14 | +- return the discord invite created for the user |
| 15 | + |
| 16 | +- **Query** |
| 17 | + |
| 18 | + - Optional: `userId=[string]`: if this is provided it returns the invite of the user whose userId is provided in the query param, if the user is not a super user then this should be equal to the userId of the user, if no userId is provided, it return invite for the user who has made the request |
| 19 | + |
| 20 | +- **Headers** |
| 21 | + None |
| 22 | +- **Cookie** |
| 23 | + rds-session: `<JWT>` |
| 24 | + |
| 25 | +- **Success Response:** |
| 26 | + |
| 27 | + - **Code:** 200 |
| 28 | + - **Content:** |
| 29 | + ```json |
| 30 | + { |
| 31 | + "message": "Invite return successfully!", |
| 32 | + "inviteLink": "discord_invite_link_here" |
| 33 | + } |
| 34 | + ``` |
| 35 | + |
| 36 | +- **Error Responses:** |
| 37 | + |
| 38 | + - **Code:** 401 |
| 39 | + - **Content:** |
| 40 | + ```json |
| 41 | + { |
| 42 | + "statusCode": 401, |
| 43 | + "error": "Unauthorized", |
| 44 | + "message": "You are not authorized for this action." |
| 45 | + } |
| 46 | + ``` |
| 47 | + - **Code:** 403 |
| 48 | + |
| 49 | + - **Content:** |
| 50 | + ```json |
| 51 | + { |
| 52 | + "message": "You do not have permission to access this resource." |
| 53 | + } |
| 54 | + ``` |
| 55 | + - **Code:** 404 |
| 56 | + |
| 57 | + - **Content:** |
| 58 | + ```json |
| 59 | + { |
| 60 | + "message": "Invite not found for user!" |
| 61 | + } |
| 62 | + ``` |
| 63 | + |
| 64 | + - **Code:** 500 |
| 65 | + - **Content:** |
| 66 | + ```json |
| 67 | + { |
| 68 | + "statusCode": 500, |
| 69 | + "error": "Internal Server Error", |
| 70 | + "message": "Something went wrong. Please contact admin" |
| 71 | + } |
| 72 | + ``` |
| 73 | + |
| 74 | +## **POST /discord/invites** |
| 75 | + |
| 76 | +- This Api is used to create a discord invite for the user, invite for a particular user can be generated by a super user or a that user only, invite for a particular user can be created only once, Following conditions will be there for creating invite for the user: |
| 77 | +- The user should not be archieved |
| 78 | +- The user should have one of these roles, if they want to directly generate a invite: product_manager, designer, maven |
| 79 | +- If they don't have the roles mentioned above, they should have profileStatus approved |
| 80 | + |
| 81 | +- **Params**\ |
| 82 | + None |
| 83 | +- **Query**\ |
| 84 | + - Optional: `userId=[string]`: if this is provided it create the invite for that userId if the user is a super user, if this is not provided it create invite for the user making the request |
| 85 | +- **Body**\ |
| 86 | + None |
| 87 | +- **Headers**\ |
| 88 | + None |
| 89 | +- **Cookie**\ |
| 90 | + None |
| 91 | +- **Success Response:** |
| 92 | + |
| 93 | + - **Code:** 201 |
| 94 | + - **Content:** |
| 95 | + ```json |
| 96 | + { |
| 97 | + "message": "Invite created successfully.", |
| 98 | + "inviteLink": "string" |
| 99 | + } |
| 100 | + ``` |
| 101 | + - **Code:** 401 |
| 102 | + - **Content:** |
| 103 | + ```json |
| 104 | + { |
| 105 | + "statusCode": 401, |
| 106 | + "error": "Unauthorized", |
| 107 | + "message": "Unauthenticated user" |
| 108 | + } |
| 109 | + ``` |
| 110 | + - **Code:** 409 |
| 111 | + |
| 112 | + - **Content:** |
| 113 | + ```json |
| 114 | + { |
| 115 | + "message": "User invite is already present!" |
| 116 | + } |
| 117 | + ``` |
| 118 | + |
| 119 | + - **Code:** 403 |
| 120 | + - **Content:** |
| 121 | + ```json |
| 122 | + { |
| 123 | + "statusCode": 403, |
| 124 | + "error": "Forbidden", |
| 125 | + "message": "User should be super user to generate link for other users" "||" "Only users who have never joined discord can generate invite link" "||" "Archived users cannot generate invite" "||" "Only selected roles can generate discord link directly" |
| 126 | + } |
| 127 | + ``` |
| 128 | + |
| 129 | +- **Error Response:** |
| 130 | + - **Code:** 500 |
| 131 | + - **Content:** |
| 132 | + ```json |
| 133 | + { |
| 134 | + "statusCode": 500, |
| 135 | + "error": "Internal Server Error", |
| 136 | + "message": "An internal server error occurred" |
| 137 | + } |
| 138 | + ``` |
| 139 | + ``` |
| 140 | + |
| 141 | + ``` |
0 commit comments