Repository: CaffeineDuck/nepse-api (language: python)

Issue:
Check IPO not working
Trying to check the user's IPO result using `nepse.MarketClient.check_IPO` is giving TypeError:
```py
TypeError: 'coroutine' object is not subscriptable
```
In 
```py
for resp in self._client_wrapper._get_json( "https://iporesult.cdsc.com.np/result/companyShares/fileUploaded")["body"]
```



Discussion / hints:

Fix patch:
diff --git a/nepse/errors.py b/nepse/errors.py
index d425ead..ec1959c 100644
--- a/nepse/errors.py
+++ b/nepse/errors.py
@@ -8,9 +8,14 @@ def __str__(self) -> str:
 
 class NotFound(NepseException):
     def __str__(self) -> str:
-        return "The Company name Provided was not found !"
+        return "The data provided was not found !"
 
 
 class APIError(NepseException):
     def __str__(self) -> str:
         return "The data couldn't be fetched from the NEPSE API for this"
+
+
+class CompanyNotFound(NotFound):
+    def __str__(self) -> str:
+        return "The provided company was not found !"
diff --git a/nepse/market/core.py b/nepse/market/core.py
index 52e8e85..fd366bd 100644
--- a/nepse/market/core.py
+++ b/nepse/market/core.py
@@ -1,9 +1,11 @@
 import asyncio
 import json
+from ast import Index
 from typing import List, Optional
 
 import humps
 
+from nepse.errors import CompanyNotFound
 from nepse.market.types import FloorSheet, MarketCap
 from nepse.utils import _ClientWrapperHTTPX
 
@@ -27,28 +29,33 @@ async def market_is_open(self) -> bool:
             return True
         return False
 
-    async def check_IPO(self, scrip, boid) -> bool:
+    async def check_IPO(self, scrip: str, BOID: int) -> bool:
         """Checks if the given user got the IPO
 
         Args:
-            scrip (Any): The Script
-            boid (int): The boid
+            scrip (str): The Scrip of the company
+            boid (int): The user's BOID
 
         Returns:
             bool: Returns if the user got alloted in the IPO
         """
-        scripID = [
-            resp["id"]
-            for resp in self._client_wrapper._get_json(
-                "https://iporesult.cdsc.com.np/result/companyShares/fileUploaded"
-            )["body"]
-            if resp["scrip"] == scrip.upper()
-        ][0]
+        try:
+            scripID = [
+                resp.get("id")
+                for resp in (
+                    await self._client_wrapper._get_json(
+                        "https://iporesult.cdsc.com.np/result/companyShares/fileUploaded"
+                    )
+                ).get("body")
+                if resp.get("scrip") == scrip.upper()
+            ][0]
+        except IndexError:
+            raise CompanyNotFound()
 
         return (
             await self._client_wrapper._post_json(
                 url="https://iporesult.cdsc.com.np/result/result/check",
-                body={"companyShareId": scripID, "boid": boid},
+                body={"companyShareId": scripID, "boid": BOID},
             )
         ).get("success")
 
diff --git a/pyproject.toml b/pyproject.toml
index a111db1..9983108 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "nepse-api"
-version = "1.1.1"
+version = "1.1.2"
 description = "This is a API wrapper for NEPSE API."
 authors = ["Samrid Pandit <samrid.pandit@gmail.com>"]
 license = "MIT"


Test patch:
diff --git a/basic_test.py b/basic_test.py
index e19e0d9..0d683e5 100644
--- a/basic_test.py
+++ b/basic_test.py
@@ -107,6 +107,17 @@ async def test_brokers():
     assert wrapper_broker
 
 
+@pytest.mark.asyncio
+async def test_IPO():
+    async with httpx.AsyncClient() as async_client:
+        await asyncio.sleep(0.1)
+
+        client = Client(httpx_client=async_client)
+        ipo_result = await client.market_client.check_IPO("MLBSL", 1301310000123606)
+
+    assert ipo_result == False
+
+
 # @pytest.mark.asyncio
 # async def test_floorsheet():
 #     async with httpx.AsyncClient() as async_client: