branddrive-python-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.
Files changed (62) hide show
  1. branddrive_python_sdk-0.1.0/PKG-INFO +132 -0
  2. branddrive_python_sdk-0.1.0/README.md +112 -0
  3. branddrive_python_sdk-0.1.0/pyproject.toml +40 -0
  4. branddrive_python_sdk-0.1.0/setup.cfg +4 -0
  5. branddrive_python_sdk-0.1.0/src/branddrive/__init__.py +33 -0
  6. branddrive_python_sdk-0.1.0/src/branddrive/client.py +134 -0
  7. branddrive_python_sdk-0.1.0/src/branddrive/config.py +15 -0
  8. branddrive_python_sdk-0.1.0/src/branddrive/dataclasses/__init__.py +118 -0
  9. branddrive_python_sdk-0.1.0/src/branddrive/dataclasses/_utils.py +8 -0
  10. branddrive_python_sdk-0.1.0/src/branddrive/dataclasses/customers.py +66 -0
  11. branddrive_python_sdk-0.1.0/src/branddrive/dataclasses/expenses.py +155 -0
  12. branddrive_python_sdk-0.1.0/src/branddrive/dataclasses/invoices.py +131 -0
  13. branddrive_python_sdk-0.1.0/src/branddrive/dataclasses/payment_links.py +134 -0
  14. branddrive_python_sdk-0.1.0/src/branddrive/dataclasses/pos.py +141 -0
  15. branddrive_python_sdk-0.1.0/src/branddrive/dataclasses/products.py +166 -0
  16. branddrive_python_sdk-0.1.0/src/branddrive/dataclasses/purchase_orders.py +141 -0
  17. branddrive_python_sdk-0.1.0/src/branddrive/dataclasses/services.py +76 -0
  18. branddrive_python_sdk-0.1.0/src/branddrive/dataclasses/vendors.py +48 -0
  19. branddrive_python_sdk-0.1.0/src/branddrive/dataclasses/wallets.py +72 -0
  20. branddrive_python_sdk-0.1.0/src/branddrive/exceptions.py +35 -0
  21. branddrive_python_sdk-0.1.0/src/branddrive/protocols/__init__.py +43 -0
  22. branddrive_python_sdk-0.1.0/src/branddrive/protocols/analytics.py +61 -0
  23. branddrive_python_sdk-0.1.0/src/branddrive/protocols/customers.py +42 -0
  24. branddrive_python_sdk-0.1.0/src/branddrive/protocols/expenses.py +69 -0
  25. branddrive_python_sdk-0.1.0/src/branddrive/protocols/invoices.py +81 -0
  26. branddrive_python_sdk-0.1.0/src/branddrive/protocols/payment_links.py +49 -0
  27. branddrive_python_sdk-0.1.0/src/branddrive/protocols/pos.py +88 -0
  28. branddrive_python_sdk-0.1.0/src/branddrive/protocols/products.py +150 -0
  29. branddrive_python_sdk-0.1.0/src/branddrive/protocols/purchase_orders.py +68 -0
  30. branddrive_python_sdk-0.1.0/src/branddrive/protocols/services.py +56 -0
  31. branddrive_python_sdk-0.1.0/src/branddrive/protocols/vendors.py +39 -0
  32. branddrive_python_sdk-0.1.0/src/branddrive/protocols/wallets.py +52 -0
  33. branddrive_python_sdk-0.1.0/src/branddrive/resources/__init__.py +125 -0
  34. branddrive_python_sdk-0.1.0/src/branddrive/resources/_utils.py +10 -0
  35. branddrive_python_sdk-0.1.0/src/branddrive/resources/analytics.py +198 -0
  36. branddrive_python_sdk-0.1.0/src/branddrive/resources/customers.py +194 -0
  37. branddrive_python_sdk-0.1.0/src/branddrive/resources/expenses.py +209 -0
  38. branddrive_python_sdk-0.1.0/src/branddrive/resources/invoices.py +268 -0
  39. branddrive_python_sdk-0.1.0/src/branddrive/resources/payment_links.py +265 -0
  40. branddrive_python_sdk-0.1.0/src/branddrive/resources/pos.py +353 -0
  41. branddrive_python_sdk-0.1.0/src/branddrive/resources/products.py +612 -0
  42. branddrive_python_sdk-0.1.0/src/branddrive/resources/purchase_orders.py +235 -0
  43. branddrive_python_sdk-0.1.0/src/branddrive/resources/services.py +184 -0
  44. branddrive_python_sdk-0.1.0/src/branddrive/resources/vendors.py +152 -0
  45. branddrive_python_sdk-0.1.0/src/branddrive/resources/wallets.py +204 -0
  46. branddrive_python_sdk-0.1.0/src/branddrive_python_sdk.egg-info/PKG-INFO +132 -0
  47. branddrive_python_sdk-0.1.0/src/branddrive_python_sdk.egg-info/SOURCES.txt +60 -0
  48. branddrive_python_sdk-0.1.0/src/branddrive_python_sdk.egg-info/dependency_links.txt +1 -0
  49. branddrive_python_sdk-0.1.0/src/branddrive_python_sdk.egg-info/requires.txt +6 -0
  50. branddrive_python_sdk-0.1.0/src/branddrive_python_sdk.egg-info/top_level.txt +1 -0
  51. branddrive_python_sdk-0.1.0/tests/test_analytics.py +173 -0
  52. branddrive_python_sdk-0.1.0/tests/test_client.py +58 -0
  53. branddrive_python_sdk-0.1.0/tests/test_customers.py +315 -0
  54. branddrive_python_sdk-0.1.0/tests/test_expenses.py +270 -0
  55. branddrive_python_sdk-0.1.0/tests/test_invoices.py +352 -0
  56. branddrive_python_sdk-0.1.0/tests/test_payment_links.py +244 -0
  57. branddrive_python_sdk-0.1.0/tests/test_pos.py +331 -0
  58. branddrive_python_sdk-0.1.0/tests/test_products.py +344 -0
  59. branddrive_python_sdk-0.1.0/tests/test_purchase_orders.py +296 -0
  60. branddrive_python_sdk-0.1.0/tests/test_services.py +219 -0
  61. branddrive_python_sdk-0.1.0/tests/test_vendors.py +230 -0
  62. branddrive_python_sdk-0.1.0/tests/test_wallets.py +244 -0
@@ -0,0 +1,132 @@
1
+ Metadata-Version: 2.4
2
+ Name: branddrive-python-sdk
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for the BrandDrive API
5
+ Author: Ogenna Israel
6
+ License-Expression: LicenseRef-Proprietary
7
+ Keywords: branddrive,sdk,api,business
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Requires-Python: >=3.12
14
+ Description-Content-Type: text/markdown
15
+ Requires-Dist: httpx>=0.29.0
16
+ Requires-Dist: python-dotenv>=1.0.0
17
+ Provides-Extra: dev
18
+ Requires-Dist: build>=1.2; extra == "dev"
19
+ Requires-Dist: pytest>=9.2.0; extra == "dev"
20
+
21
+ # BrandDrive Python SDK
22
+
23
+ A Python client for BrandDrive business resources, including customers, products,
24
+ invoices, POS, services, vendors, purchase orders, expenses, wallets, payment
25
+ links, and analytics.
26
+
27
+ ## Requirements
28
+
29
+ - Python 3.12 or newer
30
+ - A BrandDrive API key
31
+
32
+ ## Installation
33
+
34
+ Install the package from the repository:
35
+
36
+ ```bash
37
+ python -m pip install .
38
+ ```
39
+
40
+ For local development:
41
+
42
+ ```bash
43
+ python -m pip install -e ".[dev]"
44
+ ```
45
+
46
+ ## Configuration
47
+
48
+ Set credentials in environment variables or pass them directly:
49
+
50
+ ```bash
51
+ BRANDDRIVE_API_KEY=your-api-key
52
+ BRANDDRIVE_BASE_URL=https://api.branddrive.com
53
+ ```
54
+
55
+ Copy `.env.example` to `.env` for local development. `.env` is ignored by Git.
56
+
57
+ ## Quick start
58
+
59
+ ```python
60
+ from branddrive import BrandDriveClient
61
+ from branddrive.dataclasses import CustomerData
62
+
63
+ with BrandDriveClient() as client:
64
+ customer = CustomerData(
65
+ first_name="Amina",
66
+ branch_id=2,
67
+ birth_day=3,
68
+ birth_month=6,
69
+ email="amina@example.com",
70
+ )
71
+ created = client.customers.create_customer(customer)
72
+ print(created)
73
+ ```
74
+
75
+ Credentials can also be supplied explicitly:
76
+
77
+ ```python
78
+ client = BrandDriveClient(
79
+ api_key="your-api-key",
80
+ base_url="https://api.branddrive.com",
81
+ timeout=10,
82
+ max_retries=3,
83
+ )
84
+ ```
85
+
86
+ Always close a client that is not used as a context manager:
87
+
88
+ ```python
89
+ client.close()
90
+ ```
91
+
92
+ ## Resources
93
+
94
+ - `client.customers`
95
+ - `client.invoices`
96
+ - `client.products`
97
+ - `client.pos`
98
+ - `client.services`
99
+ - `client.vendors`
100
+ - `client.purchase_orders`
101
+ - `client.expenses`
102
+ - `client.wallets`
103
+ - `client.payment_links`
104
+ - `client.analytics`
105
+
106
+ Payload dataclasses are available under `branddrive.dataclasses`, for example
107
+ `from branddrive.dataclasses import CustomerData`.
108
+
109
+ ## Error handling
110
+
111
+ ```python
112
+ from branddrive.exceptions import APIException
113
+
114
+ try:
115
+ client.customers.list_cusotmers(limit=10)
116
+ except APIException as exc:
117
+ print(exc.status_code, exc.request_id, exc)
118
+ ```
119
+
120
+ API methods return decoded JSON dictionaries. Export and download methods may
121
+ return `bytes`.
122
+
123
+ ## Development
124
+
125
+ ```bash
126
+ python -m pytest
127
+ python -m build
128
+ ```
129
+
130
+ The build produces an installable wheel and source distribution in `dist/`.
131
+
132
+ See [deployment notes](docs/deployment.md) and [API usage](docs/api.md).
@@ -0,0 +1,112 @@
1
+ # BrandDrive Python SDK
2
+
3
+ A Python client for BrandDrive business resources, including customers, products,
4
+ invoices, POS, services, vendors, purchase orders, expenses, wallets, payment
5
+ links, and analytics.
6
+
7
+ ## Requirements
8
+
9
+ - Python 3.12 or newer
10
+ - A BrandDrive API key
11
+
12
+ ## Installation
13
+
14
+ Install the package from the repository:
15
+
16
+ ```bash
17
+ python -m pip install .
18
+ ```
19
+
20
+ For local development:
21
+
22
+ ```bash
23
+ python -m pip install -e ".[dev]"
24
+ ```
25
+
26
+ ## Configuration
27
+
28
+ Set credentials in environment variables or pass them directly:
29
+
30
+ ```bash
31
+ BRANDDRIVE_API_KEY=your-api-key
32
+ BRANDDRIVE_BASE_URL=https://api.branddrive.com
33
+ ```
34
+
35
+ Copy `.env.example` to `.env` for local development. `.env` is ignored by Git.
36
+
37
+ ## Quick start
38
+
39
+ ```python
40
+ from branddrive import BrandDriveClient
41
+ from branddrive.dataclasses import CustomerData
42
+
43
+ with BrandDriveClient() as client:
44
+ customer = CustomerData(
45
+ first_name="Amina",
46
+ branch_id=2,
47
+ birth_day=3,
48
+ birth_month=6,
49
+ email="amina@example.com",
50
+ )
51
+ created = client.customers.create_customer(customer)
52
+ print(created)
53
+ ```
54
+
55
+ Credentials can also be supplied explicitly:
56
+
57
+ ```python
58
+ client = BrandDriveClient(
59
+ api_key="your-api-key",
60
+ base_url="https://api.branddrive.com",
61
+ timeout=10,
62
+ max_retries=3,
63
+ )
64
+ ```
65
+
66
+ Always close a client that is not used as a context manager:
67
+
68
+ ```python
69
+ client.close()
70
+ ```
71
+
72
+ ## Resources
73
+
74
+ - `client.customers`
75
+ - `client.invoices`
76
+ - `client.products`
77
+ - `client.pos`
78
+ - `client.services`
79
+ - `client.vendors`
80
+ - `client.purchase_orders`
81
+ - `client.expenses`
82
+ - `client.wallets`
83
+ - `client.payment_links`
84
+ - `client.analytics`
85
+
86
+ Payload dataclasses are available under `branddrive.dataclasses`, for example
87
+ `from branddrive.dataclasses import CustomerData`.
88
+
89
+ ## Error handling
90
+
91
+ ```python
92
+ from branddrive.exceptions import APIException
93
+
94
+ try:
95
+ client.customers.list_cusotmers(limit=10)
96
+ except APIException as exc:
97
+ print(exc.status_code, exc.request_id, exc)
98
+ ```
99
+
100
+ API methods return decoded JSON dictionaries. Export and download methods may
101
+ return `bytes`.
102
+
103
+ ## Development
104
+
105
+ ```bash
106
+ python -m pytest
107
+ python -m build
108
+ ```
109
+
110
+ The build produces an installable wheel and source distribution in `dist/`.
111
+
112
+ See [deployment notes](docs/deployment.md) and [API usage](docs/api.md).
@@ -0,0 +1,40 @@
1
+ [project]
2
+ name = "branddrive-python-sdk"
3
+ version = "0.1.0"
4
+ description = "Official Python SDK for the BrandDrive API"
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ license = "LicenseRef-Proprietary"
8
+ authors = [
9
+ { name = "Ogenna Israel" },
10
+ ]
11
+ keywords = ["branddrive", "sdk", "api", "business"]
12
+ classifiers = [
13
+ "Development Status :: 4 - Beta",
14
+ "Intended Audience :: Developers",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.12",
17
+ "Programming Language :: Python :: 3.13",
18
+ ]
19
+ dependencies = [
20
+ "httpx>=0.29.0",
21
+ "python-dotenv>=1.0.0",
22
+ ]
23
+
24
+ [project.optional-dependencies]
25
+ dev = [
26
+ "build>=1.2",
27
+ "pytest>=9.2.0",
28
+ ]
29
+
30
+ [build-system]
31
+ requires = ["setuptools>=68", "wheel"]
32
+ build-backend = "setuptools.build_meta"
33
+
34
+ [tool.setuptools.packages.find]
35
+ where = ["src"]
36
+ include = ["branddrive*"]
37
+
38
+ [tool.pytest.ini_options]
39
+ testpaths = ["tests"]
40
+ addopts = "-ra"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,33 @@
1
+ from typing import TYPE_CHECKING, Any
2
+
3
+ version = '0.1.0'
4
+ if TYPE_CHECKING:
5
+ from .client import BrandDriveClient
6
+ from .exceptions import APIException, InvalidAPIKeyException, InvalidBaseURLException
7
+
8
+ def __getattr__(name: str) -> Any:
9
+ if name == "BrandDriveClient":
10
+ from .client import BrandDriveClient
11
+
12
+ return BrandDriveClient
13
+ if name in {
14
+ "APIException",
15
+ "InvalidAPIKeyException",
16
+ "InvalidBaseURLException",
17
+ }:
18
+ from .exceptions import (
19
+ APIException,
20
+ InvalidAPIKeyException,
21
+ InvalidBaseURLException,
22
+ )
23
+
24
+ return locals()[name]
25
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
26
+
27
+
28
+ __all__ = [
29
+ "BrandDriveClient",
30
+ "APIException",
31
+ "InvalidAPIKeyException",
32
+ "InvalidBaseURLException"
33
+ ]
@@ -0,0 +1,134 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Optional, Any
4
+
5
+ from .config import settings
6
+ from .exceptions import handle_api_exception, InvalidAPIKeyException, InvalidBaseURLException
7
+ from .resources import (
8
+ Customer,
9
+ Expense,
10
+ Invoice,
11
+ Product,
12
+ POS,
13
+ PurchaseOrder,
14
+ Service,
15
+ Vendor,
16
+ Wallet,
17
+ PaymentLink,
18
+ Analytics,
19
+ )
20
+ from .protocols.customers import _CustomerAPI
21
+ from .protocols.invoices import _InvoiceAPI
22
+ from .protocols.products import _ProductAPI
23
+ from .protocols.pos import _POSAPI
24
+ from .protocols.services import _ServiceAPI
25
+ from .protocols.vendors import _VendorAPI
26
+ from .protocols.purchase_orders import _PurchaseOrderAPI
27
+ from .protocols.expenses import _ExpenseAPI
28
+ from .protocols.wallets import _WalletAPI
29
+ from .protocols.payment_links import _PaymentLinkAPI
30
+ from .protocols.analytics import _AnalyticsAPI
31
+
32
+ import httpx
33
+ import time
34
+ import random
35
+
36
+
37
+ class Client:
38
+ def __init__(
39
+ self, api_key: Optional[str],
40
+ base_url: Optional[str],
41
+ timeout: Optional[int] = 30
42
+ ) -> None:
43
+ self.api_key = api_key
44
+ self.base_url = base_url
45
+ self.timeout = timeout
46
+
47
+ if not self.api_key:
48
+ raise InvalidAPIKeyException("API key is required. Please set the BRANDDRIVE_API_KEY environment variable or provide it as an argument.")
49
+
50
+ if not self.base_url:
51
+ raise InvalidBaseURLException("Base URL is required. Please set the BRANDDRIVE_BASE_URL environment variable or provide it as an argument.")
52
+
53
+ def _client(self) -> httpx.Client:
54
+
55
+ """Create an HTTP client with the specified settings."""
56
+
57
+ return httpx.Client(
58
+ base_url=self.base_url,
59
+ headers={
60
+ "Authorization": f"Bearer {self.api_key}",
61
+ "Accept": "application/json",
62
+ },
63
+ timeout=self.timeout,
64
+ limits=httpx.Limits(max_keepalive_connections=5, max_connections=10),
65
+ )
66
+
67
+ def __exit__(self, exc_type, exc, tb):
68
+
69
+ """Close the HTTP client when exiting the context."""
70
+ self._client().close()
71
+
72
+ def close(self) -> None:
73
+ """Close the HTTP client."""
74
+ self._client().close()
75
+
76
+
77
+ class BrandDriveClient:
78
+ """BrandDrive API client."""
79
+
80
+ def __init__(
81
+ self, api_key: str = settings.api_key,
82
+ base_url: str = settings.base_url,
83
+ timeout: int = 10,
84
+ max_retries: int = 3,
85
+ ) -> None:
86
+ client = Client(api_key, base_url, timeout)
87
+
88
+ self._httpx = client._client()
89
+ self._max_retries = max_retries
90
+ self.customers: _CustomerAPI = Customer(self._httpx)
91
+ self.invoices: _InvoiceAPI = Invoice(self._httpx)
92
+ self.products: _ProductAPI = Product(self._httpx)
93
+ self.pos: _POSAPI = POS(self._httpx)
94
+ self.services: _ServiceAPI = Service(self._httpx)
95
+ self.vendors: _VendorAPI = Vendor(self._httpx)
96
+ self.purchase_orders: _PurchaseOrderAPI = PurchaseOrder(self._httpx)
97
+ self.expenses: _ExpenseAPI = Expense(self._httpx)
98
+ self.wallets: _WalletAPI = Wallet(self._httpx)
99
+ self.payment_links: _PaymentLinkAPI = PaymentLink(self._httpx)
100
+ self.analytics: _AnalyticsAPI = Analytics(self._httpx)
101
+
102
+ def __enter__(self) -> "BrandDriveClient":
103
+ return self
104
+
105
+ def __exit__(self, exc_type, exc, tb) -> None:
106
+ self.close()
107
+
108
+ def close(self) -> None:
109
+ """Close the underlying HTTP connection pool."""
110
+ self._httpx.close()
111
+
112
+ def request(self, method: str, path: str, **kwargs) -> Any:
113
+ """Send a request to the BrandDrive API with retry logic."""
114
+
115
+ attempt = 0
116
+ while True:
117
+ delay = 0.5 * 2**attempt + random.uniform(0, 0.25) # Exponential backoff delay
118
+ try:
119
+ response = self._httpx.request(method, path, **kwargs)
120
+ except httpx.TransportError:
121
+ if attempt >= self._max_retries:
122
+ raise
123
+ else:
124
+ status_code = response.status_code
125
+ if response.is_success:
126
+ return response.json()
127
+
128
+ retryable = status_code == 500 # Retry server error, return client error back to the user
129
+ if not retryable or attempt >= self._max_retries:
130
+ return handle_api_exception(response)
131
+
132
+ time.sleep(delay)
133
+ attempt += 1
134
+
@@ -0,0 +1,15 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ from dotenv import load_dotenv
5
+
6
+ load_dotenv()
7
+
8
+ class Settings:
9
+ """Settings for BrandDrive SDK."""
10
+
11
+ def __init__(self) -> None:
12
+ self.api_key = os.environ.get("BRANDDRIVE_API_KEY", "")
13
+ self.base_url = os.environ.get("BRANDDRIVE_BASE_URL", "https://api.branddrive.com")
14
+
15
+ settings = Settings()
@@ -0,0 +1,118 @@
1
+ from .customers import CustomerData, UpdateCustomerData
2
+ from .pos import (
3
+ POSCreate,
4
+ POSPaymentProcurement,
5
+ POSProcurement,
6
+ POSProcurementUpdate,
7
+ POSProductProcurement,
8
+ POSVoidData,
9
+ PosUpdate,
10
+ )
11
+ from .invoices import (
12
+ InvoiceCreate,
13
+ InvoiceCreateSend,
14
+ InvoiceUpdate,
15
+ RecurringScheduleCreate,
16
+ RecurringScheduleUpdate,
17
+ )
18
+ from .products import (
19
+ ProcurementData,
20
+ ProductDistributionCreate,
21
+ ProductDistributionUpdate,
22
+ SingleProductCreate,
23
+ UpdateProductData,
24
+ UpdateProcurementData,
25
+ ProductVariationCreate
26
+ )
27
+
28
+ from .services import (
29
+ ServiceCategoryCreate,
30
+ ServiceCategoryUpdate,
31
+ ServiceCreate,
32
+ UpdateServiceData,
33
+ )
34
+ from .vendors import VendorData, UpdateVendorData
35
+ from .purchase_orders import (
36
+ PurchaseOrderCreate,
37
+ PurchaseOrderPaymentCreate,
38
+ PurchaseOrderPaymentMethod,
39
+ PurchaseOrderProcurementCreate,
40
+ PurchaseOrderProduct,
41
+ PurchaseOrderUpdate,
42
+ )
43
+
44
+ from .expenses import (
45
+ ExpenseCreate,
46
+ ExpenseLineItem,
47
+ ExpensePaymentCreate,
48
+ ExpensePaymentMethod,
49
+ ExpenseProcurementCreate,
50
+ ExpenseProcurementUpdate,
51
+ ExpenseUpdate,
52
+ )
53
+ from .wallets import (
54
+ WalletBusinessTransferData,
55
+ WalletExternalTransferData,
56
+ WalletFundData,
57
+ WalletPersonalTransferData,
58
+ )
59
+ from .payment_links import (
60
+ PaymentLinkCategoryCreate,
61
+ PaymentLinkCategoryData,
62
+ PaymentLinkCreate,
63
+ PaymentLinkPayData,
64
+ PaymentLinkSubscriptionDuration,
65
+ PaymentLinkUpdate,
66
+ )
67
+ __all__ = [
68
+ "CustomerData",
69
+ "UpdateCustomerData",
70
+ "POSCreate",
71
+ "POSPaymentProcurement",
72
+ "POSProcurement",
73
+ "POSProcurementUpdate",
74
+ "POSProductProcurement",
75
+ "POSVoidData",
76
+ "PosUpdate",
77
+ "InvoiceCreate",
78
+ "InvoiceCreateSend",
79
+ "InvoiceUpdate",
80
+ "RecurringScheduleCreate",
81
+ "RecurringScheduleUpdate",
82
+ "ProcurementData",
83
+ "UpdateProcurementData",
84
+ "ProductDistributionCreate",
85
+ "ProductDistributionUpdate",
86
+ "SingleProductCreate",
87
+ "UpdateProductData",
88
+ 'ProductVariationCreate',
89
+ "ServiceCategoryCreate",
90
+ "ServiceCategoryUpdate",
91
+ "ServiceCreate",
92
+ "UpdateServiceData",
93
+ "VendorData",
94
+ "UpdateVendorData",
95
+ "PurchaseOrderCreate",
96
+ "PurchaseOrderUpdate",
97
+ "PurchaseOrderProduct",
98
+ "PurchaseOrderProcurementCreate",
99
+ "PurchaseOrderPaymentCreate",
100
+ "PurchaseOrderPaymentMethod",
101
+ "ExpenseProcurementCreate",
102
+ "ExpenseProcurementUpdate",
103
+ "ExpenseCreate",
104
+ "ExpenseUpdate",
105
+ "ExpenseLineItem",
106
+ "ExpensePaymentCreate",
107
+ "ExpensePaymentMethod",
108
+ "WalletFundData",
109
+ "WalletBusinessTransferData",
110
+ "WalletPersonalTransferData",
111
+ "WalletExternalTransferData",
112
+ "PaymentLinkCategoryCreate",
113
+ "PaymentLinkCategoryData",
114
+ "PaymentLinkCreate",
115
+ "PaymentLinkPayData",
116
+ "PaymentLinkSubscriptionDuration",
117
+ "PaymentLinkUpdate",
118
+ ]
@@ -0,0 +1,8 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+
5
+
6
+ def omit_none(payload: dict[str, Any]) -> dict[str, Any]:
7
+ """Return a payload without fields whose value is ``None``."""
8
+ return {key: value for key, value in payload.items() if value is not None}
@@ -0,0 +1,66 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Any, Optional
5
+
6
+ from ._utils import omit_none
7
+
8
+
9
+ @dataclass
10
+ class CustomerData:
11
+ """Fields used to create a customer."""
12
+
13
+ first_name: str
14
+ branch_id: int
15
+ birth_day: int
16
+ birth_month: int
17
+ last_name: Optional[str] = None
18
+ company_name: Optional[str] = None
19
+ email: Optional[str] = None
20
+ phone: Optional[str] = None
21
+ address: Optional[str] = None
22
+ country_code: Optional[str] = None
23
+ state_code: Optional[str] = None
24
+ city_id: Optional[int] = None
25
+
26
+ def to_dict(self) -> dict[str, Any]:
27
+ return omit_none({
28
+ "firstname": self.first_name,
29
+ "lastname": self.last_name,
30
+ "company": self.company_name,
31
+ "email": self.email,
32
+ "phone": self.phone,
33
+ "address": self.address,
34
+ "countryCode": self.country_code,
35
+ "stateCode": self.state_code,
36
+ "cityId": self.city_id,
37
+ "branchId": self.branch_id,
38
+ "birthDay": self.birth_day,
39
+ "birthMonth": self.birth_month,
40
+ })
41
+
42
+
43
+ @dataclass
44
+ class UpdateCustomerData:
45
+ """Fields used to update a customer's record."""
46
+
47
+ firstname: Optional[str] = None
48
+ lastname: Optional[str] = None
49
+ birth_day: Optional[int] = None
50
+ birth_month: Optional[int] = None
51
+ company_name: Optional[str] = None
52
+ email: Optional[str] = None
53
+ phone: Optional[str] = None
54
+ address: Optional[str] = None
55
+
56
+ def to_dict(self) -> dict[str, Any]:
57
+ return omit_none({
58
+ "firstname": self.firstname,
59
+ "lastname": self.lastname,
60
+ "birthDay": self.birth_day,
61
+ "birthMonth": self.birth_month,
62
+ "email": self.email,
63
+ "company": self.company_name,
64
+ "phoneNumber": self.phone,
65
+ "address": self.address,
66
+ })