deen-api-client 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Imaniro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,133 @@
1
+ Metadata-Version: 2.4
2
+ Name: deen-api-client
3
+ Version: 1.0.0
4
+ Summary: Python client for Deen API from Imaniro.com - Islamic resources API
5
+ Home-page: https://github.com/imaniro-tech/deen-api-python-client
6
+ Author: Imaniro pvt ltd
7
+ Author-email: info@imaniro.com
8
+ Project-URL: Documentation, https://github.com/imaniro-tech/deen-api-python-client
9
+ Project-URL: Source, https://github.com/imaniro-tech/deen-api-python-client
10
+ Project-URL: Tracker, https://github.com/imaniro-tech/deen-api-python-client/issues
11
+ Keywords: islamic,api,hadith,quran,dua,muslim
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.7
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Requires-Python: >=3.7
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: requests>=2.25.0
27
+ Requires-Dist: dataclasses>=0.6; python_version < "3.7"
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=6.0.0; extra == "dev"
30
+ Requires-Dist: requests-mock>=1.9.0; extra == "dev"
31
+ Requires-Dist: pytest-cov>=2.0.0; extra == "dev"
32
+ Dynamic: author
33
+ Dynamic: author-email
34
+ Dynamic: classifier
35
+ Dynamic: description
36
+ Dynamic: description-content-type
37
+ Dynamic: home-page
38
+ Dynamic: keywords
39
+ Dynamic: license-file
40
+ Dynamic: project-url
41
+ Dynamic: provides-extra
42
+ Dynamic: requires-dist
43
+ Dynamic: requires-python
44
+ Dynamic: summary
45
+
46
+ # Deen API Python Client
47
+
48
+ A Python client for the Deen API, providing easy access to Islamic resources including Hadith, Quran verses, and Duas.
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ pip install deen-api-client
54
+ ```
55
+
56
+ # Quick Start
57
+
58
+ ```python
59
+ from deen_api import ImaniroDeenAPIClient
60
+
61
+ # Initialize client with your API key
62
+ client = ImaniroDeenAPIClient(api_key="sk_12345")
63
+
64
+ # Get hadiths from Sahih al-Bukhari
65
+ hadiths = client.get_hadiths(book="Sahih al-Bukhari", max_limits=5)
66
+
67
+ for hadith in hadiths:
68
+ print(f"Book: {hadith.book}")
69
+ print(f"Chapter: {hadith.chapter}")
70
+ print(f"Text: {hadith.text}")
71
+ print(f"Translation: {hadith.translation}")
72
+ print("---")
73
+
74
+ # Get Quran verses
75
+ verses = client.get_quran_verses(surah="Al-Fatiha", max_limits=3)
76
+
77
+ # Get Duas
78
+ duas = client.get_duas(category="morning", max_limits=5)
79
+ ```
80
+
81
+ # Features
82
+
83
+ - Hadith Access: Retrieve hadiths from various books
84
+
85
+ - Quran Verses: Access Quranic verses with translations(under development)
86
+
87
+ - Islamic Duas: Get supplications for various occasions(under development)
88
+
89
+ - Error Handling: Comprehensive exception handling
90
+
91
+ # Error Handling
92
+
93
+ The client provides specific exception types:
94
+
95
+ ```python
96
+ from deen_api import AuthenticationError, RateLimitError, NotFoundError
97
+
98
+ try:
99
+ hadiths = client.get_hadiths(book="Sahih al-Bukhari")
100
+ except AuthenticationError:
101
+ print("Invalid API key")
102
+ except RateLimitError:
103
+ print("Rate limit exceeded")
104
+ except NotFoundError:
105
+ print("Resource not found")
106
+ ```
107
+
108
+ ## Example Usage Files
109
+
110
+ ### `examples/hadith_example.py`
111
+
112
+ ```python
113
+ from deen_api import ImaniroDeenAPIClient
114
+
115
+ def hadith_example():
116
+ client = ImaniroDeenAPIClient(api_key="sk_12345")
117
+
118
+ try:
119
+ # Get hadiths from Sahih al-Bukhari
120
+ hadiths = client.get_hadiths(book="Sahih al-Bukhari", max_limits=3)
121
+
122
+ print("Hadiths from Sahih al-Bukhari:")
123
+ for i, hadith in enumerate(hadiths, 1):
124
+ print(f"\n{i}. {hadith.hadith}")
125
+ print(f"Translation: {hadith.translation}")
126
+ print("-" * 50)
127
+
128
+ except Exception as e:
129
+ print(f"Error: {e}")
130
+
131
+ if __name__ == "__main__":
132
+ hadith_example()
133
+ ```
@@ -0,0 +1,88 @@
1
+ # Deen API Python Client
2
+
3
+ A Python client for the Deen API, providing easy access to Islamic resources including Hadith, Quran verses, and Duas.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install deen-api-client
9
+ ```
10
+
11
+ # Quick Start
12
+
13
+ ```python
14
+ from deen_api import ImaniroDeenAPIClient
15
+
16
+ # Initialize client with your API key
17
+ client = ImaniroDeenAPIClient(api_key="sk_12345")
18
+
19
+ # Get hadiths from Sahih al-Bukhari
20
+ hadiths = client.get_hadiths(book="Sahih al-Bukhari", max_limits=5)
21
+
22
+ for hadith in hadiths:
23
+ print(f"Book: {hadith.book}")
24
+ print(f"Chapter: {hadith.chapter}")
25
+ print(f"Text: {hadith.text}")
26
+ print(f"Translation: {hadith.translation}")
27
+ print("---")
28
+
29
+ # Get Quran verses
30
+ verses = client.get_quran_verses(surah="Al-Fatiha", max_limits=3)
31
+
32
+ # Get Duas
33
+ duas = client.get_duas(category="morning", max_limits=5)
34
+ ```
35
+
36
+ # Features
37
+
38
+ - Hadith Access: Retrieve hadiths from various books
39
+
40
+ - Quran Verses: Access Quranic verses with translations(under development)
41
+
42
+ - Islamic Duas: Get supplications for various occasions(under development)
43
+
44
+ - Error Handling: Comprehensive exception handling
45
+
46
+ # Error Handling
47
+
48
+ The client provides specific exception types:
49
+
50
+ ```python
51
+ from deen_api import AuthenticationError, RateLimitError, NotFoundError
52
+
53
+ try:
54
+ hadiths = client.get_hadiths(book="Sahih al-Bukhari")
55
+ except AuthenticationError:
56
+ print("Invalid API key")
57
+ except RateLimitError:
58
+ print("Rate limit exceeded")
59
+ except NotFoundError:
60
+ print("Resource not found")
61
+ ```
62
+
63
+ ## Example Usage Files
64
+
65
+ ### `examples/hadith_example.py`
66
+
67
+ ```python
68
+ from deen_api import ImaniroDeenAPIClient
69
+
70
+ def hadith_example():
71
+ client = ImaniroDeenAPIClient(api_key="sk_12345")
72
+
73
+ try:
74
+ # Get hadiths from Sahih al-Bukhari
75
+ hadiths = client.get_hadiths(book="Sahih al-Bukhari", max_limits=3)
76
+
77
+ print("Hadiths from Sahih al-Bukhari:")
78
+ for i, hadith in enumerate(hadiths, 1):
79
+ print(f"\n{i}. {hadith.hadith}")
80
+ print(f"Translation: {hadith.translation}")
81
+ print("-" * 50)
82
+
83
+ except Exception as e:
84
+ print(f"Error: {e}")
85
+
86
+ if __name__ == "__main__":
87
+ hadith_example()
88
+ ```
@@ -0,0 +1,15 @@
1
+ from .client import ImaniroDeenAPIClient
2
+ from .models import Hadith, APIResponse
3
+ from .exceptions import DeenAPIError, AuthenticationError, RateLimitError, NotFoundError, ServerError
4
+
5
+ __version__ = "1.0.0"
6
+ __all__ = [
7
+ 'ImaniroDeenAPIClient',
8
+ 'Hadith',
9
+ 'APIResponse',
10
+ 'DeenAPIError',
11
+ 'AuthenticationError',
12
+ 'RateLimitError',
13
+ 'NotFoundError',
14
+ 'ServerError'
15
+ ]
@@ -0,0 +1,75 @@
1
+ import requests
2
+ from typing import List, Optional, Dict, Any
3
+ from .models import Hadith, APIResponse
4
+ from .exceptions import *
5
+
6
+ class ImaniroDeenAPIClient:
7
+ def __init__(self, api_key: str, base_url: str = "https://deen-api.imaniro.com/api/v1"):
8
+ self.api_key = api_key
9
+ self.base_url = base_url.rstrip('/')
10
+ self.session = requests.Session()
11
+ self.session.headers.update({
12
+ 'Content-Type': 'application/json',
13
+ 'X-API-Key': self.api_key
14
+ })
15
+
16
+ def _handle_response(self, response: requests.Response) -> Dict[str, Any]:
17
+ """Handle API response and raise appropriate exceptions"""
18
+ if response.status_code == 401:
19
+ raise AuthenticationError("Invalid API key")
20
+ elif response.status_code == 404:
21
+ raise NotFoundError("Resource not found")
22
+ elif response.status_code == 429:
23
+ raise RateLimitError("Rate limit exceeded")
24
+ elif response.status_code >= 500:
25
+ raise ServerError("Server error occurred")
26
+ elif response.status_code != 200:
27
+ raise DeenAPIError(f"API error: {response.status_code} - {response.text}")
28
+
29
+ return response.json()
30
+
31
+ def _make_request(self, endpoint: str, params: Optional[Dict] = None) -> APIResponse:
32
+ """Make API request and return parsed response"""
33
+ url = f"{self.base_url}/{endpoint}"
34
+
35
+ try:
36
+ response = self.session.post(url, json=params or {})
37
+ data = self._handle_response(response)
38
+ return APIResponse.from_dict(data)
39
+ except requests.exceptions.RequestException as e:
40
+ raise DeenAPIError(f"Request failed: {str(e)}")
41
+
42
+ def get_hadiths(self, book: str = '',
43
+ max_limits: int = 1,
44
+ number:str = '',
45
+ language:str = 'en',
46
+ authenticity:str = '',
47
+ keywords: List[str] = [],
48
+ topics: List[str] = [],
49
+ narrator:str = '',
50
+ **kwargs) -> List[Hadith]:
51
+ """
52
+ Get hadiths from specified book
53
+
54
+ Args:
55
+ book: Name of the hadith book (e.g., "Sahih al-Bukhari")
56
+ max_limits: Maximum number of hadiths to return
57
+ **kwargs: Additional parameters for the API
58
+
59
+ Returns:
60
+ List of Hadith objects
61
+ """
62
+ params = {
63
+ "book": book,
64
+ "number" : number,
65
+ "narrator": narrator,
66
+ "language": language,
67
+ "authenticity": authenticity,
68
+ "keywords": keywords,
69
+ "topics": topics,
70
+ "maxLimits": max_limits,
71
+ **kwargs
72
+ }
73
+
74
+ response = self._make_request("hadiths", params)
75
+ return [Hadith.from_dict(item) for item in response.data]
@@ -0,0 +1,19 @@
1
+ class DeenAPIError(Exception):
2
+ """Base exception for Deen API client"""
3
+ pass
4
+
5
+ class AuthenticationError(DeenAPIError):
6
+ """Raised when API key is invalid or missing"""
7
+ pass
8
+
9
+ class RateLimitError(DeenAPIError):
10
+ """Raised when rate limit is exceeded"""
11
+ pass
12
+
13
+ class NotFoundError(DeenAPIError):
14
+ """Raised when resource is not found"""
15
+ pass
16
+
17
+ class ServerError(DeenAPIError):
18
+ """Raised when server returns 5xx error"""
19
+ pass
@@ -0,0 +1,46 @@
1
+ from typing import List, Optional, Dict, Any
2
+ from dataclasses import dataclass
3
+
4
+ @dataclass
5
+ class Hadith:
6
+ attribution: str
7
+ authenticity: str
8
+ category: str
9
+ context: str
10
+ explanation: str
11
+ hadith: str
12
+ narratedBy: str
13
+ book: str
14
+ number: str
15
+ translation: str
16
+
17
+ @classmethod
18
+ def from_dict(cls, data: Dict[str, Any]) -> 'Hadith':
19
+ return cls(
20
+ attribution = data.get('attribution', ''),
21
+ authenticity = data.get('authenticity', ''),
22
+ category = data.get('category', ''),
23
+ context = data.get('context', ''),
24
+ explanation = data.get('explanation', ''),
25
+ hadith = data.get('hadith', ''),
26
+ narratedBy = data.get('narratedBy', ''),
27
+ book=data.get('book', ''),
28
+ number = data.get('number', ''),
29
+ translation=data.get('translation', '')
30
+ )
31
+
32
+ @dataclass
33
+ class APIResponse:
34
+ success: bool
35
+ data: List[Any]
36
+ message: str
37
+ count: int
38
+
39
+ @classmethod
40
+ def from_dict(cls, data: Dict[str, Any]) -> 'APIResponse':
41
+ return cls(
42
+ success=data.get('success', False),
43
+ data=data.get('data', []),
44
+ message=data.get('message', ''),
45
+ count=data.get('count', 0)
46
+ )
@@ -0,0 +1,133 @@
1
+ Metadata-Version: 2.4
2
+ Name: deen-api-client
3
+ Version: 1.0.0
4
+ Summary: Python client for Deen API from Imaniro.com - Islamic resources API
5
+ Home-page: https://github.com/imaniro-tech/deen-api-python-client
6
+ Author: Imaniro pvt ltd
7
+ Author-email: info@imaniro.com
8
+ Project-URL: Documentation, https://github.com/imaniro-tech/deen-api-python-client
9
+ Project-URL: Source, https://github.com/imaniro-tech/deen-api-python-client
10
+ Project-URL: Tracker, https://github.com/imaniro-tech/deen-api-python-client/issues
11
+ Keywords: islamic,api,hadith,quran,dua,muslim
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.7
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Requires-Python: >=3.7
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: requests>=2.25.0
27
+ Requires-Dist: dataclasses>=0.6; python_version < "3.7"
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=6.0.0; extra == "dev"
30
+ Requires-Dist: requests-mock>=1.9.0; extra == "dev"
31
+ Requires-Dist: pytest-cov>=2.0.0; extra == "dev"
32
+ Dynamic: author
33
+ Dynamic: author-email
34
+ Dynamic: classifier
35
+ Dynamic: description
36
+ Dynamic: description-content-type
37
+ Dynamic: home-page
38
+ Dynamic: keywords
39
+ Dynamic: license-file
40
+ Dynamic: project-url
41
+ Dynamic: provides-extra
42
+ Dynamic: requires-dist
43
+ Dynamic: requires-python
44
+ Dynamic: summary
45
+
46
+ # Deen API Python Client
47
+
48
+ A Python client for the Deen API, providing easy access to Islamic resources including Hadith, Quran verses, and Duas.
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ pip install deen-api-client
54
+ ```
55
+
56
+ # Quick Start
57
+
58
+ ```python
59
+ from deen_api import ImaniroDeenAPIClient
60
+
61
+ # Initialize client with your API key
62
+ client = ImaniroDeenAPIClient(api_key="sk_12345")
63
+
64
+ # Get hadiths from Sahih al-Bukhari
65
+ hadiths = client.get_hadiths(book="Sahih al-Bukhari", max_limits=5)
66
+
67
+ for hadith in hadiths:
68
+ print(f"Book: {hadith.book}")
69
+ print(f"Chapter: {hadith.chapter}")
70
+ print(f"Text: {hadith.text}")
71
+ print(f"Translation: {hadith.translation}")
72
+ print("---")
73
+
74
+ # Get Quran verses
75
+ verses = client.get_quran_verses(surah="Al-Fatiha", max_limits=3)
76
+
77
+ # Get Duas
78
+ duas = client.get_duas(category="morning", max_limits=5)
79
+ ```
80
+
81
+ # Features
82
+
83
+ - Hadith Access: Retrieve hadiths from various books
84
+
85
+ - Quran Verses: Access Quranic verses with translations(under development)
86
+
87
+ - Islamic Duas: Get supplications for various occasions(under development)
88
+
89
+ - Error Handling: Comprehensive exception handling
90
+
91
+ # Error Handling
92
+
93
+ The client provides specific exception types:
94
+
95
+ ```python
96
+ from deen_api import AuthenticationError, RateLimitError, NotFoundError
97
+
98
+ try:
99
+ hadiths = client.get_hadiths(book="Sahih al-Bukhari")
100
+ except AuthenticationError:
101
+ print("Invalid API key")
102
+ except RateLimitError:
103
+ print("Rate limit exceeded")
104
+ except NotFoundError:
105
+ print("Resource not found")
106
+ ```
107
+
108
+ ## Example Usage Files
109
+
110
+ ### `examples/hadith_example.py`
111
+
112
+ ```python
113
+ from deen_api import ImaniroDeenAPIClient
114
+
115
+ def hadith_example():
116
+ client = ImaniroDeenAPIClient(api_key="sk_12345")
117
+
118
+ try:
119
+ # Get hadiths from Sahih al-Bukhari
120
+ hadiths = client.get_hadiths(book="Sahih al-Bukhari", max_limits=3)
121
+
122
+ print("Hadiths from Sahih al-Bukhari:")
123
+ for i, hadith in enumerate(hadiths, 1):
124
+ print(f"\n{i}. {hadith.hadith}")
125
+ print(f"Translation: {hadith.translation}")
126
+ print("-" * 50)
127
+
128
+ except Exception as e:
129
+ print(f"Error: {e}")
130
+
131
+ if __name__ == "__main__":
132
+ hadith_example()
133
+ ```
@@ -0,0 +1,16 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ deen_api/__init__.py
5
+ deen_api/client.py
6
+ deen_api/exceptions.py
7
+ deen_api/models.py
8
+ deen_api_client.egg-info/PKG-INFO
9
+ deen_api_client.egg-info/SOURCES.txt
10
+ deen_api_client.egg-info/dependency_links.txt
11
+ deen_api_client.egg-info/requires.txt
12
+ deen_api_client.egg-info/top_level.txt
13
+ examples/__init__.py
14
+ examples/hadith_example.py
15
+ tests/__init__.py
16
+ tests/test_client.py
@@ -0,0 +1,9 @@
1
+ requests>=2.25.0
2
+
3
+ [:python_version < "3.7"]
4
+ dataclasses>=0.6
5
+
6
+ [dev]
7
+ pytest>=6.0.0
8
+ requests-mock>=1.9.0
9
+ pytest-cov>=2.0.0
@@ -0,0 +1,3 @@
1
+ deen_api
2
+ examples
3
+ tests
File without changes
@@ -0,0 +1,20 @@
1
+ from deen_api import ImaniroDeenAPIClient
2
+
3
+ def hadith_example():
4
+ client = ImaniroDeenAPIClient(api_key="sk_12345")
5
+
6
+ try:
7
+ # Get hadiths from Sahih al-Bukhari
8
+ hadiths = client.get_hadiths(book="Sahih al-Bukhari", max_limits=3)
9
+
10
+ print("Hadiths from Sahih al-Bukhari:")
11
+ for i, hadith in enumerate(hadiths, 1):
12
+ print(f"\n{i}. {hadith.hadith}")
13
+ print(f"Translation: {hadith.translation}")
14
+ print("-" * 50)
15
+
16
+ except Exception as e:
17
+ print(f"Error: {e}")
18
+
19
+ if __name__ == "__main__":
20
+ hadith_example()
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,47 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ with open("README.md", "r", encoding="utf-8") as fh:
4
+ long_description = fh.read()
5
+
6
+ with open("requirements.txt", "r", encoding="utf-8") as fh:
7
+ requirements = [line.strip() for line in fh if line.strip() and not line.startswith("#")]
8
+
9
+ setup(
10
+ name="deen-api-client",
11
+ version="1.0.0",
12
+ author="Imaniro pvt ltd",
13
+ author_email="info@imaniro.com",
14
+ description="Python client for Deen API from Imaniro.com - Islamic resources API",
15
+ long_description=long_description,
16
+ long_description_content_type="text/markdown",
17
+ url="https://github.com/imaniro-tech/deen-api-python-client",
18
+ packages=find_packages(),
19
+ classifiers=[
20
+ "Development Status :: 4 - Beta",
21
+ "Intended Audience :: Developers",
22
+ "License :: OSI Approved :: MIT License",
23
+ "Operating System :: OS Independent",
24
+ "Programming Language :: Python :: 3",
25
+ "Programming Language :: Python :: 3.7",
26
+ "Programming Language :: Python :: 3.8",
27
+ "Programming Language :: Python :: 3.9",
28
+ "Programming Language :: Python :: 3.10",
29
+ "Programming Language :: Python :: 3.11",
30
+ "Programming Language :: Python :: 3.12",
31
+ ],
32
+ python_requires=">=3.7",
33
+ install_requires=requirements,
34
+ extras_require={
35
+ "dev": [
36
+ "pytest>=6.0.0",
37
+ "requests-mock>=1.9.0",
38
+ "pytest-cov>=2.0.0",
39
+ ]
40
+ },
41
+ keywords="islamic, api, hadith, quran, dua, muslim",
42
+ project_urls={
43
+ "Documentation": "https://github.com/imaniro-tech/deen-api-python-client",
44
+ "Source": "https://github.com/imaniro-tech/deen-api-python-client",
45
+ "Tracker": "https://github.com/imaniro-tech/deen-api-python-client/issues",
46
+ },
47
+ )
File without changes
@@ -0,0 +1,47 @@
1
+ import pytest
2
+ import requests_mock
3
+ from deen_api import ImaniroDeenAPIClient, Hadith
4
+ from deen_api.exceptions import AuthenticationError, NotFoundError
5
+
6
+ class TestDeenAPIClient:
7
+ def setup_method(self):
8
+ self.api_key = "test_key"
9
+ self.client = ImaniroDeenAPIClient(api_key=self.api_key)
10
+ self.base_url = "https://deen-api.imaniro.com/api/v1"
11
+
12
+ def test_authentication_error(self):
13
+ with requests_mock.Mocker() as m:
14
+ m.post(f"{self.base_url}/hadiths", status_code=401)
15
+
16
+ with pytest.raises(AuthenticationError):
17
+ self.client.get_hadiths(book="Sahih al-Bukhari")
18
+
19
+ def test_get_hadiths_success(self):
20
+ mock_response = {
21
+ "success": True,
22
+ "data": [
23
+ {
24
+ "book": "Sahih al-Bukhari",
25
+ "number": "1",
26
+ "narratedBy": "Abu Huraira",
27
+ "translation": "Hadith translation...",
28
+ "attribution": "Marfu",
29
+ "authenticity": "sahih",
30
+ "category": "Prayer",
31
+ "context": "Hadith Context...",
32
+ "explanation": "hadith Explanation...",
33
+ "hadith": "الكَعْبَةَ وَأُسَامَةُ"
34
+ }
35
+ ],
36
+ "message": "Success",
37
+ "count": 1
38
+ }
39
+
40
+ with requests_mock.Mocker() as m:
41
+ m.post(f"{self.base_url}/hadiths", json=mock_response)
42
+
43
+ hadiths = self.client.get_hadiths(book="Sahih al-Bukhari")
44
+
45
+ assert len(hadiths) == 1
46
+ assert isinstance(hadiths[0], Hadith)
47
+ assert hadiths[0].book == "Sahih al-Bukhari"