ishtaran 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.
- ishtaran-0.1.0/.github/RELEASE_NOTES_TEMPLATE.md +13 -0
- ishtaran-0.1.0/.github/workflows/release.yml +67 -0
- ishtaran-0.1.0/.gitignore +8 -0
- ishtaran-0.1.0/AUTHENTICATION.md +26 -0
- ishtaran-0.1.0/CHANGELOG.md +34 -0
- ishtaran-0.1.0/CONFIGURATION.md +35 -0
- ishtaran-0.1.0/CORE_API.md +47 -0
- ishtaran-0.1.0/EASY_MODE.md +27 -0
- ishtaran-0.1.0/ERROR_HANDLING.md +51 -0
- ishtaran-0.1.0/FEATURES.md +17 -0
- ishtaran-0.1.0/GETTING_STARTED.md +59 -0
- ishtaran-0.1.0/IDEMPOTENCY.md +22 -0
- ishtaran-0.1.0/LICENSE +201 -0
- ishtaran-0.1.0/PKG-INFO +243 -0
- ishtaran-0.1.0/README.md +216 -0
- ishtaran-0.1.0/RETRIES.md +14 -0
- ishtaran-0.1.0/SECURITY.md +24 -0
- ishtaran-0.1.0/SECURITY_REVIEW.md +57 -0
- ishtaran-0.1.0/WEBHOOKS.md +43 -0
- ishtaran-0.1.0/examples/01_auth.py +9 -0
- ishtaran-0.1.0/examples/02_create_account.py +21 -0
- ishtaran-0.1.0/examples/03_receive_payment_easy.py +25 -0
- ishtaran-0.1.0/examples/04_create_transaction_core.py +26 -0
- ishtaran-0.1.0/examples/05_payment_intent_core.py +20 -0
- ishtaran-0.1.0/examples/06_settlement.py +17 -0
- ishtaran-0.1.0/examples/07_withdrawal_quote.py +19 -0
- ishtaran-0.1.0/examples/08_withdrawal.py +19 -0
- ishtaran-0.1.0/examples/09_ledger.py +21 -0
- ishtaran-0.1.0/examples/10_webhook_verification.py +29 -0
- ishtaran-0.1.0/examples/11_sandbox.py +23 -0
- ishtaran-0.1.0/examples/12_account_holder_invitation.py +31 -0
- ishtaran-0.1.0/examples/13_self_custody_signing.py +95 -0
- ishtaran-0.1.0/examples/README.md +38 -0
- ishtaran-0.1.0/pyproject.toml +58 -0
- ishtaran-0.1.0/src/ishtaran/__init__.py +47 -0
- ishtaran-0.1.0/src/ishtaran/auth/__init__.py +0 -0
- ishtaran-0.1.0/src/ishtaran/auth/bearer_token_holder.py +17 -0
- ishtaran-0.1.0/src/ishtaran/client.py +206 -0
- ishtaran-0.1.0/src/ishtaran/config/__init__.py +0 -0
- ishtaran-0.1.0/src/ishtaran/config/client_config.py +67 -0
- ishtaran-0.1.0/src/ishtaran/config/endpoints.py +24 -0
- ishtaran-0.1.0/src/ishtaran/config/environment.py +9 -0
- ishtaran-0.1.0/src/ishtaran/config/retry_policy.py +24 -0
- ishtaran-0.1.0/src/ishtaran/easy/__init__.py +0 -0
- ishtaran-0.1.0/src/ishtaran/error/__init__.py +0 -0
- ishtaran-0.1.0/src/ishtaran/error/error_mapper.py +63 -0
- ishtaran-0.1.0/src/ishtaran/error/errors.py +109 -0
- ishtaran-0.1.0/src/ishtaran/http/__init__.py +0 -0
- ishtaran-0.1.0/src/ishtaran/http/authenticating_transport.py +27 -0
- ishtaran-0.1.0/src/ishtaran/http/httpx_transport.py +55 -0
- ishtaran-0.1.0/src/ishtaran/http/logging_transport.py +36 -0
- ishtaran-0.1.0/src/ishtaran/http/retrying_transport.py +58 -0
- ishtaran-0.1.0/src/ishtaran/http/types.py +58 -0
- ishtaran-0.1.0/src/ishtaran/idempotency/__init__.py +0 -0
- ishtaran-0.1.0/src/ishtaran/idempotency/idempotency_key_generator.py +19 -0
- ishtaran-0.1.0/src/ishtaran/model/__init__.py +0 -0
- ishtaran-0.1.0/src/ishtaran/model/account_holders.py +131 -0
- ishtaran-0.1.0/src/ishtaran/model/control_plane.py +245 -0
- ishtaran-0.1.0/src/ishtaran/model/data_plane.py +225 -0
- ishtaran-0.1.0/src/ishtaran/model/deposits.py +74 -0
- ishtaran-0.1.0/src/ishtaran/model/enum_factory.py +51 -0
- ishtaran-0.1.0/src/ishtaran/model/enums.py +64 -0
- ishtaran-0.1.0/src/ishtaran/model/execution_custody.py +178 -0
- ishtaran-0.1.0/src/ishtaran/model/sandbox.py +84 -0
- ishtaran-0.1.0/src/ishtaran/model/settlement.py +138 -0
- ishtaran-0.1.0/src/ishtaran/model/webhook_endpoints.py +97 -0
- ishtaran-0.1.0/src/ishtaran/model/workflow.py +225 -0
- ishtaran-0.1.0/src/ishtaran/pagination/__init__.py +0 -0
- ishtaran-0.1.0/src/ishtaran/pagination/page_iterator.py +25 -0
- ishtaran-0.1.0/src/ishtaran/resources/__init__.py +0 -0
- ishtaran-0.1.0/src/ishtaran/resources/account_holders_resource.py +70 -0
- ishtaran-0.1.0/src/ishtaran/resources/accounts_resource.py +60 -0
- ishtaran-0.1.0/src/ishtaran/resources/api_keys_resource.py +26 -0
- ishtaran-0.1.0/src/ishtaran/resources/applications_resource.py +27 -0
- ishtaran-0.1.0/src/ishtaran/resources/asset_network_catalog_resource.py +56 -0
- ishtaran-0.1.0/src/ishtaran/resources/auth_resource.py +46 -0
- ishtaran-0.1.0/src/ishtaran/resources/deposits_resource.py +45 -0
- ishtaran-0.1.0/src/ishtaran/resources/environments_resource.py +24 -0
- ishtaran-0.1.0/src/ishtaran/resources/event_types_resource.py +18 -0
- ishtaran-0.1.0/src/ishtaran/resources/events_resource.py +33 -0
- ishtaran-0.1.0/src/ishtaran/resources/ledger_resource.py +56 -0
- ishtaran-0.1.0/src/ishtaran/resources/members_resource.py +46 -0
- ishtaran-0.1.0/src/ishtaran/resources/organizations_resource.py +47 -0
- ishtaran-0.1.0/src/ishtaran/resources/refunds_resource.py +28 -0
- ishtaran-0.1.0/src/ishtaran/resources/resource_support.py +76 -0
- ishtaran-0.1.0/src/ishtaran/resources/sandbox_resource.py +67 -0
- ishtaran-0.1.0/src/ishtaran/resources/settlements_resource.py +37 -0
- ishtaran-0.1.0/src/ishtaran/resources/signing_requests_resource.py +66 -0
- ishtaran-0.1.0/src/ishtaran/resources/transactions_resource.py +86 -0
- ishtaran-0.1.0/src/ishtaran/resources/wallets_resource.py +53 -0
- ishtaran-0.1.0/src/ishtaran/resources/webhook_deliveries_resource.py +18 -0
- ishtaran-0.1.0/src/ishtaran/resources/webhook_endpoints_resource.py +63 -0
- ishtaran-0.1.0/src/ishtaran/resources/withdrawals_resource.py +122 -0
- ishtaran-0.1.0/src/ishtaran/resources/workflows_resource.py +59 -0
- ishtaran-0.1.0/src/ishtaran/signing/__init__.py +5 -0
- ishtaran-0.1.0/src/ishtaran/signing/canonical_hash.py +63 -0
- ishtaran-0.1.0/src/ishtaran/util/__init__.py +0 -0
- ishtaran-0.1.0/src/ishtaran/util/dotnet_timespan.py +20 -0
- ishtaran-0.1.0/src/ishtaran/util/json_util.py +74 -0
- ishtaran-0.1.0/src/ishtaran/util/polling.py +30 -0
- ishtaran-0.1.0/src/ishtaran/util/redactor.py +22 -0
- ishtaran-0.1.0/src/ishtaran/util/user_agent.py +4 -0
- ishtaran-0.1.0/src/ishtaran/wallet/__init__.py +19 -0
- ishtaran-0.1.0/src/ishtaran/wallet/_bip32.py +117 -0
- ishtaran-0.1.0/src/ishtaran/wallet/derivation_scheme.py +5 -0
- ishtaran-0.1.0/src/ishtaran/wallet/signer.py +52 -0
- ishtaran-0.1.0/src/ishtaran/wallet/tron_address.py +37 -0
- ishtaran-0.1.0/src/ishtaran/wallet/wallet_factory.py +61 -0
- ishtaran-0.1.0/src/ishtaran/webhook/__init__.py +0 -0
- ishtaran-0.1.0/src/ishtaran/webhook/webhook_signature_verifier.py +43 -0
- ishtaran-0.1.0/tests/__init__.py +0 -0
- ishtaran-0.1.0/tests/fake_transport.py +46 -0
- ishtaran-0.1.0/tests/test_asset_network_catalog_resource.py +21 -0
- ishtaran-0.1.0/tests/test_authenticating_transport.py +32 -0
- ishtaran-0.1.0/tests/test_canonical_hash_reference_vectors.py +54 -0
- ishtaran-0.1.0/tests/test_client_config.py +52 -0
- ishtaran-0.1.0/tests/test_client_easy_mode.py +117 -0
- ishtaran-0.1.0/tests/test_enums.py +30 -0
- ishtaran-0.1.0/tests/test_error_mapper.py +78 -0
- ishtaran-0.1.0/tests/test_httpx_transport.py +31 -0
- ishtaran-0.1.0/tests/test_idempotency_key_generator.py +19 -0
- ishtaran-0.1.0/tests/test_json_util.py +42 -0
- ishtaran-0.1.0/tests/test_logging_transport.py +36 -0
- ishtaran-0.1.0/tests/test_organizations_resource.py +22 -0
- ishtaran-0.1.0/tests/test_page_iterator.py +37 -0
- ishtaran-0.1.0/tests/test_query_encoding_safety.py +31 -0
- ishtaran-0.1.0/tests/test_redactor.py +20 -0
- ishtaran-0.1.0/tests/test_resource_support_encoding.py +51 -0
- ishtaran-0.1.0/tests/test_retrying_transport.py +61 -0
- ishtaran-0.1.0/tests/test_signer.py +76 -0
- ishtaran-0.1.0/tests/test_tron_address.py +49 -0
- ishtaran-0.1.0/tests/test_wallet_factory.py +49 -0
- ishtaran-0.1.0/tests/test_webhook_endpoints_resource.py +35 -0
- ishtaran-0.1.0/tests/test_webhook_signature_verifier.py +57 -0
- ishtaran-0.1.0/tests/test_withdrawals_resource.py +71 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## Ishtaran Python SDK -- first public release
|
|
2
|
+
|
|
3
|
+
This is the first public **Development Preview** release of the official Ishtaran Python SDK. It
|
|
4
|
+
is not GA, not stable, and not production-ready -- see
|
|
5
|
+
[Project status](../README.md#project-status) in the README for the current, up-to-date state.
|
|
6
|
+
|
|
7
|
+
- Official Ishtaran SDK, covering the current HTTP API surface (Easy Mode + Core API).
|
|
8
|
+
- Self-custody wallet generation and transaction signing supported end to end -- see
|
|
9
|
+
[Self-custody](../README.md#self-custody) in the README.
|
|
10
|
+
- The public Sandbox is not live yet.
|
|
11
|
+
- Production blockchain execution is not available yet.
|
|
12
|
+
|
|
13
|
+
See the [README](../README.md) and [CHANGELOG](../CHANGELOG.md) for full detail.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# Triggered only by a protected version tag (never a pull request, never a
|
|
4
|
+
# branch push) -- pushing a `v*` tag requires write access to this repository,
|
|
5
|
+
# so a fork/PR can never trigger a publish. Least privilege: `test` only
|
|
6
|
+
# reads the repo; `publish` is the only job with `id-token: write` (PyPI
|
|
7
|
+
# Trusted Publishing/OIDC -- no long-lived PyPI API token secret needed) and
|
|
8
|
+
# runs behind the `pypi-release` environment, which the repository owner can
|
|
9
|
+
# gate with required reviewers in Settings -> Environments.
|
|
10
|
+
#
|
|
11
|
+
# PyPI Trusted Publishing must be configured once on pypi.org (a "pending
|
|
12
|
+
# publisher" for a not-yet-existing project) pointing at this exact repo,
|
|
13
|
+
# this workflow filename, and this environment name before the first run of
|
|
14
|
+
# this workflow can succeed -- that one-time setup is a manual owner action,
|
|
15
|
+
# see the release report for the exact steps.
|
|
16
|
+
|
|
17
|
+
on:
|
|
18
|
+
push:
|
|
19
|
+
tags:
|
|
20
|
+
- 'v[0-9]+.[0-9]+.[0-9]+'
|
|
21
|
+
|
|
22
|
+
permissions:
|
|
23
|
+
contents: read
|
|
24
|
+
|
|
25
|
+
jobs:
|
|
26
|
+
test:
|
|
27
|
+
runs-on: ubuntu-latest
|
|
28
|
+
permissions:
|
|
29
|
+
contents: read
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v4
|
|
32
|
+
- uses: actions/setup-python@v5
|
|
33
|
+
with:
|
|
34
|
+
python-version: '3.10'
|
|
35
|
+
- run: pip install -e ".[dev]"
|
|
36
|
+
- run: python -m mypy src/
|
|
37
|
+
- run: python -m pytest -q
|
|
38
|
+
|
|
39
|
+
publish:
|
|
40
|
+
needs: test
|
|
41
|
+
runs-on: ubuntu-latest
|
|
42
|
+
environment: pypi-release
|
|
43
|
+
permissions:
|
|
44
|
+
contents: read
|
|
45
|
+
id-token: write
|
|
46
|
+
steps:
|
|
47
|
+
- uses: actions/checkout@v4
|
|
48
|
+
- uses: actions/setup-python@v5
|
|
49
|
+
with:
|
|
50
|
+
python-version: '3.10'
|
|
51
|
+
- run: pip install build
|
|
52
|
+
# Fails the job if the tag and pyproject.toml version ever drift --
|
|
53
|
+
# never publish a version that doesn't match what was tagged/reviewed.
|
|
54
|
+
- name: Verify tag matches pyproject.toml version
|
|
55
|
+
run: |
|
|
56
|
+
TAG_VERSION="${GITHUB_REF_NAME#v}"
|
|
57
|
+
# No TOML parser dependency (tomllib needs Python 3.11+, this job runs
|
|
58
|
+
# 3.10 to match the SDK's own minimum) -- pyproject.toml's `version =
|
|
59
|
+
# "x.y.z"` line is simple enough for grep/sed.
|
|
60
|
+
PKG_VERSION="$(grep -m1 '^version = ' pyproject.toml | sed -E 's/^version = "(.*)"$/\1/')"
|
|
61
|
+
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
|
|
62
|
+
echo "Tag v$TAG_VERSION does not match pyproject.toml version $PKG_VERSION"
|
|
63
|
+
exit 1
|
|
64
|
+
fi
|
|
65
|
+
- run: python -m build
|
|
66
|
+
- name: Publish to PyPI
|
|
67
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Authentication
|
|
2
|
+
|
|
3
|
+
Two real mechanisms (see `SDK_CAPABILITY_SPEC.md` §3).
|
|
4
|
+
|
|
5
|
+
## `X-Api-Key` (recommended)
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
client = IshtaranClient.create(api_key="<your API Key>", environment=Environment.LOCAL)
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Works for read and write on the 8 Data Plane modules. Does not work today for Control Plane,
|
|
12
|
+
reading the AssetNetworkCatalog, or WebhookEndpoint management (real API gaps, §12.3/§12.4).
|
|
13
|
+
|
|
14
|
+
## Member JWT (human login)
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
client.auth.login(email, password)
|
|
18
|
+
# the client now uses the token internally for every subsequent Control Plane call.
|
|
19
|
+
org = client.organizations.get(organization_id)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Never mix them silently
|
|
23
|
+
|
|
24
|
+
The SDK never sends the API Key as a Bearer token nor the JWT as `X-Api-Key`. If both are
|
|
25
|
+
configured, both headers are sent on Data Plane routes — avoid configuring both at once
|
|
26
|
+
against different Organizations (precedence not verified live by this SDK).
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Follows [SemVer](https://semver.org/). Not yet published (PyPI).
|
|
4
|
+
|
|
5
|
+
## [1.0.0.dev0] — 2026-08-17
|
|
6
|
+
|
|
7
|
+
Third implementation of the Ishtaran Official SDK Program — 100% functional parity with the
|
|
8
|
+
Java SDK (reference implementation).
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Central client (`IshtaranClient.create(...)`).
|
|
13
|
+
- Complete Core API — 16 modules, 93 real operations.
|
|
14
|
+
- Easy Mode — `receive_payment`/`get_payment`/`wait_for_payment`, `withdraw`, `get_balance`,
|
|
15
|
+
`verify_webhook_signature`.
|
|
16
|
+
- `X-Api-Key` + Member JWT authentication.
|
|
17
|
+
- Complete `IshtaranError` hierarchy.
|
|
18
|
+
- Safe retry with backoff+jitter.
|
|
19
|
+
- Idempotency (body and header, depending on the endpoint).
|
|
20
|
+
- Real pagination via lazy generators.
|
|
21
|
+
- Forward-compatible enums (`from_raw`/`is_unknown`, `UNKNOWN` fallback).
|
|
22
|
+
- Money always as `decimal.Decimal` (never `float`), via `json.loads(parse_float=Decimal,
|
|
23
|
+
parse_int=Decimal)`.
|
|
24
|
+
- `verify_webhook_signature`/`compute_webhook_signature` (HMAC-SHA256, constant time).
|
|
25
|
+
- Opt-in logging with central redaction.
|
|
26
|
+
- HTTP redirects never followed automatically (`follow_redirects=False`).
|
|
27
|
+
- `mypy --strict` clean across all 63 modules of the SDK.
|
|
28
|
+
- Packaging validated — real wheel + sdist (`python -m build`), installed in a clean venv.
|
|
29
|
+
|
|
30
|
+
### Known, still pending
|
|
31
|
+
|
|
32
|
+
- Sync only in this version (`httpx.Client`) — async support is a documented future extension,
|
|
33
|
+
same pacing allowed for Java ("sync-first initially").
|
|
34
|
+
- Real PyPI publication — blocked on a pending licensing decision.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Configuration
|
|
2
|
+
|
|
3
|
+
```python
|
|
4
|
+
client = IshtaranClient.create(
|
|
5
|
+
api_key="...",
|
|
6
|
+
environment=Environment.LOCAL,
|
|
7
|
+
base_url="http://localhost:8080", # always explicit when present
|
|
8
|
+
connect_timeout_seconds=5.0, # default
|
|
9
|
+
request_timeout_seconds=30.0, # default
|
|
10
|
+
enable_logging=True, # opt-in, never on by default
|
|
11
|
+
)
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## `base_url`/`Environment`
|
|
15
|
+
|
|
16
|
+
| Environment | Default | Explicit `base_url`? |
|
|
17
|
+
|---|---|---|
|
|
18
|
+
| `LOCAL` | `http://localhost:8080` | No |
|
|
19
|
+
| `SANDBOX`/`PRODUCTION` | **none** — infra not yet provisioned | **Yes, required** |
|
|
20
|
+
|
|
21
|
+
Constructing without `base_url` for `SANDBOX`/`PRODUCTION` raises `ValueError` immediately — it
|
|
22
|
+
never points to a made-up URL.
|
|
23
|
+
|
|
24
|
+
## TLS
|
|
25
|
+
|
|
26
|
+
Verified by default (native `httpx` behavior); never disabled by this SDK.
|
|
27
|
+
|
|
28
|
+
## Redirects
|
|
29
|
+
|
|
30
|
+
`httpx.Client(follow_redirects=False)` — any 3xx is treated as a `NetworkError`, never followed
|
|
31
|
+
automatically (same policy as Java/TypeScript).
|
|
32
|
+
|
|
33
|
+
## User-Agent
|
|
34
|
+
|
|
35
|
+
`ishtaran-python/<version>` — fixed, no personal data.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Core API
|
|
2
|
+
|
|
3
|
+
Complete, literal coverage of the real API — 83 routes, 16 modules (see `SDK_FEATURE_MATRIX.md`,
|
|
4
|
+
`SDK_METHOD_MAP.md`). No invented endpoint, no admin-only/platform-only route exposed.
|
|
5
|
+
|
|
6
|
+
## Control Plane (always Member JWT)
|
|
7
|
+
|
|
8
|
+
`client.organizations`, `client.applications`, `client.environments`, `client.api_keys`,
|
|
9
|
+
`client.members`, `client.asset_network_catalog`, `client.webhook_endpoints`, `client.webhook_deliveries`.
|
|
10
|
+
|
|
11
|
+
## Data Plane (API Key or Member JWT)
|
|
12
|
+
|
|
13
|
+
`client.accounts`, `client.transactions`, `client.deposits`, `client.ledger`, `client.settlements`,
|
|
14
|
+
`client.refunds`, `client.withdrawals`, `client.workflows`/`event_types`/`events`, `client.sandbox`.
|
|
15
|
+
|
|
16
|
+
## Example — full flow without Easy Mode
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
from decimal import Decimal
|
|
20
|
+
|
|
21
|
+
account = client.accounts.create(organization_id, "customer-123")
|
|
22
|
+
client.accounts.authorize_application(account.account_id, application_id)
|
|
23
|
+
|
|
24
|
+
txn = client.transactions.create(organization_id, application_id, None, asset_network_id, Decimal("100"), [payer, recipient])
|
|
25
|
+
intent = client.deposits.create_payment_intent(organization_id, txn.transaction_id, asset_network_id, Decimal("100"))
|
|
26
|
+
full_intent = client.deposits.get_payment_intent(intent.payment_intent_id)
|
|
27
|
+
# full_intent.deposit_address -- real address to watch on-chain
|
|
28
|
+
|
|
29
|
+
settlement = client.settlements.execute_settlement(txn.transaction_id)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Real anonymous objects
|
|
33
|
+
|
|
34
|
+
Several real POSTs return a minimal object (`CreateAccountResult(account_id=...)`,
|
|
35
|
+
`CreateTransactionResult(transaction_id=...)`) instead of the full resource — confirmed in the
|
|
36
|
+
real handler source code. Fetch the full resource with the corresponding `get(...)`.
|
|
37
|
+
|
|
38
|
+
## Real pagination (lazy generators)
|
|
39
|
+
|
|
40
|
+
Only 2 endpoints have real pagination: `withdrawals.list`/`.list_all` and
|
|
41
|
+
`ledger.list_entries`/`.list_all_entries`. The `.list_all*` variants are generators — they fetch
|
|
42
|
+
the next page on demand:
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
for withdrawal in client.withdrawals.list_all(organization_id, page_size=20):
|
|
46
|
+
print(withdrawal.withdrawal_id)
|
|
47
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Easy Mode vs. Core API
|
|
2
|
+
|
|
3
|
+
## Use Easy Mode when...
|
|
4
|
+
|
|
5
|
+
- You want to integrate fast: `client.receive_payment(...)`, `client.withdraw(...)`, `client.get_balance(...)`.
|
|
6
|
+
- You need to safely wait for an asynchronous result: `client.wait_for_payment(...)`,
|
|
7
|
+
`client.withdrawals.wait_for(...)`, `client.transactions.wait_for(...)` — always with a timeout.
|
|
8
|
+
- You only need to verify a webhook signature: `client.verify_webhook_signature(...)`.
|
|
9
|
+
|
|
10
|
+
## Use Core API when...
|
|
11
|
+
|
|
12
|
+
- You need granular control (`client.transactions.reserve(...)` vs. `client.settlements.execute_settlement(...)`).
|
|
13
|
+
- You need a resource that Easy Mode doesn't cover — 93 real operations, see `SDK_FEATURE_MATRIX.md`.
|
|
14
|
+
- You want real pagination: `client.withdrawals.list_all(...)`/`client.ledger.list_all_entries(...)`
|
|
15
|
+
(lazy generators) instead of a single call.
|
|
16
|
+
|
|
17
|
+
## Concrete equivalence
|
|
18
|
+
|
|
19
|
+
| Easy Mode | Core equivalent |
|
|
20
|
+
|---|---|
|
|
21
|
+
| `client.receive_payment(...)` | `transactions.create()` + `deposits.create_payment_intent()` + `deposits.get_payment_intent()` |
|
|
22
|
+
| `client.withdraw(...)` | `withdrawals.create_destination()` + `withdrawals.request()` |
|
|
23
|
+
| `client.get_balance(...)` | `ledger.get_balance(...)` |
|
|
24
|
+
|
|
25
|
+
Easy Mode never hides the real `withdrawal_id`/`transaction_id`/`payment_intent_id`. `withdraw()`
|
|
26
|
+
always returns `estimated_network_fee`/`estimated_recipient_amount`/`status` — never just
|
|
27
|
+
success/failure.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Error Handling
|
|
2
|
+
|
|
3
|
+
Every exception is a subclass of `IshtaranError` (see `SDK_CAPABILITY_SPEC.md` §6):
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
IshtaranError
|
|
7
|
+
├── AuthenticationError (401 — no code/details)
|
|
8
|
+
├── AuthorizationError (403 — same)
|
|
9
|
+
├── ValidationError (400, code=VALIDATION_ERROR — 1 string, never a per-field list)
|
|
10
|
+
├── NotFoundError (404, code=NOT_FOUND)
|
|
11
|
+
├── ConflictError (409 — various codes)
|
|
12
|
+
├── IdempotencyConflictError (409, code=IDEMPOTENCY_KEY_CONFLICT — extends ConflictError)
|
|
13
|
+
├── RateLimitError (429, code=RATE_LIMITED — retry_after_seconds)
|
|
14
|
+
├── NetworkError (transport failure)
|
|
15
|
+
├── TimeoutError (request timeout, or wait_for exceeding its deadline)
|
|
16
|
+
└── ApiError (fallback — preserves raw http_status/code/details)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from ishtaran import ValidationError, RateLimitError, IshtaranError
|
|
23
|
+
import time
|
|
24
|
+
|
|
25
|
+
try:
|
|
26
|
+
client.withdrawals.request(org_id, account_id, dest_id, asset_network_id, amount)
|
|
27
|
+
except ValidationError as e:
|
|
28
|
+
print("Validation failed:", e.message)
|
|
29
|
+
except RateLimitError as e:
|
|
30
|
+
time.sleep(e.retry_after_seconds or 1)
|
|
31
|
+
except IshtaranError as e:
|
|
32
|
+
print(f"Failed ({e.http_status}):", e.message)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Available fields
|
|
36
|
+
|
|
37
|
+
`http_status`, `code`, `request_id` (always `None` today — the real API has no correlation ID
|
|
38
|
+
mechanism, §12.1), `details` (raw body), `retryable`.
|
|
39
|
+
|
|
40
|
+
## Why 401/403 have no `code`/`details`
|
|
41
|
+
|
|
42
|
+
No backend `AuthenticationHandler` registers a custom challenge — the authentication middleware
|
|
43
|
+
responds with an empty body before reaching the handler that produces `ProblemDetails`.
|
|
44
|
+
|
|
45
|
+
## Naming note
|
|
46
|
+
|
|
47
|
+
`ishtaran.TimeoutError` deliberately shadows `builtins.TimeoutError`, to keep exact name parity
|
|
48
|
+
with Java/TypeScript (rule from the brief). Internal SDK code that needs the real network timeout
|
|
49
|
+
uses `httpx.TimeoutException`, not the builtin — no practical collision. If your own code also
|
|
50
|
+
uses `builtins.TimeoutError`, import with an alias: `from ishtaran import TimeoutError as
|
|
51
|
+
IshtaranTimeoutError`.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Features
|
|
2
|
+
|
|
3
|
+
Derived from the real API contract (see the [API Reference](https://ishtaran.com/docs/api/ishtaran-api)). Core API: 93/93 real
|
|
4
|
+
operations (16/16 modules). Easy Mode: 100%. Cross-cutting: 100% (config, auth, errors, retry,
|
|
5
|
+
idempotency, pagination, forward-compatible enums, security/redaction, opt-in logging, safe
|
|
6
|
+
wait_for, validated wheel+sdist packaging).
|
|
7
|
+
|
|
8
|
+
100% functional parity with the Java SDK (reference implementation) — same business-concept
|
|
9
|
+
names, same defaults, same retry/idempotency/timeout policy, differing only in the language's
|
|
10
|
+
idiom (`client.withdrawals.quote(...)` identical in Python and TypeScript; Java uses
|
|
11
|
+
`client.withdrawals().quote(...)`).
|
|
12
|
+
|
|
13
|
+
## Extra compared to Java/TypeScript
|
|
14
|
+
|
|
15
|
+
- `mypy --strict` clean (full static verification).
|
|
16
|
+
- Money as a native `decimal.Decimal` — more idiomatic than TypeScript's `string`, with no
|
|
17
|
+
third-party dependency for precision (the stdlib `json`/`decimal` already solve the problem).
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
## 1. Install
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install -e ".[dev]" # local, see README.md — not yet published on PyPI
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## 2. Build the client
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
import os
|
|
13
|
+
from ishtaran import IshtaranClient, Environment
|
|
14
|
+
|
|
15
|
+
client = IshtaranClient.create(
|
|
16
|
+
api_key=os.environ["ISHTARAN_API_KEY"],
|
|
17
|
+
environment=Environment.LOCAL,
|
|
18
|
+
)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`Environment.SANDBOX`/`PRODUCTION` don't have a known real URL yet — use an explicit `base_url=`
|
|
22
|
+
(see [`CONFIGURATION.md`](CONFIGURATION.md)).
|
|
23
|
+
|
|
24
|
+
## 3. Check a balance (Easy Mode)
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
balance = client.get_balance(account_id, asset_network_id)
|
|
28
|
+
print("Available:", balance.available) # decimal.Decimal
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 4. Receive a payment (Easy Mode)
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from decimal import Decimal
|
|
35
|
+
|
|
36
|
+
payment = client.receive_payment(organization_id, application_id, payer_account_id, recipient_account_id, asset_network_id, Decimal("100"))
|
|
37
|
+
print("Deposit address:", payment.deposit_address)
|
|
38
|
+
|
|
39
|
+
finished = client.wait_for_payment(payment.transaction_id, payment.payment_intent_id, timeout_seconds=600, poll_interval_seconds=5)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 5. Withdrawal with visible Network Fee (Easy Mode)
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
withdrawal = client.withdraw(organization_id, account_id, asset_network_id, Decimal("50"), "TDestinationAddressReal")
|
|
46
|
+
print(f"You receive {withdrawal.estimated_recipient_amount} (fee: {withdrawal.estimated_network_fee})")
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 6. Or use Core directly
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
account = client.accounts.get(account_id)
|
|
53
|
+
quote = client.withdrawals.quote(organization_id, account_id, destination_id, asset_network_id, Decimal("50"))
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Next steps
|
|
57
|
+
|
|
58
|
+
- [`AUTHENTICATION.md`](AUTHENTICATION.md), [`EASY_MODE.md`](EASY_MODE.md), [`ERROR_HANDLING.md`](ERROR_HANDLING.md)
|
|
59
|
+
- [`examples/`](examples/) — 11 numbered examples
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Idempotency
|
|
2
|
+
|
|
3
|
+
Two real mechanisms (see `SDK_CAPABILITY_SPEC.md` §9):
|
|
4
|
+
|
|
5
|
+
## Body field — every financial endpoint
|
|
6
|
+
|
|
7
|
+
`transactions.create`, `deposits.create_payment_intent`, `settlements.execute_settlement`,
|
|
8
|
+
`refunds.execute_refund`, `withdrawals.request`, `events.ingest` — optional parameter
|
|
9
|
+
`idempotency_key`; if omitted, the SDK generates a UUID v4 automatically; if explicit, it is
|
|
10
|
+
never overwritten.
|
|
11
|
+
|
|
12
|
+
## `Idempotency-Key` header — only 2 real endpoints
|
|
13
|
+
|
|
14
|
+
`organizations.create(...)` and `organizations.create_application(...)` — the only 2 places in
|
|
15
|
+
the backend that use a header instead of a body field (confirmed in source code). Same
|
|
16
|
+
auto-generation policy.
|
|
17
|
+
|
|
18
|
+
## Resubmission
|
|
19
|
+
|
|
20
|
+
Same key + same payload = safe (replay). Same key + different payload =
|
|
21
|
+
`IdempotencyConflictError` (409). Automatic retry (`RETRIES.md`) reuses the same key from the
|
|
22
|
+
first attempt, never generates a new one per attempt.
|
ishtaran-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|