# CredGem Python SDK
A Python SDK for interacting with the CredGem API.
## Installation
```bash
pip install credgem-sdk
```
## Configuration
The SDK can be configured to work with different environments:
```python
from credgem import CredGemClient
# Production environment
client = CredGemClient(
api_key="your-api-key",
base_url="https://api.credgem.com"
)
# Staging environment
client = CredGemClient(
api_key="your-staging-key",
base_url="https://api.staging.credgem.com"
)
# Local development
client = CredGemClient(
api_key="your-dev-key",
base_url="http://localhost:8000"
)
```
## Basic Usage
```python
from credgem import CredGemClient
from decimal import Decimal
async with CredGemClient(api_key="your-api-key", base_url="https://api.credgem.com") as client:
# Create a wallet
wallet = await client.wallets.create(
name="My Wallet",
context={"customer_id": "cust_123"}
)
# Get wallet details
wallet = await client.wallets.get(wallet.id)
# List transactions
transactions = await client.transactions.list(wallet_id=wallet.id)
```
## Credit Operations
The SDK provides a context manager for safe credit operations:
```python
# With hold and debit
async with client.draw_credits(
wallet_id="wallet_123",
credit_type_id="POINTS",
amount=Decimal("50.00"),
description="Purchase with hold",
issuer="store_app",
context={"order_id": "order_123"}
) as draw:
# Process your order
result = await process_order()
if result.success:
await draw.debit() # Uses held amount
# If no debit is called, hold is automatically released
# Direct debit without hold
async with client.draw_credits(
wallet_id="wallet_123",
credit_type_id="POINTS",
description="Direct purchase",
issuer="store_app",
skip_hold=True
) as draw:
await draw.debit(amount=Decimal("25.00"))
```
## Features
- Wallet management
- Transaction operations
- Credit type operations
- Insights and analytics
- Async support
- Type hints for better IDE integration
- Automatic hold release on errors
- Idempotent operations
- Environment-specific configurations
## Documentation
For detailed documentation, visit [docs.credgem.com](https://docs.credgem.com)
Raw data
{
"_id": null,
"home_page": "https://credgem.com",
"name": "credgem-sdk",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "credits, wallet, payments, virtual-currency",
"author": "CredGem",
"author_email": "support@credgem.com",
"download_url": "https://files.pythonhosted.org/packages/48/5e/acd212b20c59d87f0b872e0baa81e64cb14fbfc1253f6e8ec8e245d29978/credgem_sdk-0.1.6.tar.gz",
"platform": null,
"description": "# CredGem Python SDK\n\nA Python SDK for interacting with the CredGem API.\n\n## Installation\n\n```bash\npip install credgem-sdk\n```\n\n## Configuration\n\nThe SDK can be configured to work with different environments:\n\n```python\nfrom credgem import CredGemClient\n\n# Production environment\nclient = CredGemClient(\n api_key=\"your-api-key\",\n base_url=\"https://api.credgem.com\"\n)\n\n# Staging environment\nclient = CredGemClient(\n api_key=\"your-staging-key\",\n base_url=\"https://api.staging.credgem.com\"\n)\n\n# Local development\nclient = CredGemClient(\n api_key=\"your-dev-key\",\n base_url=\"http://localhost:8000\"\n)\n```\n\n## Basic Usage\n\n```python\nfrom credgem import CredGemClient\nfrom decimal import Decimal\n\nasync with CredGemClient(api_key=\"your-api-key\", base_url=\"https://api.credgem.com\") as client:\n # Create a wallet\n wallet = await client.wallets.create(\n name=\"My Wallet\",\n context={\"customer_id\": \"cust_123\"}\n )\n\n # Get wallet details\n wallet = await client.wallets.get(wallet.id)\n\n # List transactions\n transactions = await client.transactions.list(wallet_id=wallet.id)\n```\n\n## Credit Operations\n\nThe SDK provides a context manager for safe credit operations:\n\n```python\n# With hold and debit\nasync with client.draw_credits(\n wallet_id=\"wallet_123\",\n credit_type_id=\"POINTS\",\n amount=Decimal(\"50.00\"),\n description=\"Purchase with hold\",\n issuer=\"store_app\",\n context={\"order_id\": \"order_123\"}\n) as draw:\n # Process your order\n result = await process_order()\n if result.success:\n await draw.debit() # Uses held amount\n # If no debit is called, hold is automatically released\n\n# Direct debit without hold\nasync with client.draw_credits(\n wallet_id=\"wallet_123\",\n credit_type_id=\"POINTS\",\n description=\"Direct purchase\",\n issuer=\"store_app\",\n skip_hold=True\n) as draw:\n await draw.debit(amount=Decimal(\"25.00\"))\n```\n\n## Features\n\n- Wallet management\n- Transaction operations\n- Credit type operations\n- Insights and analytics\n- Async support\n- Type hints for better IDE integration\n- Automatic hold release on errors\n- Idempotent operations\n- Environment-specific configurations\n\n## Documentation\n\nFor detailed documentation, visit [docs.credgem.com](https://docs.credgem.com) ",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python SDK for CredGem API - A powerful credit management system",
"version": "0.1.6",
"project_urls": {
"Documentation": "https://docs.credgem.com",
"Homepage": "https://credgem.com",
"Repository": "https://github.com/CredGem/CredGem"
},
"split_keywords": [
"credits",
" wallet",
" payments",
" virtual-currency"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "798e794a0d94866436792336396748cbad3098aa3d3ca4e46090b55c9e8078a1",
"md5": "fc9e221ee69b36a5b9b23d4276cbc6e0",
"sha256": "744e8f08ad2146800d3598b002354b2c33ed3d2b922183bc6569b919874f35e0"
},
"downloads": -1,
"filename": "credgem_sdk-0.1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fc9e221ee69b36a5b9b23d4276cbc6e0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 12823,
"upload_time": "2025-02-24T10:13:14",
"upload_time_iso_8601": "2025-02-24T10:13:14.141885Z",
"url": "https://files.pythonhosted.org/packages/79/8e/794a0d94866436792336396748cbad3098aa3d3ca4e46090b55c9e8078a1/credgem_sdk-0.1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "485eacd212b20c59d87f0b872e0baa81e64cb14fbfc1253f6e8ec8e245d29978",
"md5": "859e28ba0a7a55a9ae8b63a230cc0b17",
"sha256": "6dc69a6a0997c8ad3a971f7e28a9f5dc99abde5fb75655049bad6047f9fd1c0b"
},
"downloads": -1,
"filename": "credgem_sdk-0.1.6.tar.gz",
"has_sig": false,
"md5_digest": "859e28ba0a7a55a9ae8b63a230cc0b17",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 9245,
"upload_time": "2025-02-24T10:13:16",
"upload_time_iso_8601": "2025-02-24T10:13:16.947308Z",
"url": "https://files.pythonhosted.org/packages/48/5e/acd212b20c59d87f0b872e0baa81e64cb14fbfc1253f6e8ec8e245d29978/credgem_sdk-0.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-24 10:13:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "CredGem",
"github_project": "CredGem",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "credgem-sdk"
}