qbitflow 1.0.0__py3-none-any.whl

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.
Files changed (39) hide show
  1. qbitflow/__init__.py +37 -0
  2. qbitflow/client.py +118 -0
  3. qbitflow/config.py +55 -0
  4. qbitflow/dto/__init__.py +32 -0
  5. qbitflow/dto/api_key.py +91 -0
  6. qbitflow/dto/base_model.py +44 -0
  7. qbitflow/dto/customer.py +106 -0
  8. qbitflow/dto/product.py +108 -0
  9. qbitflow/dto/transaction/__init__.py +50 -0
  10. qbitflow/dto/transaction/currency.py +44 -0
  11. qbitflow/dto/transaction/payment.py +81 -0
  12. qbitflow/dto/transaction/session.py +240 -0
  13. qbitflow/dto/transaction/status.py +122 -0
  14. qbitflow/dto/transaction/subscription.py +159 -0
  15. qbitflow/dto/user.py +123 -0
  16. qbitflow/exceptions/__init__.py +29 -0
  17. qbitflow/exceptions/exceptions.py +160 -0
  18. qbitflow/py.typed +0 -0
  19. qbitflow/requests/__init__.py +23 -0
  20. qbitflow/requests/api_key.py +49 -0
  21. qbitflow/requests/base_request.py +257 -0
  22. qbitflow/requests/customer.py +199 -0
  23. qbitflow/requests/product.py +63 -0
  24. qbitflow/requests/transaction/__init__.py +19 -0
  25. qbitflow/requests/transaction/payg.py +156 -0
  26. qbitflow/requests/transaction/payment.py +182 -0
  27. qbitflow/requests/transaction/session.py +28 -0
  28. qbitflow/requests/transaction/status.py +41 -0
  29. qbitflow/requests/transaction/subscription.py +133 -0
  30. qbitflow/requests/user.py +56 -0
  31. qbitflow/utils/__init__.py +11 -0
  32. qbitflow/utils/cursor_data.py +93 -0
  33. qbitflow/utils/duration.py +74 -0
  34. qbitflow/utils/helpers.py +137 -0
  35. qbitflow-1.0.0.dist-info/METADATA +683 -0
  36. qbitflow-1.0.0.dist-info/RECORD +39 -0
  37. qbitflow-1.0.0.dist-info/WHEEL +5 -0
  38. qbitflow-1.0.0.dist-info/licenses/LICENSE +242 -0
  39. qbitflow-1.0.0.dist-info/top_level.txt +1 -0
