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 Contracts for /qr-code-auth Endpoint #134

Merged
merged 18 commits into from
Jun 18, 2023
Merged
Changes from 7 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
286 changes: 286 additions & 0 deletions qr-code-auth/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
# Collection - QrCodeAuth

heyrandhir marked this conversation as resolved.
Show resolved Hide resolved
## API Endpoints

| Route | Description |
| :--------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------: |
| [POST /qr-code-auth](#post-qr-code-auth) | Creates a new authentication document. |
| [GET /qr-code-auth](#get-qr-code-auth) | Retrieves all the authentication document belonging to a specified user |
| [PATCH /qr-code-auth](#patch-qr-code-authuser_iduser_idis_authorizedis_authorized) | Updates the is_authorized field of an existing qr-code-auth document for the specified user. |

## POST /qr-code-auth

Creates a new qr-code-auth document.

- **Params**
None
- **Query**
None
- **Body**
- Attributes
sakshambhatt marked this conversation as resolved.
Show resolved Hide resolved
- **device_info** (required, string): Specifies the device information associated with the authentication authentication.
heyrandhir marked this conversation as resolved.
Show resolved Hide resolved
- **is_authorized** (required, boolean): Indicates whether the authentication document is authorized or not.
- **access_token** (required, string): Specifies the access token associated with the authentication document.
- **Headers**
- Content-Type: application/json
- **Cookie**
- rds-session: `<JWT>`
heyrandhir marked this conversation as resolved.
Show resolved Hide resolved
- **Success Response:**
- **Code:** 201
- **Content:**
```json
{
"message": "String",
"data": {
"user_id": "String",
"device_info": "String",
"is_authorized": "Boolean",
"access_token": "String"
}
}
```
- **Error Response:**

- **Code:** 400

- **Content:**
```json
{
"message": "Bad Request"
}
```

- **Code:** 401
- **Content:**
```json
{
"statusCode": 401,
"error": "Unauthorized",
"message": "Unauthenticated User."
}
```
- **Code:** 409
- **Content:**
```json
{
"message": "The authentication document has already been created"
}
```
- **Code:** 500
- **Content:**
```json
{
"message": "The server has encountered an unexpected error. Please contact the administrator for more information."
}
```

- **Example for user authentication document creation request:**
POST /qr-code-auth<br/>
Content-Type: application/json<br/>
Request-Body:<br/>

```json
{
"device_info": "t5k77PHnuDSrgEzvMJAj",
"is_authorized": true,
"access_token": "NLFSj7Kz30oHgolfIZtJ"
}
```

Response :
Status 201<br/>
Content-Type: application/json<br/>

```json
{
"data": {
"user_id": "SooJK37gzjIZfFNH0tlL",
"device_info": "t5k77PHnuDSrgEzvMJAj",
"is_authorized": true,
"access_token": "NLFSj7Kz30oHgolfIZtJ"
},
"message": "authentication document created successfully."
}
```

## GET /qr-code-auth

Retrieves THE authentication document.

- **Params**
None
- **Query**

- user_id : Specifies the ID of the User whose authentication document will be retrieved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added user_id as well to filter the document on the basis of user_id since we don't have device_id stored in our database.


- **Body**
None
- **Headers**
None
- **Cookie**
None
- **Success Response:**

- **Code:** 200

- **Content:**

```json
{
"message": "String",
"data": {
"user_id": "String",
"device_info": "String",
sakshambhatt marked this conversation as resolved.
Show resolved Hide resolved
"is_authorized": "Boolean",
"access_token": "String"
}
}
```

- **Error Response:**

- **Code:** 400

- **Content:**
```json
{
"message": "Bad Request"
}
```

- **Code:** 404
- **Content:**
```json
{
"message": "User with id <:id> does not exist."
}
```
- **Code:** 500
- **Content:**
```json
{
"message": "The server has encountered an unexpected error. Please contact the administrator for more information."
}
```

- **Example:**
GET /qr-code-auth?user_id=SooJK37gzjIZfFNH0tlL<br/>
Status: 200 OK<br/>
```json
{
"message": "Authentication document retrieved successfully.",
"data": {
"user_id": "SooJK37gzjIZfFNH0tlL",
"device_info": "t5k77PHnuDSrgEzvMJAj",
"is_authorized": true,
"access_token": "NLFSj7Kz30oHgolfIZtJ"
}
}
```
GET /qr-code-auth?user_id=invalidUserId<br/>
Status: 404 Not Found<br/>
```json
{
"message": "No Authentication authentication found."
}
```
GET /qr-code-auth?taskId=GTB4UUtlKwGemRN2lwBp11<br/>
Status: 400 Bad Request
```json
{
"statusCode": 400,
"error": "Bad Request",
"message": "invalid query parameters passed"
}
```
GET /?user_id=GTB4UUtlKwGemRN2lwBp11
Status: 500 Internal Server Error
```json
{
"message": "The server has encountered an unexpected error. Please contact the administrator for more information."
}
```

Sure, here's the updated API contract for the PATCH call:

## PATCH /qr-code-auth/is_authorized/{is_authorized}

Updates the is_authorized field of an existing qr-code-auth document for the specified user.

- **Params**
- **is_authorized** (required, boolean): Specifies whether the authentication document is authorized or not.
- **Query**
None
- **Headers**
Content-Type: application/json
- **Cookie**
rds-session: `<JWT>`
- **Success Response:**
- **Code:** 200
- **Content:**
```json
{
"message": "String",
"data": {
"user_id": "String",
"device_info": "String",
"is_authorized": "Boolean",
"access_token": "String"
}
}
```
- **Error Response:**

- **Code:** 400

- **Content:**
```json
{
"message": "Bad Request"
}
```

- **Code:** 401
- **Content:**
```json
{
"statusCode": 401,
"error": "Unauthorized",
"message": "Unauthenticated User."
}
```
- **Code:** 404
- **Content:**
```json
{
"message": "Document not found"
}
```
- **Code:** 500
- **Content:**
```json
{
"message": "The server has encountered an unexpected error. Please contact the administrator for more information."
}
```

- **Example for updating an existing authentication document:**
PATCH /qr-code-auth/is_authorized/true<br/>
Content-Type: application/json<br/>
Request-Body:<br/>
None
Response :
Status 200 OK <br/>
Content-Type: application/json<br/>

```json
{
"data": {
"user_id": "SooJK37gzjIZfFNH0tlL",
"device_info": "t5k77PHnuDSrgEzvMJAj",
"is_authorized": true,
"access_token": "NLFSj7Kz30oHgolfIZtJ"
isVivek99 marked this conversation as resolved.
Show resolved Hide resolved
},
"message": "Authentication document for user SooJK37gzjIZfFNH0tlL updated successfully."
}
```