cosmic-python-sdk 0.1.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,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: cosmic-python-sdk
3
+ Version: 0.1.0
4
+ Summary: Cosmic Gateway Python SDK
5
+ Home-page: https://github.com/cosmic-payment/cosmic-gateway
6
+ Author: Emmanuel Mnanka Samo
7
+ License: MIT
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: requests>=2.28
11
+
12
+ # Cosmic Python SDK
13
+
14
+ Minimal Python client for Cosmic Gateway API.
15
+
16
+ Install (PyPI):
17
+
18
+ pip install cosmic-python-sdk
19
+
20
+ Quick example:
21
+
22
+ ```py
23
+ from cosmic_sdk import CosmicGateway
24
+
25
+ client = CosmicGateway(api_key="sk_test_...")
26
+ resp = client.get('/health')
27
+ print(resp.status_code, resp.text)
28
+ ```
@@ -0,0 +1,17 @@
1
+ # Cosmic Python SDK
2
+
3
+ Minimal Python client for Cosmic Gateway API.
4
+
5
+ Install (PyPI):
6
+
7
+ pip install cosmic-python-sdk
8
+
9
+ Quick example:
10
+
11
+ ```py
12
+ from cosmic_sdk import CosmicGateway
13
+
14
+ client = CosmicGateway(api_key="sk_test_...")
15
+ resp = client.get('/health')
16
+ print(resp.status_code, resp.text)
17
+ ```
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: cosmic-python-sdk
3
+ Version: 0.1.0
4
+ Summary: Cosmic Gateway Python SDK
5
+ Home-page: https://github.com/cosmic-payment/cosmic-gateway
6
+ Author: Emmanuel Mnanka Samo
7
+ License: MIT
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: requests>=2.28
11
+
12
+ # Cosmic Python SDK
13
+
14
+ Minimal Python client for Cosmic Gateway API.
15
+
16
+ Install (PyPI):
17
+
18
+ pip install cosmic-python-sdk
19
+
20
+ Quick example:
21
+
22
+ ```py
23
+ from cosmic_sdk import CosmicGateway
24
+
25
+ client = CosmicGateway(api_key="sk_test_...")
26
+ resp = client.get('/health')
27
+ print(resp.status_code, resp.text)
28
+ ```
@@ -0,0 +1,11 @@
1
+ README.md
2
+ pyproject.toml
3
+ setup.cfg
4
+ cosmic_python_sdk.egg-info/PKG-INFO
5
+ cosmic_python_sdk.egg-info/SOURCES.txt
6
+ cosmic_python_sdk.egg-info/dependency_links.txt
7
+ cosmic_python_sdk.egg-info/requires.txt
8
+ cosmic_python_sdk.egg-info/top_level.txt
9
+ cosmic_sdk/__init__.py
10
+ cosmic_sdk/client.py
11
+ tests/test_client.py
@@ -0,0 +1 @@
1
+ requests>=2.28
@@ -0,0 +1,5 @@
1
+ from .client import CosmicGateway
2
+
3
+ __all__ = ["CosmicGateway"]
4
+
5
+ __version__ = "0.1.0"
@@ -0,0 +1,31 @@
1
+ import requests
2
+ from typing import Optional, Dict, Any
3
+
4
+
5
+ class CosmicGateway:
6
+ """Simple HTTP client for Cosmic Gateway"""
7
+
8
+ def __init__(self, api_key: str, base_url: str = "https://api.cosmicgateway.com"):
9
+ self.api_key = api_key
10
+ self.base_url = base_url.rstrip("/")
11
+ self.session = requests.Session()
12
+ self.session.headers.update(self._default_headers())
13
+
14
+ def _default_headers(self) -> Dict[str, str]:
15
+ return {
16
+ "Authorization": f"Bearer {self.api_key}",
17
+ "Accept": "application/json",
18
+ "User-Agent": "cosmic-python-sdk/0.1.0",
19
+ }
20
+
21
+ def get(self, path: str, params: Optional[Dict[str, Any]] = None) -> requests.Response:
22
+ url = f"{self.base_url}{path if path.startswith('/') else '/' + path}"
23
+ return self.session.get(url, params=params)
24
+
25
+ def post(self, path: str, json: Optional[Dict[str, Any]] = None) -> requests.Response:
26
+ url = f"{self.base_url}{path if path.startswith('/') else '/' + path}"
27
+ return self.session.post(url, json=json)
28
+
29
+ # convenience method
30
+ def health(self) -> requests.Response:
31
+ return self.get('/health')
@@ -0,0 +1,3 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,20 @@
1
+ [metadata]
2
+ name = cosmic-python-sdk
3
+ version = 0.1.0
4
+ description = Cosmic Gateway Python SDK
5
+ author = Emmanuel Mnanka Samo
6
+ long_description = file: README.md
7
+ long_description_content_type = text/markdown
8
+ url = https://github.com/cosmic-payment/cosmic-gateway
9
+ license = MIT
10
+
11
+ [options]
12
+ packages = find:
13
+ install_requires =
14
+ requests>=2.28
15
+ python_requires = >=3.8
16
+
17
+ [egg_info]
18
+ tag_build =
19
+ tag_date = 0
20
+
@@ -0,0 +1,16 @@
1
+ import pytest
2
+ from cosmic_sdk import CosmicGateway
3
+
4
+
5
+ def test_default_headers():
6
+ c = CosmicGateway(api_key="sk_test")
7
+ headers = c._default_headers()
8
+ assert "Authorization" in headers
9
+ assert headers["Authorization"] == "Bearer sk_test"
10
+
11
+
12
+ def test_build_url():
13
+ c = CosmicGateway(api_key="sk_test", base_url="https://example.com/api")
14
+ # ensure no exception when calling get/post (we won't send network requests)
15
+ assert c.base_url == "https://example.com/api"
16
+