qbitflow/__init__.py ADDED
@@ -0,0 +1,37 @@
1
+
2
+ """
3
+ QBitFlow Python SDK
4
+ ===================
5
+
6
+ A Python SDK for QBitFlow - Next Generation Crypto Payment Processing.
7
+
8
+ This SDK provides a simple and intuitive interface for:
9
+ - Processing one-time cryptocurrency payments
10
+ - Managing recurring subscriptions
11
+ - Handling pay-as-you-go subscriptions
12
+ - Managing customers and products
13
+ - Tracking transaction statuses
14
+
15
+ Basic Usage
16
+ -----------
17
+ >>> from qbitflow import QBitFlow
18
+ >>> client = QBitFlow(api_key="your_api_key_here")
19
+ >>>
20
+ >>> # Create a one-time payment session
21
+ >>> response = client.one_time_payments.create_session(
22
+ ... product_id=1,
23
+ ... customer_uuid="customer-uuid-here"
24
+ ... )
25
+ >>> print(response.link) # Send this link to your customer
26
+
27
+ For more examples, see the documentation at https://qbitflow.app/docs
28
+ """
29
+
30
+ from .client import QBitFlow
31
+ from . import dto
32
+ from . import exceptions
33
+ from .utils.duration import Duration
34
+
35
+ __version__ = "1.0.0"
36
+ __author__ = "QBitFlow"
37
+ __all__ = ["QBitFlow", "dto", "exceptions", "Duration"]
qbitflow/client.py ADDED
@@ -0,0 +1,118 @@
1
+ """
2
+ QBitFlow SDK main client.
3
+
4
+ This module provides the main QBitFlow client class for interacting with the API.
5
+ """
6
+
7
+ from typing import Optional
8
+
9
+ from .requests.customer import CustomerRequests
10
+ from .requests.product import ProductRequests
11
+ from .requests.user import UserRequests
12
+ from .requests.api_key import ApiKeyRequests
13
+ from .requests.transaction.payment import PaymentRequests
14
+ from .requests.transaction.subscription import SubscriptionRequests
15
+ from .requests.transaction.payg import PayAsYouGoSubscriptionRequests
16
+ from .requests.transaction.status import TransactionStatusRequests
17
+
18
+
19
+ class QBitFlow:
20
+ """
21
+ Main client for interacting with the QBitFlow API.
22
+
23
+ This class provides access to all QBitFlow API functionality through
24
+ organized request handlers for different resource types.
25
+
26
+ Attributes:
27
+ api_key: API key used for authentication.
28
+ customers: Handler for customer-related operations.
29
+ products: Handler for product-related operations.
30
+ users: Handler for user-related operations.
31
+ api_keys: Handler for API key management.
32
+ transaction_status: Handler for checking transaction statuses.
33
+ one_time_payments: Handler for one-time payment operations.
34
+ subscriptions: Handler for recurring subscription operations.
35
+ pay_as_you_go: Handler for pay-as-you-go subscription operations.
36
+
37
+ Example:
38
+ >>> from qbitflow import QBitFlow
39
+ >>>
40
+ >>> # Initialize the client
41
+ >>> client = QBitFlow(api_key="your_api_key_here")
42
+ >>>
43
+ >>> # Create a one-time payment
44
+ >>> response = client.one_time_payments.create_session(
45
+ ... product_id=1,
46
+ ... customer_uuid="customer-uuid",
47
+ ... webhook_url="https://example.com/webhook"
48
+ ... )
49
+ >>> print(f"Payment link: {response.link}")
50
+ >>>
51
+ >>> # Create a subscription
52
+ >>> from qbitflow import Duration
53
+ >>> response = client.subscriptions.create_session(
54
+ ... product_id=1,
55
+ ... frequency=Duration(value=1, unit="months"),
56
+ ... customer_uuid="customer-uuid"
57
+ ... )
58
+ >>> print(f"Subscription link: {response.link}")
59
+ >>>
60
+ >>> # Check transaction status
61
+ >>> from qbitflow.dto.transaction.status import TransactionType
62
+ >>> status = client.transaction_status.get(
63
+ ... "transaction-uuid",
64
+ ... TransactionType.ONE_TIME_PAYMENT
65
+ ... )
66
+ >>> print(f"Status: {status.status.value}")
67
+ """
68
+
69
+ def __init__(
70
+ self,
71
+ api_key: str,
72
+ timeout: Optional[int] = None,
73
+ max_retries: Optional[int] = None
74
+ ):
75
+ """
76
+ Initialize the QBitFlow client.
77
+
78
+ Args:
79
+ api_key: Your QBitFlow API key. Get this from your dashboard.
80
+ timeout: Optional request timeout in seconds (default: 30).
81
+ max_retries: Optional maximum retry attempts (default: 3).
82
+
83
+ Raises:
84
+ ValueError: If api_key is empty or None.
85
+
86
+ Example:
87
+ >>> # Basic initialization
88
+ >>> client = QBitFlow(api_key="your_api_key_here")
89
+ >>>
90
+ >>> # With custom timeout and retries
91
+ >>> client = QBitFlow(
92
+ ... api_key="your_api_key_here",
93
+ ... timeout=60,
94
+ ... max_retries=5
95
+ ... )
96
+ """
97
+ if not api_key:
98
+ raise ValueError("API key is required")
99
+
100
+ self.api_key = api_key
101
+ self._timeout = timeout
102
+ self._max_retries = max_retries
103
+
104
+ # Initialize request handlers
105
+ self.customers = CustomerRequests(api_key, timeout, max_retries)
106
+ self.products = ProductRequests(api_key, timeout, max_retries)
107
+ self.users = UserRequests(api_key, timeout, max_retries)
108
+ self.api_keys = ApiKeyRequests(api_key, timeout, max_retries)
109
+
110
+ # Transaction-related handlers
111
+ self.transaction_status = TransactionStatusRequests(api_key, timeout, max_retries)
112
+ self.one_time_payments = PaymentRequests(api_key, timeout, max_retries)
113
+ self.subscriptions = SubscriptionRequests(api_key, timeout, max_retries)
114
+ self.pay_as_you_go = PayAsYouGoSubscriptionRequests(api_key, timeout, max_retries)
115
+
116
+ def __repr__(self) -> str:
117
+ """Return a string representation of the client."""
118
+ return f"QBitFlow(api_key='***{self.api_key[-4:]}')"
qbitflow/config.py ADDED
@@ -0,0 +1,55 @@
1
+
2
+ """
3
+ Configuration module for QBitFlow SDK.
4
+
5
+ This module contains configuration settings for the SDK including API base URLs
6
+ and other global settings.
7
+ """
8
+
9
+ from typing import Optional
10
+ import os
11
+
12
+ # Default base URL for QBitFlow API
13
+ # Can be overridden by setting QBITFLOW_BASE_URL environment variable
14
+ BASE_URL: str = os.getenv("QBITFLOW_BASE_URL", "https://api.qbitflow.app/v1")
15
+
16
+ # API version
17
+ API_VERSION: str = "v1"
18
+
19
+ # Request timeout in seconds
20
+ DEFAULT_TIMEOUT: int = 30
21
+
22
+ # Maximum retry attempts for failed requests
23
+ MAX_RETRIES: int = 3
24
+
25
+
26
+ def set_base_url(url: str) -> None:
27
+ """
28
+ Set the base URL for API requests.
29
+
30
+ This is useful for testing or when using a different API endpoint.
31
+
32
+ Args:
33
+ url: The base URL to use for all API requests.
34
+
35
+ Example:
36
+ >>> from qbitflow import config
37
+ >>> config.set_base_url("http://localhost:3001")
38
+ """
39
+ global BASE_URL
40
+ BASE_URL = url
41
+
42
+
43
+ def get_base_url() -> str:
44
+ """
45
+ Get the current base URL for API requests.
46
+
47
+ Returns:
48
+ The current base URL.
49
+
50
+ Example:
51
+ >>> from qbitflow import config
52
+ >>> print(config.get_base_url())
53
+ https://api.qbitflow.app
54
+ """
55
+ return BASE_URL
@@ -0,0 +1,32 @@
1
+
2
+ """
3
+ Data Transfer Objects (DTOs) for QBitFlow SDK.
4
+
5
+ This package contains all the data models used throughout the SDK for
6
+ representing API requests and responses.
7
+ """
8
+
9
+ from .base_model import BaseModel
10
+ from . import transaction
11
+ from .customer import Customer, CreateCustomerDto, UpdateCustomerDto
12
+ from .product import Product, CreateProductDto, UpdateProductDto
13
+ from .user import User, UserRole, CreateUserDto, UpdateUserDto
14
+ from .api_key import ApiKey, CreateApiKeyDto, CreatedKeyResponse
15
+
16
+ __all__ = [
17
+ "BaseModel",
18
+ "transaction",
19
+ "Customer",
20
+ "CreateCustomerDto",
21
+ "UpdateCustomerDto",
22
+ "Product",
23
+ "CreateProductDto",
24
+ "UpdateProductDto",
25
+ "User",
26
+ "UserRole",
27
+ "CreateUserDto",
28
+ "UpdateUserDto",
29
+ "ApiKey",
30
+ "CreateApiKeyDto",
31
+ "CreatedKeyResponse",
32
+ ]
@@ -0,0 +1,91 @@
1
+
2
+ """
3
+ API key-related data models.
4
+
5
+ This module contains data models for API key management operations.
6
+ """
7
+
8
+ from datetime import datetime
9
+ from typing import Optional
10
+ from pydantic import Field
11
+
12
+ from .base_model import BaseModel
13
+ from .user import UserRole
14
+
15
+
16
+ class ApiKey(BaseModel):
17
+ """
18
+ Represents an API key in the QBitFlow system.
19
+
20
+ API keys are used to authenticate requests to the QBitFlow API.
21
+
22
+ Attributes:
23
+ id: Unique identifier for the API key.
24
+ name: Descriptive name for the API key.
25
+ organization_id: ID of the organization this key belongs to.
26
+ user_id: ID of the user who created this key.
27
+ created_at: Timestamp when the key was created.
28
+ expires_at: Optional expiration timestamp.
29
+ role: Role associated with this API key.
30
+ test: Whether this is a test mode API key.
31
+
32
+ Example:
33
+ >>> api_key = client.api_keys.get(1)
34
+ >>> print(f"{api_key.name} - Test: {api_key.test}")
35
+ """
36
+
37
+ id: int = Field(..., description="Unique identifier for the API key")
38
+ name: str = Field(..., description="Descriptive name for the API key")
39
+ organization_id: int = Field(..., description="Organization ID")
40
+ user_id: int = Field(..., description="User ID who created the key")
41
+ created_at: datetime = Field(..., description="Creation timestamp")
42
+ expires_at: Optional[datetime] = Field(default=None, description="Expiration timestamp")
43
+ role: UserRole = Field(..., description="Role associated with the key")
44
+ test: bool = Field(..., description="Whether this is a test mode key")
45
+
46
+
47
+ class CreateApiKeyDto(BaseModel):
48
+ """
49
+ Data transfer object for creating a new API key.
50
+
51
+ Attributes:
52
+ name: Descriptive name for the API key (required).
53
+ user_id: ID of the user creating the key (required).
54
+ expires_at: Optional expiration timestamp.
55
+ role: Role to associate with the key (required).
56
+ test: Whether this should be a test mode key (required).
57
+
58
+ Example:
59
+ >>> new_key = CreateApiKeyDto(
60
+ ... name="Production API Key",
61
+ ... user_id=1,
62
+ ... role=UserRole.ADMIN,
63
+ ... test=False
64
+ ... )
65
+ >>> api_key = client.api_keys.create(new_key)
66
+ """
67
+
68
+ name: str = Field(..., min_length=1, description="Descriptive name for the API key")
69
+ user_id: int = Field(..., gt=0, description="User ID creating the key")
70
+ expires_at: Optional[datetime] = Field(default=None, description="Expiration timestamp")
71
+ test: bool = Field(..., description="Whether this is a test mode key")
72
+
73
+
74
+ class CreatedKeyResponse(BaseModel):
75
+ """
76
+ Response when a new API key is created.
77
+
78
+ This contains the actual API key value which is only shown once during creation.
79
+
80
+ Attributes:
81
+ data: The created API key information.
82
+ key: The actual API key value (only shown once).
83
+
84
+ Example:
85
+ >>> response = client.api_keys.create(new_key_dto)
86
+ >>> print(f"Save this key: {response.key}")
87
+ >>> print(f"Key ID: {response.data.id}")
88
+ """
89
+
90
+ data: ApiKey = Field(..., description="Created API key information")
91
+ key: str = Field(..., description="The actual API key value (only shown once)")
@@ -0,0 +1,44 @@
1
+
2
+ """
3
+ Base model for all DTOs in QBitFlow SDK.
4
+
5
+ This module provides a base Pydantic model with common configuration
6
+ for automatic camelCase/snake_case conversion.
7
+ """
8
+
9
+ from pydantic import BaseModel as PydanticBaseModel, ConfigDict
10
+ from qbitflow.utils.helpers import snake_to_camel_case
11
+
12
+
13
+ class BaseModel(PydanticBaseModel):
14
+ """
15
+ Base model with common configuration for all DTOs.
16
+
17
+ This model automatically handles conversion between Python's snake_case
18
+ convention and the API's camelCase convention.
19
+
20
+ Features:
21
+ - Automatic camelCase to snake_case conversion for incoming data
22
+ - Automatic snake_case to camelCase conversion for outgoing data
23
+ - Support for both naming conventions when loading data
24
+ """
25
+
26
+ model_config = ConfigDict(
27
+ populate_by_name=True, # Allow both camelCase and snake_case
28
+ alias_generator=snake_to_camel_case, # Generate camelCase aliases
29
+ use_enum_values=True, # Use enum values instead of enum objects
30
+ )
31
+
32
+ def model_dump(self, *args, **kwargs):
33
+ """
34
+ Serialize the model to a dictionary with camelCase keys.
35
+
36
+ Args:
37
+ *args: Positional arguments to pass to parent method.
38
+ **kwargs: Keyword arguments to pass to parent method.
39
+
40
+ Returns:
41
+ Dictionary representation of the model with camelCase keys.
42
+ """
43
+ kwargs['by_alias'] = True
44
+ return super().model_dump(*args, **kwargs)
@@ -0,0 +1,106 @@
1
+
2
+ """
3
+ Customer-related data models.
4
+
5
+ This module contains data models for customer management operations.
6
+ """
7
+
8
+ from datetime import datetime
9
+ from typing import Optional
10
+ from pydantic import Field, EmailStr
11
+
12
+ from .base_model import BaseModel
13
+
14
+
15
+ class Customer(BaseModel):
16
+ """
17
+ Represents a customer in the QBitFlow system.
18
+
19
+ Customers are individuals or entities that make payments through your platform.
20
+ Each customer has a unique UUID and contact information.
21
+
22
+ Attributes:
23
+ uuid: Unique identifier for the customer.
24
+ name: Customer's first name.
25
+ last_name: Customer's last name.
26
+ email: Customer's email address.
27
+ phone_number: Optional phone number.
28
+ address: Optional physical address.
29
+ reference: Optional external reference ID for your records.
30
+ created_at: Timestamp when the customer was created.
31
+
32
+ Example:
33
+ >>> customer = client.customers.get("customer-uuid")
34
+ >>> print(f"{customer.name} {customer.last_name}")
35
+ >>> print(f"Email: {customer.email}")
36
+ """
37
+
38
+ uuid: str = Field(..., description="Unique identifier for the customer")
39
+ name: str = Field(..., description="Customer's first name")
40
+ last_name: str = Field(..., description="Customer's last name")
41
+ email: EmailStr = Field(..., description="Customer's email address")
42
+ phone_number: Optional[str] = Field(default=None, description="Customer's phone number")
43
+ address: Optional[str] = Field(default=None, description="Customer's physical address")
44
+ reference: Optional[str] = Field(default=None, description="External reference ID")
45
+ created_at: datetime = Field(..., description="Creation timestamp")
46
+
47
+
48
+ class CreateCustomerDto(BaseModel):
49
+ """
50
+ Data transfer object for creating a new customer.
51
+
52
+ Use this model to provide customer information when creating a new customer.
53
+
54
+ Attributes:
55
+ name: Customer's first name (required).
56
+ last_name: Customer's last name (required).
57
+ email: Customer's email address (required).
58
+ phone_number: Optional phone number.
59
+ address: Optional physical address.
60
+ reference: Optional external reference ID for your records.
61
+
62
+ Example:
63
+ >>> new_customer = CreateCustomerDto(
64
+ ... name="John",
65
+ ... last_name="Doe",
66
+ ... email="john@example.com",
67
+ ... phone_number="+1234567890",
68
+ ... reference="CRM-12345"
69
+ ... )
70
+ >>> customer = client.customers.create(new_customer)
71
+ """
72
+
73
+ name: str = Field(..., min_length=1, description="Customer's first name")
74
+ last_name: str = Field(..., min_length=1, description="Customer's last name")
75
+ email: EmailStr = Field(..., description="Customer's email address")
76
+ phone_number: Optional[str] = Field(default=None, description="Customer's phone number")
77
+ address: Optional[str] = Field(default=None, description="Customer's physical address")
78
+ reference: Optional[str] = Field(default=None, description="External reference ID")
79
+
80
+
81
+ class UpdateCustomerDto(BaseModel):
82
+ """
83
+ Data transfer object for updating an existing customer.
84
+
85
+ All fields are optional - only provide the fields you want to update.
86
+
87
+ Attributes:
88
+ name: New first name.
89
+ last_name: New last name.
90
+ email: New email address.
91
+ phone_number: New phone number.
92
+ address: New physical address.
93
+
94
+ Example:
95
+ >>> update_data = UpdateCustomerDto(
96
+ ... email="newemail@example.com",
97
+ ... phone_number="+9876543210"
98
+ ... )
99
+ >>> customer = client.customers.update("customer-uuid", update_data)
100
+ """
101
+
102
+ name: Optional[str] = Field(..., min_length=1, description="Customer's first name")
103
+ last_name: Optional[str] = Field(..., min_length=1, description="Customer's last name")
104
+ email: Optional[EmailStr] = Field(..., description="Customer's email address")
105
+ phone_number: Optional[str] = Field(default=None, description="Customer's phone number")
106
+ address: Optional[str] = Field(default=None, description="Customer's physical address")
@@ -0,0 +1,108 @@
1
+
2
+ """
3
+ Product-related data models.
4
+
5
+ This module contains data models for product management operations.
6
+ """
7
+
8
+ from datetime import datetime
9
+ from typing import Optional
10
+ from pydantic import Field, field_validator
11
+
12
+ from .base_model import BaseModel
13
+
14
+
15
+ class Product(BaseModel):
16
+ """
17
+ Represents a product in the QBitFlow system.
18
+
19
+ Products are items or services that customers can purchase through
20
+ one-time payments or subscriptions.
21
+
22
+ Attributes:
23
+ id: Unique identifier for the product.
24
+ name: Product name.
25
+ description: Product description.
26
+ price: Price in USD.
27
+ reference: Optional external reference ID for your records.
28
+ created_at: Timestamp when the product was created.
29
+ is_active: Whether the product is currently active.
30
+
31
+ Example:
32
+ >>> product = client.products.get(1)
33
+ >>> print(f"{product.name}: ${product.price}")
34
+ >>> print(f"Active: {product.is_active}")
35
+ """
36
+
37
+ id: int = Field(..., description="Unique identifier for the product")
38
+ name: str = Field(..., description="Product name")
39
+ description: str = Field(..., description="Product description")
40
+ price: float = Field(..., ge=0, description="Price in USD")
41
+ reference: Optional[str] = Field(default=None, description="External reference ID")
42
+ created_at: datetime = Field(..., description="Creation timestamp")
43
+ is_active: bool = Field(..., description="Whether the product is active")
44
+
45
+
46
+ class CreateProductDto(BaseModel):
47
+ """
48
+ Data transfer object for creating a new product.
49
+
50
+ Attributes:
51
+ name: Product name (required).
52
+ description: Product description (required).
53
+ price: Price in USD (required, must be non-negative).
54
+ reference: Optional external reference ID for your records.
55
+
56
+ Example:
57
+ >>> new_product = CreateProductDto(
58
+ ... name="Premium Subscription",
59
+ ... description="Access to all premium features",
60
+ ... price=29.99,
61
+ ... reference="PROD-PREMIUM"
62
+ ... )
63
+ >>> product = client.products.create(new_product)
64
+ """
65
+
66
+ name: str = Field(..., min_length=1, description="Product name")
67
+ description: str = Field(..., min_length=1, description="Product description")
68
+ price: float = Field(..., ge=0, description="Price in USD")
69
+ reference: Optional[str] = Field(default=None, description="External reference ID")
70
+
71
+ @field_validator('price')
72
+ @classmethod
73
+ def validate_price(cls, v: float) -> float:
74
+ """Validate that price is non-negative."""
75
+ if v < 0:
76
+ raise ValueError("Price must be non-negative")
77
+ return v
78
+
79
+
80
+ class UpdateProductDto(BaseModel):
81
+ """
82
+ Data transfer object for updating an existing product.
83
+
84
+ Attributes:
85
+ name: New product name (required).
86
+ description: New product description (required).
87
+ price: New price in USD (required, must be non-negative).
88
+
89
+ Example:
90
+ >>> update_data = UpdateProductDto(
91
+ ... name="Premium Plus Subscription",
92
+ ... description="Updated description",
93
+ ... price=39.99
94
+ ... )
95
+ >>> product = client.products.update(1, update_data)
96
+ """
97
+
98
+ name: str = Field(..., min_length=1, description="Product name")
99
+ description: str = Field(..., min_length=1, description="Product description")
100
+ price: float = Field(..., ge=0, description="Price in USD")
101
+
102
+ @field_validator('price')
103
+ @classmethod
104
+ def validate_price(cls, v: float) -> float:
105
+ """Validate that price is non-negative."""
106
+ if v < 0:
107
+ raise ValueError("Price must be non-negative")
108
+ return v
@@ -0,0 +1,50 @@
1
+
2
+ """
3
+ Transaction-related data models.
4
+
5
+ This package contains data models for payment transactions, subscriptions,
6
+ and related operations.
7
+ """
8
+
9
+ from .currency import Currency
10
+ from .payment import Payment, CombinedPayment
11
+ from .session import (
12
+ Session,
13
+ SubscriptionOptions,
14
+ CreateSessionDto,
15
+ CreateSubscriptionOptions,
16
+ LinkResponse,
17
+ StatusLinkResponse,
18
+ SessionWebhookResponse,
19
+ )
20
+ from .status import (
21
+ TransactionType,
22
+ TransactionStatusValue,
23
+ TransactionStatus,
24
+ StatusResponseError,
25
+ )
26
+ from .subscription import (
27
+ Subscription,
28
+ SubscriptionStatus,
29
+ PayAsYouGoSubscription,
30
+ )
31
+
32
+ __all__ = [
33
+ "Currency",
34
+ "Payment",
35
+ "CombinedPayment",
36
+ "Session",
37
+ "SubscriptionOptions",
38
+ "CreateSessionDto",
39
+ "CreateSubscriptionOptions",
40
+ "LinkResponse",
41
+ "StatusLinkResponse",
42
+ "SessionWebhookResponse",
43
+ "TransactionType",
44
+ "TransactionStatusValue",
45
+ "TransactionStatus",
46
+ "StatusResponseError",
47
+ "Subscription",
48
+ "SubscriptionStatus",
49
+ "PayAsYouGoSubscription",
50
+ ]
@@ -0,0 +1,44 @@
1
+
2
+ """
3
+ Currency-related data models.
4
+
5
+ This module contains data models for cryptocurrency information.
6
+ """
7
+
8
+ from typing import Optional
9
+ from pydantic import Field
10
+
11
+ from qbitflow.dto.base_model import BaseModel
12
+
13
+
14
+ class Currency(BaseModel):
15
+ """
16
+ Represents a cryptocurrency that can be used for payments.
17
+
18
+ Currencies define the supported cryptocurrencies that customers can use
19
+ to complete payments.
20
+
21
+ Attributes:
22
+ id: Unique identifier for the currency.
23
+ name: Currency name (e.g., "Bitcoin", "Ethereum").
24
+ symbol: Currency symbol (e.g., "BTC", "ETH").
25
+ decimals: Number of decimal places for this currency.
26
+ address: Smart contract address or blockchain identifier.
27
+ main_currency_id: ID of the main currency if this is a variant.
28
+ main_currency: Reference to the main currency object if applicable.
29
+ test: Whether this is a test mode currency.
30
+
31
+ Example:
32
+ >>> session = client.one_time_payments.get_session("session-uuid")
33
+ >>> for currency in session.available_currencies:
34
+ ... print(f"{currency.name} ({currency.symbol})")
35
+ """
36
+
37
+ id: int = Field(..., description="Unique identifier for the currency")
38
+ name: str = Field(..., description="Currency name")
39
+ symbol: str = Field(..., description="Currency symbol")
40
+ decimals: int = Field(..., ge=0, description="Number of decimal places")
41
+ address: str = Field(..., description="Smart contract address or blockchain identifier")
42
+ main_currency_id: Optional[int] = Field(default=None, description="ID of main currency if variant")
43
+ main_currency: Optional["Currency"] = Field(default=None, description="Main currency reference")
44
+ test: bool = Field(..., description="Whether this is a test mode currency")