Skip to main content

Python SDK for CredGem API - A powerful credit management system

Project description

CredGem Python SDK

A Python SDK for interacting with the CredGem API.

Installation

pip install credgem-sdk

Configuration

The SDK can be configured to work with different environments:

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

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:

# 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

credgem_sdk-0.1.1.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

credgem_sdk-0.1.1-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file credgem_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: credgem_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Darwin/23.6.0

File hashes

Hashes for credgem_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c474e47165d03ca97cb069a54b9eba2dd9b7108faa04a3ad08f78ce8c14470f9
MD5 9fa14ee5a6077e78c36f5164670f0926
BLAKE2b-256 922ce237d07441df4e69080bd22ea2ce7638bffb21d4271e9f5d3dbf27d8d384

See more details on using hashes here.

File details

Details for the file credgem_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: credgem_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Darwin/23.6.0

File hashes

Hashes for credgem_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fe14b79b5a296e67609e2a02c016aebbfed454d0f399c6a409120eba050c6e49
MD5 e216f6f2a32714cd86d2a3bf4a1ed3a4
BLAKE2b-256 d8482c9125128db0c30eba96d5e2e895b2f55a69c63ee827eaf12487e26a5d98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page