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

Api contract for POST user/picture #81

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 46 additions & 7 deletions users/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@

## **Requests**

| Route | Description |
|:-------------------------------------:|:------------------------------------:|
| [GET /users](#get-users) | Returns all users in the system |
| [GET /users/self](#get-usersSelf) | Returns the logged in user's details |
| [GET /users/:id](#get-usersid) | Returns user with given id |
| [POST /users](#post-users) | Creates a new User |
| [PATCH /users/self](#patch-usersself) | Updates data of the User |
| Route | Description |
| :---------------------------------------: | :----------------------------------: |
| [GET /users](#get-users) | Returns all users in the system |
| [GET /users/self](#get-usersSelf) | Returns the logged in user's details |
| [GET /users/:id](#get-usersid) | Returns user with given id |
| [POST /users](#post-users) | Creates a new User |
| [PATCH /users/self](#patch-usersself) | Updates data of the User |
| [POST /users/picture](#post-userspicture) | Uploads user profile picture |


## **GET /users**
Expand Down Expand Up @@ -187,3 +188,41 @@ Updates data of the User.
- **Content:** `{ 'statusCode': 403, 'error': 'Forbidden', 'message': 'Cannot update username again'}`
- **Code:** 503
- **Content:** `{ 'statusCode': 503, 'error': 'Service Unavailable', 'message': 'Something went wrong please contact admin' }`


## **POST /users/picture**

Upload user proflie picture.

- **Params**
- **in**: formData
- **name**: profile
- **type**: file
- **description**: Profile picture to upload
- **Query**
None
- **Headers**
Content-Type: multipart/form-data
- **Cookie**
rds-session: `<JWT>`
- **Body** `{ 'image':{'publicId':'image publicId','url':'imageURl'} }`
- **Success Response:**
- **Code:** 200
- **Content:** `{ 'message': 'Profile picture uploaded successfully', 'image':{'publicId':'image publicId','url':'imageURl'} }`
- **Error Response:**
- **Code:** 401
- **Content:** `{ 'statusCode': 401, 'error': 'Unauthorized', 'message': 'Unauthenticated User' }`
- **Code:** 404
- **Content:** `{ 'statusCode': 404, 'error': 'Not Found', 'message': 'User not found' }`
- **Code:** 413
- **Content:** `{ 'statusCode': 413, 'error': 'File too large', 'message': 'File too large' }`
- **Code:** 415
- **Content:** `{ 'statusCode': 415, 'error': 'Unsupported media type', 'message': 'Invalid content-type header: ${contentType}, expected: application/json or multipart/form-data' }`
- **Code:** 500
- **Content:** `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }`

**Note**
- Consumes only [multipart/form-data](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
- Accepts only image/png, image/jpeg
- Image should be attached to Formfiled with name *'profile'*
- Max image size allowed is **2MB**