Skip to content
Closed
Show file tree
Hide file tree
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: 12 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,25 @@ object, with the user's profile information if requested.

#### Request Parameters

| **Parameter** | **Optional** | **Type** | **Default** | **Description** |
| ------------------------- | ------------ | ----------- | ----------- | ----------------------------------------------------------------------------------------------- |
| `username` | No | `str` | | The user's SRN or PRN |
| `password` | No | `str` | | The user's password |
| `profile` | Yes | `boolean` | `False` | Whether to fetch profile information |
| `knowYourClassAndSection` | Yes | `boolean` | `False` | Whether to fetch data from PESU's "Know Your Class and Section" information |
| `fields` | Yes | `list[str]` | `None` | Which fields to fetch from the profile information. If not provided, all fields will be fetched |
| **Parameter** | **Optional** | **Type** | **Default** | **Description** |
| ------------- | ------------ | ----------- | ----------- | ----------------------------------------------------------------------------------------------- |
| `username` | No | `str` | | The user's SRN or PRN |
| `password` | No | `str` | | The user's password |
| `profile` | Yes | `boolean` | `False` | Whether to fetch profile information |
| `fields` | Yes | `list[str]` | `None` | Which fields to fetch from the profile information. If not provided, all fields will be fetched |

#### Response Object

On authentication, it returns the following parameters in a JSON object. If the authentication was successful and
profile data was requested, the response's `profile` key will store a dictionary with a user's profile information.
**On an unsuccessful sign-in, this field will not exist**.

| **Field** | **Type** | **Description** |
| ------------------------- | ------------------------------- | ----------------------------------------------------------------------------------------------- |
| `status` | `boolean` | A flag indicating whether the overall request was successful |
| `profile` | `ProfileObject` | A nested map storing the profile information, returned only if requested |
| `knowYourClassAndSection` | `KnowYourClassAndSectionObject` | A nested map storing the profile information from PESU's "Know Your Class and Section" endpoint |
| `message` | `str` | A message that provides information corresponding to the status |
| `timestamp` | `datetime` | A timezone offset timestamp indicating the time of authentication |
| **Field** | **Type** | **Description** |
| ----------- | --------------- | ------------------------------------------------------------------------ |
| `status` | `boolean` | A flag indicating whether the overall request was successful |
| `profile` | `ProfileObject` | A nested map storing the profile information, returned only if requested |
| `message` | `str` | A message that provides information corresponding to the status |
| `timestamp` | `datetime` | A timezone offset timestamp indicating the time of authentication |

##### `ProfileObject`

Expand All @@ -152,21 +150,6 @@ If the authentication fails, this field will not be present in the response.
| `campusCode` | The integer code of the campus (1 for RR and 2 for EC) |
| `campus` | Abbreviation of the user's campus name |

#### `KnowYourClassAndSectionObject`

| **Field** | **Description** |
| --------------- | ------------------------------------------------------------------------ |
| `prn` | PRN of the user |
| `srn` | SRN of the user |
| `name` | Name of the user |
| `semester` | Current semester that the user is in |
| `section` | Section of the user |
| `cycle` | Physics Cycle or Chemistry Cycle, if the user is in first year |
| `department` | Abbreviation of the branch along with the campus the user is studying in |
| `branch` | Abbreviation of the branch that the user is pursuing |
| `instituteName` | The name of the campus that the user is studying in |
| `error` | The error name and stack trace, if an error occurs |

### `/health`

This endpoint can be used to check the health of the API. It's useful for monitoring and uptime checks. This endpoint
Expand Down Expand Up @@ -199,7 +182,6 @@ data = {
"username": "your SRN or PRN here",
"password": "your password here",
"profile": True, # Optional, defaults to False
'knowYourClassAndSection': True, # Optional, defaults to False
}

