(20250211) Slight changes in NSE's IPO section.

This commit is contained in:
2025-02-11 15:29:59 +05:30
parent 94e5c81087
commit 382c6c991d
3 changed files with 72 additions and 3 deletions
+69
View File
@@ -190,6 +190,9 @@ class AsyncREST:
api_response.httpCode = response.status_code
api_response.message = response.reason_phrase
# Assume success if the response's HTTP code is in the 200 series:
api_response.success = response.is_success
# If something goes wrong:
except Exception as exception:
api_response.exception = exception
@@ -244,6 +247,9 @@ class AsyncREST:
api_response.httpCode = response.status_code
api_response.message = response.reason_phrase
# Assume success if the response's HTTP code is in the 200 series:
api_response.success = response.is_success
# If something goes wrong:
except Exception as exception:
api_response.exception = exception
@@ -295,6 +301,66 @@ class AsyncREST:
api_response.httpCode = response.status_code
api_response.message = response.reason_phrase
# Assume success if the response's HTTP code is in the 200 series:
api_response.success = response.is_success
# If something goes wrong:
except Exception as exception:
api_response.exception = exception
api_response.message = str(exception)
self._printer(exception, api_response.url, api_response.method, headers, json, data)
# Done here:
return api_response
async def patch(
self,
url: str,
headers: dict = None,
json: dict = None,
data: dict = None,
content: str | bytes = None,
auth: httpx.Auth = None
) -> ApiResponse:
"""
To call an API using the PATCH method.
:param url: The URL to call.
:param headers: The headers to pass.
:param json: The params to send in the JSON body.
:param data: The params to send in the form-data in the body.
:param content: The raw content to be sent in the body (typically as an octet-stream).
:param auth: Any authentication credentials that need to be sent.
:return: A structured response that includes the raw response, the exception (if any), and so on.
"""
# Prepare the structure of the response:
api_response = ApiResponse(
action = inspect.stack()[1].function,
url = url,
method = "POST"
)
try:
# Make the API call:
response = await self._http_client.patch(
url = url,
headers = headers,
json = json,
data = data,
content = content,
auth = auth
)
# Note down the results:
api_response.response = response
api_response.httpCode = response.status_code
api_response.message = response.reason_phrase
# Assume success if the response's HTTP code is in the 200 series:
api_response.success = response.is_success
# If something goes wrong:
except Exception as exception:
api_response.exception = exception
@@ -340,6 +406,9 @@ class AsyncREST:
api_response.httpCode = response.status_code
api_response.message = response.reason_phrase
# Assume success if the response's HTTP code is in the 200 series:
api_response.success = response.is_success
# If something goes wrong:
except Exception as exception:
api_response.exception = exception