pacspace-sdk 0.1.2__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) 2026 PacSpace
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,62 @@
1
+ Metadata-Version: 2.4
2
+ Name: pacspace-sdk
3
+ Version: 0.1.2
4
+ Summary: Official PacSpace Balance API SDK for Python.
5
+ Author: PacSpace
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/PacSpace/python-sdk
8
+ Project-URL: Repository, https://github.com/PacSpace/python-sdk
9
+ Project-URL: Issues, https://github.com/PacSpace/python-sdk/issues
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Libraries
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Dynamic: license-file
23
+
24
+ # pacspace-sdk (Python)
25
+
26
+ Official Python SDK for the PacSpace Balance API.
27
+
28
+ ## Install
29
+
30
+ ```bash
31
+ pip install pacspace-sdk
32
+ ```
33
+
34
+ ## Quick Start
35
+
36
+ ```python
37
+ from pacspace_sdk import PacSpace
38
+
39
+ pac = PacSpace.init("pk_test_xxx")
40
+
41
+ emit = pac.balance.emit("cust_123", -42, "usage")
42
+ status = pac.balance.wait_for_verified(emit["recordId"])
43
+ usage = pac.balance.usage()
44
+ ```
45
+
46
+ ## Verify source selection
47
+
48
+ ```python
49
+ verification = pac.verify(
50
+ "0xproof_root_here",
51
+ source="both", # "db" (default), "chain", or "both"
52
+ )
53
+ ```
54
+
55
+ ## Webhook Verification
56
+
57
+ ```python
58
+ from pacspace_sdk import Webhooks
59
+
60
+ webhooks = Webhooks("whsec_xxx")
61
+ event = webhooks.verify(signature, timestamp, raw_body)
62
+ ```
@@ -0,0 +1,39 @@
1
+ # pacspace-sdk (Python)
2
+
3
+ Official Python SDK for the PacSpace Balance API.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install pacspace-sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```python
14
+ from pacspace_sdk import PacSpace
15
+
16
+ pac = PacSpace.init("pk_test_xxx")
17
+
18
+ emit = pac.balance.emit("cust_123", -42, "usage")
19
+ status = pac.balance.wait_for_verified(emit["recordId"])
20
+ usage = pac.balance.usage()
21
+ ```
22
+
23
+ ## Verify source selection
24
+
25
+ ```python
26
+ verification = pac.verify(
27
+ "0xproof_root_here",
28
+ source="both", # "db" (default), "chain", or "both"
29
+ )
30
+ ```
31
+
32
+ ## Webhook Verification
33
+
34
+ ```python
35
+ from pacspace_sdk import Webhooks
36
+
37
+ webhooks = Webhooks("whsec_xxx")
38
+ event = webhooks.verify(signature, timestamp, raw_body)
39
+ ```
@@ -0,0 +1,35 @@
1
+ from .pacspace import PacSpace
2
+ from .errors import (
3
+ PacSpaceError,
4
+ InvalidApiKeyError,
5
+ InsufficientCreditsError,
6
+ NotFoundError,
7
+ ContractNotDeployedError,
8
+ RateLimitError,
9
+ CadenceLimitError,
10
+ ServiceUnavailableError,
11
+ ValidationError,
12
+ InvalidScopeCombinationError,
13
+ ScopeTooWideError,
14
+ TimeoutError,
15
+ WebhookVerificationError,
16
+ )
17
+ from .webhooks.verify import Webhooks
18
+
19
+ __all__ = [
20
+ "PacSpace",
21
+ "PacSpaceError",
22
+ "InvalidApiKeyError",
23
+ "InsufficientCreditsError",
24
+ "NotFoundError",
25
+ "ContractNotDeployedError",
26
+ "RateLimitError",
27
+ "CadenceLimitError",
28
+ "ServiceUnavailableError",
29
+ "ValidationError",
30
+ "InvalidScopeCombinationError",
31
+ "ScopeTooWideError",
32
+ "TimeoutError",
33
+ "WebhookVerificationError",
34
+ "Webhooks",
35
+ ]
@@ -0,0 +1 @@
1
+ """Internal SDK helpers. Not part of the public SDK surface."""
@@ -0,0 +1,43 @@
1
+ """Internal batch transport used by SubmissionCoordinator only.
2
+
3
+ Not part of the public SDK surface. Do not reference from public code paths.
4
+ """
5
+ from __future__ import annotations
6
+
7
+ from typing import Any, Dict, Iterable, List, Optional
8
+
9
+ from ..client import HttpClient
10
+
11
+
12
+ def submit_internal_batch(
13
+ client: HttpClient,
14
+ deltas: Iterable[Dict[str, Any]],
15
+ options: Optional[Dict[str, Any]] = None,
16
+ ) -> Dict[str, Any]:
17
+ """Submit deltas via the internal transport used by the summary submission coordinator.
18
+
19
+ This helper is internal; do not invoke it from public SDK code paths.
20
+ """
21
+ payload_deltas: List[Dict[str, Any]] = list(deltas)
22
+ response = client.post(
23
+ "/api/v1/balance/delta/batch",
24
+ {"deltas": payload_deltas},
25
+ options,
26
+ )
27
+ return _normalize_internal_batch_response(response)
28
+
29
+
30
+ def _normalize_internal_batch_response(data: Any) -> Dict[str, Any]:
31
+ if not isinstance(data, dict):
32
+ return {"totalQueued": 0, "totalFailed": 0, "results": []}
33
+
34
+ results = data.get("results")
35
+ if not isinstance(results, list):
36
+ results = []
37
+
38
+ return {
39
+ "totalQueued": int(data.get("totalQueued", len(results))),
40
+ "totalFailed": int(data.get("totalFailed", 0)),
41
+ "results": results,
42
+ "_efficiency": data.get("_efficiency"),
43
+ }