response = requests.post("http://localhost:5000/authenticate", json=data)
Expand All @@ -225,17 +207,6 @@ print(response.json())
"campus": "RR"
},
"message": "Login successful.",
"knowYourClassAndSection": {
"prn": "PES1201800001",
"srn": "PES1201800001",
"name": "JOHNNY BLAZE",
"semester": "Sem-8",
"section": "Section F",
"cycle": "NA",
"department": "CSE(EC Campus)",
"branch": "CSE",
"instituteName": "PES University (Electronic City)"
},
"timestamp": "2024-07-28 22:30:10.103368+05:30"
}
```
Expand Down
2 changes: 0 additions & 2 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ async def authenticate(payload: RequestModel, background_tasks: BackgroundTasks)
username = payload.username
password = payload.password
profile = payload.profile
know_your_class_and_section = payload.know_your_class_and_section
fields = payload.fields

# Authenticate the user
Expand All @@ -213,7 +212,6 @@ async def authenticate(payload: RequestModel, background_tasks: BackgroundTasks)
username=username,
password=password,
profile=profile,
know_your_class_and_section=know_your_class_and_section,
fields=fields,
),
)
Expand Down
50 changes: 0 additions & 50 deletions app/docs/authenticate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@
"profile": True,
},
},
"auth_with_kycas": {
"summary": 'Authentication with "Know Your Class and Section" endpoint',
"description": 'Authentication with "Know Your Class and Section" data',
"value": {
"username": "PES1201800001",
"password": "mySecurePassword123",
"profile": True,
"knowYourClassAndSection": True,
},
},
"phone_auth_selective_fields": {
"summary": "Authentication with Selected Fields",
"description": "Authentication using username and requesting specific profile data fields",
Expand Down Expand Up @@ -84,38 +74,6 @@
},
},
},
"authentication_with_kycas": {
"summary": 'Authentication with "Know Your Class and Section" data"',
"value": {
"status": True,
"message": "Login successful.",
"timestamp": "2024-07-28T22:30:10.103368+05:30",
"profile": {
"name": "John Doe",
"prn": "PESXXYYZZZZZ",
"srn": "PESXXUGYYZZZ",
"program": "Bachelor of Technology",
"branch": "Computer Science and Engineering",
"semester": "2",
"section": "C",
"email": "johndoe@gmail.com",
"phone": "1234567890",
"campusCode": 1,
"campus": "RR",
},
"knowYourClassAndSection": {
"prn": "PESXXYYZZZZZ",
"srn": "PESXXUGYYZZZ",
"name": "John Doe",
"semester": "Sem-X",
"section": "Section X",
"cycle": "NA",
"department": "Computer Science and Engineering",
"branch": "CSE",
"instituteName": "PES University",
},
},
},
"authentication_with_selected_fields": {
"summary": "Authentication with Selected Fields",
"value": {
Expand Down Expand Up @@ -209,14 +167,6 @@
"timestamp": "2024-07-28T22:30:10.103368+05:30",
},
},
"kycas_fetch_error": {
"summary": '"Know Your Class and Section" endpoint fetching failed',
"value": {
"status": False,
"message": "Failed to fetch Know Your Class and Section data from PESU Academy.",
"timestamp": "2024-07-28T22:30:10.103368+05:30",
},
},
}
}
},
Expand Down
11 changes: 0 additions & 11 deletions app/exceptions/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,3 @@ class ProfileParseError(PESUAcademyError):
def __init__(self, message: str = "Failed to parse student profile page from PESU Academy.") -> None:
"""Initialize the ProfileParseError with a custom message."""
super().__init__(message, status_code=422)


class KYCASFetchError(PESUAcademyError):
"""Raised when "Know Your Class and Section" data could not be fetched from PESU Academy."""

def __init__(
self,
message: str = 'Failed to fetch "Know Your Class and Section" data from PESU Academy.',
) -> None:
"""Initialize the "Know Your Class and Section" FetchError with a custom message."""
super().__init__(message, status_code=502)
1 change: 0 additions & 1 deletion app/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Custom models for the PESUAuth API."""

from .kycas import KYCASModel as KYCASModel
from .profile import ProfileModel as ProfileModel
from .request import RequestModel as RequestModel
from .response import ResponseModel as ResponseModel
65 changes: 0 additions & 65 deletions app/models/kycas.py

This file was deleted.

10 changes: 0 additions & 10 deletions app/models/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ class RequestModel(BaseModel):
json_schema_extra={"example": True},
)

know_your_class_and_section: bool = Field(
False,
title="Know Your Class and Section Flag",
description=(
"Whether to fetch the user's class and section information from the "
'"Know Your Class and Section" endpoint.'
),
json_schema_extra={"example": True},
)

fields: list[ProfileField] | None = Field(
None,
title="Profile Fields",
Expand Down
11 changes: 1 addition & 10 deletions app/models/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel

from app.models import KYCASModel, ProfileModel
from app.models import ProfileModel


class ResponseModel(BaseModel):
Expand Down Expand Up @@ -39,12 +39,3 @@ class ResponseModel(BaseModel):
title="User Profile Data",
description="The user's profile data returned only if authentication succeeds and profile data was requested.",
)

know_your_class_and_section: KYCASModel | None = Field(
None,
title='"Know Your Class and Section" Data',
description=(
"The user's class and section data from the "
'"Know Your Class and Section" endpoint returned only if authentication succeeds.'
),
)
Loading
Loading