tring-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,12 @@
1
+ node_modules/
2
+ dist/
3
+ docs/dist/
4
+ .venv/
5
+ __pycache__/
6
+ *.pyc
7
+ .pytest_cache/
8
+ .mypy_cache/
9
+ *.egg-info/
10
+ uv.lock
11
+ docs/shots/
12
+ .DS_Store
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tring
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,71 @@
1
+ Metadata-Version: 2.5
2
+ Name: tring-sdk
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK of the Tring API: Israeli receipts and invoices.
5
+ Project-URL: Homepage, https://developers.tring.co.il
6
+ Project-URL: Documentation, https://developers.tring.co.il/en/sdks.html
7
+ Author-email: Tring <support@tring.co.il>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: invoice,israel,israel-tax-authority,receipt,sdk,tax,tring
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Typing :: Typed
14
+ Requires-Python: >=3.9
15
+ Requires-Dist: httpx<1,>=0.24
16
+ Requires-Dist: typing-extensions>=4.7
17
+ Requires-Dist: tzdata; sys_platform == 'win32'
18
+ Provides-Extra: dev
19
+ Requires-Dist: mypy>=1.8; extra == 'dev'
20
+ Requires-Dist: pytest>=7; extra == 'dev'
21
+ Description-Content-Type: text/markdown
22
+
23
+ # tring-sdk
24
+
25
+ The official Python SDK of the [Tring API](https://developers.tring.co.il/en/): Israeli receipts and invoices.
26
+
27
+ בעברית: הספרייה הרשמית של טרינג ל-Python, להפקת קבלות וחשבוניות. התיעוד: [developers.tring.co.il](https://developers.tring.co.il/)
28
+
29
+ ```sh
30
+ pip install tring-sdk
31
+ ```
32
+
33
+ Python 3.9+. Sync (`Tring`) and async (`AsyncTring`) clients on httpx. Fully typed (TypedDicts generated from the OpenAPI spec, `py.typed`, mypy strict).
34
+
35
+ ## Issue a receipt
36
+
37
+ ```python
38
+ import os
39
+ from tring_sdk import Tring, DocType, PaymentMethod, amount, today_in_israel
40
+
41
+ tring = Tring() # reads TRING_API_KEY; sandbox keys start with kbl_test_
42
+
43
+ prepared = tring.prepare_draft(
44
+ os.environ["TRING_ISSUER_ID"],
45
+ {
46
+ "docType": DocType.RECEIPT,
47
+ "documentDate": today_in_israel(),
48
+ "customer": {"externalRef": "crm-customer-4711", "name": "ישראלה ישראלי"},
49
+ "payments": [{"method": PaymentMethod.BANK_TRANSFER, "amount": amount(118)}],
50
+ "paymentDate": today_in_israel(),
51
+ },
52
+ idempotency_key="order-1001-receipt",
53
+ )
54
+ # show prepared["draft"] to whoever approves it, then:
55
+ document = tring.confirm_draft(prepared["draft"]["id"])["document"]
56
+ ```
57
+
58
+ ## What it does for you
59
+
60
+ - **One method per API operation**, the `operationId` in snake_case (`list_documents`, `confirm_draft`), with keyword arguments for query parameters (`from_=` for `from`). `tring.request("listDocuments", ...)` calls any operation by name.
61
+ - **Retries that respect the API's rules:** a lost answer to a read or an idempotent request is sent again, a prepare with the same key; a confirm is sent again until its outcome is known, else `TringOutcomeUnknownError` with `draft_id`. Unsafe requests are never repeated after a lost answer. `Retry-After` is honoured.
62
+ - **Errors:** `TringApiError` (`code`, `status`, `issues`, `request_id`), `TringConnectionError`, `TringOutcomeUnknownError`, `TringConfigError`.
63
+ - **Helpers:** `amount()`, `quantity()`, `today_in_israel()`, `idempotency_key()`, `DocType`, `PaymentMethod`, `paginate()`, `issue()`.
64
+ - **Webhooks:** `construct_webhook_event()` checks `Tring-Signature` on the raw bytes (HMAC-SHA256, 300 s tolerance, several secrets during a rotation, constant time); checked against the service's reference code. Pluggable `SignatureScheme`. Endpoints, deliveries and `list_events()` are ordinary methods.
65
+ - **Keys stay secret:** `repr(tring)` shows only the public part of the key.
66
+
67
+ Try it without a key against the local mock: `npx tring-mock-server`.
68
+
69
+ Docs: [SDKs](https://developers.tring.co.il/en/sdks.html) · [Issuing](https://developers.tring.co.il/en/issuing.html) · [Reference](https://developers.tring.co.il/en/reference.html)
70
+
71
+ MIT
@@ -0,0 +1,49 @@
1
+ # tring-sdk
2
+
3
+ The official Python SDK of the [Tring API](https://developers.tring.co.il/en/): Israeli receipts and invoices.
4
+
5
+ בעברית: הספרייה הרשמית של טרינג ל-Python, להפקת קבלות וחשבוניות. התיעוד: [developers.tring.co.il](https://developers.tring.co.il/)
6
+
7
+ ```sh
8
+ pip install tring-sdk
9
+ ```
10
+
11
+ Python 3.9+. Sync (`Tring`) and async (`AsyncTring`) clients on httpx. Fully typed (TypedDicts generated from the OpenAPI spec, `py.typed`, mypy strict).
12
+
13
+ ## Issue a receipt
14
+
15
+ ```python
16
+ import os
17
+ from tring_sdk import Tring, DocType, PaymentMethod, amount, today_in_israel
18
+
19
+ tring = Tring() # reads TRING_API_KEY; sandbox keys start with kbl_test_
20
+
21
+ prepared = tring.prepare_draft(
22
+ os.environ["TRING_ISSUER_ID"],
23
+ {
24
+ "docType": DocType.RECEIPT,
25
+ "documentDate": today_in_israel(),
26
+ "customer": {"externalRef": "crm-customer-4711", "name": "ישראלה ישראלי"},
27
+ "payments": [{"method": PaymentMethod.BANK_TRANSFER, "amount": amount(118)}],
28
+ "paymentDate": today_in_israel(),
29
+ },
30
+ idempotency_key="order-1001-receipt",
31
+ )
32
+ # show prepared["draft"] to whoever approves it, then:
33
+ document = tring.confirm_draft(prepared["draft"]["id"])["document"]
34
+ ```
35
+
36
+ ## What it does for you
37
+
38
+ - **One method per API operation**, the `operationId` in snake_case (`list_documents`, `confirm_draft`), with keyword arguments for query parameters (`from_=` for `from`). `tring.request("listDocuments", ...)` calls any operation by name.
39
+ - **Retries that respect the API's rules:** a lost answer to a read or an idempotent request is sent again, a prepare with the same key; a confirm is sent again until its outcome is known, else `TringOutcomeUnknownError` with `draft_id`. Unsafe requests are never repeated after a lost answer. `Retry-After` is honoured.
40
+ - **Errors:** `TringApiError` (`code`, `status`, `issues`, `request_id`), `TringConnectionError`, `TringOutcomeUnknownError`, `TringConfigError`.
41
+ - **Helpers:** `amount()`, `quantity()`, `today_in_israel()`, `idempotency_key()`, `DocType`, `PaymentMethod`, `paginate()`, `issue()`.
42
+ - **Webhooks:** `construct_webhook_event()` checks `Tring-Signature` on the raw bytes (HMAC-SHA256, 300 s tolerance, several secrets during a rotation, constant time); checked against the service's reference code. Pluggable `SignatureScheme`. Endpoints, deliveries and `list_events()` are ordinary methods.
43
+ - **Keys stay secret:** `repr(tring)` shows only the public part of the key.
44
+
45
+ Try it without a key against the local mock: `npx tring-mock-server`.
46
+
47
+ Docs: [SDKs](https://developers.tring.co.il/en/sdks.html) · [Issuing](https://developers.tring.co.il/en/issuing.html) · [Reference](https://developers.tring.co.il/en/reference.html)
48
+
49
+ MIT
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.18"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "tring-sdk"
7
+ version = "0.1.0"
8
+ description = "Official Python SDK of the Tring API: Israeli receipts and invoices."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.9"
13
+ dependencies = [
14
+ "httpx>=0.24,<1",
15
+ "typing_extensions>=4.7",
16
+ "tzdata; sys_platform == 'win32'",
17
+ ]
18
+ keywords = ["tring", "invoice", "receipt", "israel", "tax", "israel-tax-authority", "sdk"]
19
+ authors = [{ name = "Tring", email = "support@tring.co.il" }]
20
+ classifiers = [
21
+ "Programming Language :: Python :: 3",
22
+ "Typing :: Typed",
23
+ "License :: OSI Approved :: MIT License",
24
+ ]
25
+
26
+ [project.urls]
27
+ Homepage = "https://developers.tring.co.il"
28
+ Documentation = "https://developers.tring.co.il/en/sdks.html"
29
+
30
+ [project.optional-dependencies]
31
+ dev = ["pytest>=7", "mypy>=1.8"]
32
+
33
+ [tool.hatch.build.targets.sdist]
34
+ include = ["src/tring_sdk", "README.md", "LICENSE", "pyproject.toml"]
35
+
36
+ [tool.hatch.build.targets.wheel]
37
+ packages = ["src/tring_sdk"]
38
+
39
+ [tool.pytest.ini_options]
40
+ testpaths = ["tests"]
41
+
42
+ [tool.mypy]
43
+ strict = true
44
+ files = ["src/tring_sdk"]
@@ -0,0 +1,77 @@
1
+ """Official Python SDK of the Tring API: Israeli receipts and invoices.
2
+
3
+ from tring_sdk import Tring
4
+ tring = Tring() # reads TRING_API_KEY; sandbox keys start with kbl_test_
5
+ """
6
+
7
+ from ._client import AsyncTring, Tring
8
+ from ._errors import (
9
+ TringApiError,
10
+ TringApprovalDeclinedError,
11
+ TringConfigError,
12
+ TringConnectionError,
13
+ TringError,
14
+ TringOutcomeUnknownError,
15
+ TringSignatureError,
16
+ is_tring_api_error,
17
+ )
18
+ from ._generated import types
19
+ from ._generated.operations import OPERATIONS, SPEC_HASH, SPEC_VERSION, WEBHOOK_EVENT_TYPES
20
+ from ._helpers import (
21
+ DocType,
22
+ PaymentMethod,
23
+ amount,
24
+ file_media_type,
25
+ idempotency_key,
26
+ is_valid_idempotency_key,
27
+ key_environment,
28
+ public_key_part,
29
+ quantity,
30
+ redact_keys,
31
+ today_in_israel,
32
+ )
33
+ from ._version import PRODUCTION_BASE_URL, SANDBOX_BASE_URL, __version__
34
+ from ._webhooks import (
35
+ DEFAULT_SIGNATURE_SCHEME,
36
+ SignatureScheme,
37
+ construct_webhook_event,
38
+ sign_webhook_payload,
39
+ verify_webhook_signature,
40
+ )
41
+
42
+ __all__ = [
43
+ "Tring",
44
+ "AsyncTring",
45
+ "TringError",
46
+ "TringApiError",
47
+ "TringConfigError",
48
+ "TringConnectionError",
49
+ "TringOutcomeUnknownError",
50
+ "TringApprovalDeclinedError",
51
+ "TringSignatureError",
52
+ "is_tring_api_error",
53
+ "DocType",
54
+ "PaymentMethod",
55
+ "amount",
56
+ "quantity",
57
+ "today_in_israel",
58
+ "idempotency_key",
59
+ "file_media_type",
60
+ "is_valid_idempotency_key",
61
+ "key_environment",
62
+ "public_key_part",
63
+ "redact_keys",
64
+ "verify_webhook_signature",
65
+ "construct_webhook_event",
66
+ "sign_webhook_payload",
67
+ "SignatureScheme",
68
+ "DEFAULT_SIGNATURE_SCHEME",
69
+ "OPERATIONS",
70
+ "WEBHOOK_EVENT_TYPES",
71
+ "SPEC_VERSION",
72
+ "SPEC_HASH",
73
+ "SANDBOX_BASE_URL",
74
+ "PRODUCTION_BASE_URL",
75
+ "types",
76
+ "__version__",
77
+ ]