paddle-python-sdk 0.3.2__py3-none-any.whl → 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.
- paddle_billing/Client.py +7 -13
- paddle_billing/Entities/Price.py +0 -4
- paddle_billing/Entities/Reports/ReportFilter.py +1 -4
- paddle_billing/Entities/Shared/CustomData.py +0 -3
- paddle_billing/Entities/Shared/TransactionLineItemPreview.py +5 -5
- paddle_billing/Entities/Shared/TransactionPreviewProduct.py +37 -0
- paddle_billing/Entities/Subscriptions/SubscriptionAdjustmentItem.py +2 -2
- paddle_billing/Entities/Subscriptions/__init__.py +0 -8
- paddle_billing/Entities/Transactions/TransactionItem.py +0 -2
- paddle_billing/Entities/Transactions/TransactionItemPreviewWithPrice.py +3 -3
- paddle_billing/Entities/Transactions/TransactionPreviewPrice.py +59 -0
- paddle_billing/Entities/Transactions/__init__.py +0 -12
- paddle_billing/Notifications/Entities/Price.py +0 -4
- paddle_billing/Notifications/Entities/Reports/ReportFilter.py +1 -4
- paddle_billing/Notifications/Entities/Shared/CustomData.py +1 -1
- paddle_billing/Resources/Addresses/AddressesClient.py +2 -4
- paddle_billing/Resources/Addresses/Operations/CreateAddress.py +3 -5
- paddle_billing/Resources/Addresses/Operations/UpdateAddress.py +3 -5
- paddle_billing/Resources/Adjustments/AdjustmentsClient.py +1 -1
- paddle_billing/Resources/Adjustments/Operations/CreateAdjustment.py +3 -18
- paddle_billing/Resources/Businesses/BusinessesClient.py +2 -4
- paddle_billing/Resources/Businesses/Operations/CreateBusiness.py +3 -5
- paddle_billing/Resources/Businesses/Operations/UpdateBusiness.py +3 -5
- paddle_billing/Resources/Customers/CustomersClient.py +2 -2
- paddle_billing/Resources/Customers/Operations/CreateCustomer.py +3 -5
- paddle_billing/Resources/Customers/Operations/UpdateCustomer.py +3 -5
- paddle_billing/Resources/Discounts/DiscountsClient.py +2 -2
- paddle_billing/Resources/Discounts/Operations/CreateDiscount.py +5 -6
- paddle_billing/Resources/Discounts/Operations/UpdateDiscount.py +5 -6
- paddle_billing/Resources/NotificationSettings/NotificationSettingsClient.py +2 -4
- paddle_billing/Resources/NotificationSettings/Operations/CreateNotificationSetting.py +3 -5
- paddle_billing/Resources/NotificationSettings/Operations/UpdateNotificationSetting.py +3 -5
- paddle_billing/Resources/Prices/Operations/CreatePrice.py +3 -5
- paddle_billing/Resources/Prices/Operations/UpdatePrice.py +3 -5
- paddle_billing/Resources/Prices/PricesClient.py +2 -2
- paddle_billing/Resources/PricingPreviews/Operations/PreviewPrice.py +3 -5
- paddle_billing/Resources/PricingPreviews/PricingPreviewsClient.py +1 -1
- paddle_billing/Resources/Products/Operations/CreateProduct.py +3 -5
- paddle_billing/Resources/Products/Operations/UpdateProduct.py +3 -5
- paddle_billing/Resources/Products/ProductsClient.py +2 -2
- paddle_billing/Resources/Reports/Operations/CreateReport.py +5 -3
- paddle_billing/Resources/Reports/Operations/Filters/Filter.py +1 -1
- paddle_billing/Resources/Reports/ReportsClient.py +1 -1
- paddle_billing/Resources/Subscriptions/Operations/CancelSubscription.py +3 -5
- paddle_billing/{Entities/Transactions/TransactionUpdateTransactionItem.py → Resources/Subscriptions/Operations/Charge/SubscriptionChargeItem.py} +1 -1
- paddle_billing/Resources/Subscriptions/Operations/Charge/SubscriptionChargeItemWithPrice.py +13 -0
- paddle_billing/Resources/Subscriptions/Operations/Charge/__init__.py +4 -0
- paddle_billing/Resources/Subscriptions/Operations/CreateOneTimeCharge.py +9 -8
- paddle_billing/Resources/Subscriptions/Operations/PauseSubscription.py +3 -8
- paddle_billing/Resources/Subscriptions/Operations/PreviewOneTimeCharge.py +9 -8
- paddle_billing/Resources/Subscriptions/Operations/PreviewUpdateSubscription.py +3 -3
- paddle_billing/Resources/Subscriptions/Operations/Price/SubscriptionNonCatalogPrice.py +24 -0
- paddle_billing/Resources/Subscriptions/Operations/Price/SubscriptionNonCatalogPriceWithProduct.py +28 -0
- paddle_billing/Resources/Subscriptions/Operations/Price/SubscriptionNonCatalogProduct.py +15 -0
- paddle_billing/Resources/Subscriptions/Operations/Price/__init__.py +9 -0
- paddle_billing/Resources/Subscriptions/Operations/ResumeSubscription.py +2 -8
- paddle_billing/Resources/Subscriptions/Operations/Update/SubscriptionUpdateItem.py +9 -0
- paddle_billing/Resources/Subscriptions/Operations/Update/SubscriptionUpdateItemWithPrice.py +13 -0
- paddle_billing/Resources/Subscriptions/Operations/Update/__init__.py +4 -0
- paddle_billing/Resources/Subscriptions/Operations/UpdateSubscription.py +3 -3
- paddle_billing/Resources/Subscriptions/SubscriptionsClient.py +5 -7
- paddle_billing/Resources/Transactions/Operations/Create/TransactionCreateItem.py +8 -0
- paddle_billing/{Entities/Transactions → Resources/Transactions/Operations/Create}/TransactionCreateItemWithPrice.py +2 -2
- paddle_billing/Resources/Transactions/Operations/Create/__init__.py +4 -0
- paddle_billing/Resources/Transactions/Operations/CreateTransaction.py +5 -2
- paddle_billing/Resources/Transactions/Operations/Preview/TransactionItemPreviewWithNonCatalogPrice.py +15 -0
- paddle_billing/Resources/Transactions/Operations/Preview/TransactionItemPreviewWithPriceId.py +10 -0
- paddle_billing/Resources/Transactions/Operations/Preview/__init__.py +6 -0
- paddle_billing/Resources/Transactions/Operations/PreviewTransactionByAddress.py +4 -6
- paddle_billing/Resources/Transactions/Operations/PreviewTransactionByCustomer.py +4 -6
- paddle_billing/Resources/Transactions/Operations/PreviewTransactionByIP.py +4 -6
- paddle_billing/Resources/Transactions/Operations/Price/TransactionNonCatalogPrice.py +24 -0
- paddle_billing/Resources/Transactions/Operations/Price/TransactionNonCatalogPriceWithProduct.py +28 -0
- paddle_billing/Resources/Transactions/Operations/Price/TransactionNonCatalogProduct.py +15 -0
- paddle_billing/Resources/Transactions/Operations/Price/__init__.py +7 -0
- paddle_billing/Resources/Transactions/Operations/Update/TransactionUpdateItem.py +8 -0
- paddle_billing/Resources/Transactions/Operations/Update/TransactionUpdateItemWithPrice.py +13 -0
- paddle_billing/Resources/Transactions/Operations/Update/__init__.py +4 -0
- paddle_billing/Resources/Transactions/Operations/UpdateTransaction.py +6 -3
- paddle_billing/Resources/Transactions/TransactionsClient.py +1 -1
- {paddle_python_sdk-0.3.2.dist-info → paddle_python_sdk-1.0.0.dist-info}/METADATA +1 -1
- {paddle_python_sdk-0.3.2.dist-info → paddle_python_sdk-1.0.0.dist-info}/RECORD +88 -80
- tests/Functional/Resources/Discounts/test_DiscountsClient.py +3 -2
- tests/Functional/Resources/Subscriptions/test_SubscriptionsClient.py +273 -75
- tests/Functional/Resources/Transactions/test_TransactionsClient.py +233 -13
- paddle_billing/Entities/Subscriptions/SubscriptionItems.py +0 -18
- paddle_billing/Entities/Subscriptions/SubscriptionItemsWithPrice.py +0 -23
- paddle_billing/Entities/Subscriptions/SubscriptionNonCatalogPrice.py +0 -33
- paddle_billing/Entities/Subscriptions/SubscriptionNonCatalogPriceWithProduct.py +0 -35
- paddle_billing/Entities/Subscriptions/SubscriptionNonCatalogProduct.py +0 -25
- paddle_billing/Entities/Subscriptions/SubscriptionUpdateItem.py +0 -15
- paddle_billing/Entities/Transactions/TransactionCreateItem.py +0 -15
- paddle_billing/Entities/Transactions/TransactionItemPreviewWithNonCatalogPrice.py +0 -29
- paddle_billing/Entities/Transactions/TransactionItemPreviewWithPriceId.py +0 -17
- paddle_billing/Entities/Transactions/TransactionNonCatalogPrice.py +0 -38
- paddle_billing/Entities/Transactions/TransactionNonCatalogPriceWithProduct.py +0 -40
- paddle_billing/Entities/Transactions/TransactionNonCatalogProduct.py +0 -24
- {paddle_python_sdk-0.3.2.dist-info → paddle_python_sdk-1.0.0.dist-info}/LICENSE +0 -0
- {paddle_python_sdk-0.3.2.dist-info → paddle_python_sdk-1.0.0.dist-info}/WHEEL +0 -0
- {paddle_python_sdk-0.3.2.dist-info → paddle_python_sdk-1.0.0.dist-info}/top_level.txt +0 -0
paddle_billing/Client.py
CHANGED
|
@@ -37,6 +37,12 @@ from paddle_billing.Resources.Transactions.TransactionsClient import Transaction
|
|
|
37
37
|
|
|
38
38
|
class PayloadEncoder(JSONEncoder):
|
|
39
39
|
def default(self, z):
|
|
40
|
+
if isinstance(z, Undefined):
|
|
41
|
+
return None
|
|
42
|
+
|
|
43
|
+
if hasattr(z, "to_json") and callable(z.to_json):
|
|
44
|
+
return z.to_json()
|
|
45
|
+
|
|
40
46
|
if is_dataclass(z):
|
|
41
47
|
data = {}
|
|
42
48
|
for field in fields(z):
|
|
@@ -44,12 +50,6 @@ class PayloadEncoder(JSONEncoder):
|
|
|
44
50
|
|
|
45
51
|
return FiltersUndefined.filter_undefined_values(data)
|
|
46
52
|
|
|
47
|
-
if isinstance(z, Undefined):
|
|
48
|
-
return None
|
|
49
|
-
|
|
50
|
-
if hasattr(z, "to_json") and callable(z.to_json):
|
|
51
|
-
return z.to_json()
|
|
52
|
-
|
|
53
53
|
return super().default(z)
|
|
54
54
|
|
|
55
55
|
|
|
@@ -183,17 +183,11 @@ class Client:
|
|
|
183
183
|
def post_raw(
|
|
184
184
|
self, url: str, payload: dict | Operation | None = None, parameters: HasParameters | dict | None = None
|
|
185
185
|
) -> Response:
|
|
186
|
-
if isinstance(payload, dict):
|
|
187
|
-
payload = FiltersUndefined.filter_undefined_values(payload) # Strip Undefined items from the dict
|
|
188
|
-
|
|
189
186
|
url = Client.format_uri_parameters(url, parameters) if parameters else url
|
|
190
187
|
|
|
191
188
|
return self._make_request("POST", url, payload)
|
|
192
189
|
|
|
193
190
|
def patch_raw(self, url: str, payload: dict | Operation | None) -> Response:
|
|
194
|
-
if isinstance(payload, dict):
|
|
195
|
-
payload = FiltersUndefined.filter_undefined_values(payload) # Strip Undefined items from the dict
|
|
196
|
-
|
|
197
191
|
return self._make_request("PATCH", url, payload)
|
|
198
192
|
|
|
199
193
|
def delete_raw(self, url: str) -> Response:
|
|
@@ -206,7 +200,7 @@ class Client:
|
|
|
206
200
|
"Authorization": f"Bearer {self.__api_key}",
|
|
207
201
|
"Content-Type": "application/json",
|
|
208
202
|
"Paddle-Version": str(self.use_api_version),
|
|
209
|
-
"User-Agent": "PaddleSDK/python 0.
|
|
203
|
+
"User-Agent": "PaddleSDK/python 1.0.0",
|
|
210
204
|
}
|
|
211
205
|
)
|
|
212
206
|
|
paddle_billing/Entities/Price.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
-
from dataclasses import
|
|
2
|
+
from dataclasses import dataclass
|
|
3
3
|
|
|
4
4
|
from paddle_billing.Entities.Reports import ReportFilterName, ReportFilterOperator
|
|
5
5
|
|
|
@@ -13,6 +13,3 @@ class ReportFilter:
|
|
|
13
13
|
@staticmethod
|
|
14
14
|
def from_dict(data: dict) -> ReportFilter:
|
|
15
15
|
return ReportFilter(**data)
|
|
16
|
-
|
|
17
|
-
def get_parameters(self) -> dict:
|
|
18
|
-
return asdict(self)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from dataclasses import dataclass
|
|
3
3
|
|
|
4
|
-
from paddle_billing.Entities.
|
|
4
|
+
from paddle_billing.Entities.Shared.TransactionPreviewProduct import TransactionPreviewProduct
|
|
5
5
|
from paddle_billing.Entities.Shared.Totals import Totals
|
|
6
6
|
from paddle_billing.Entities.Shared.UnitTotals import UnitTotals
|
|
7
7
|
from paddle_billing.Entities.Shared.Proration import Proration
|
|
@@ -9,22 +9,22 @@ from paddle_billing.Entities.Shared.Proration import Proration
|
|
|
9
9
|
|
|
10
10
|
@dataclass
|
|
11
11
|
class TransactionLineItemPreview:
|
|
12
|
-
price_id: str
|
|
12
|
+
price_id: str | None
|
|
13
13
|
quantity: int
|
|
14
14
|
tax_rate: str
|
|
15
15
|
unit_totals: UnitTotals
|
|
16
16
|
totals: Totals
|
|
17
|
-
product:
|
|
17
|
+
product: TransactionPreviewProduct
|
|
18
18
|
proration: Proration | None
|
|
19
19
|
|
|
20
20
|
@staticmethod
|
|
21
21
|
def from_dict(data: dict) -> TransactionLineItemPreview:
|
|
22
22
|
return TransactionLineItemPreview(
|
|
23
|
-
price_id=data
|
|
23
|
+
price_id=data.get("price_id"),
|
|
24
24
|
quantity=data["quantity"],
|
|
25
25
|
tax_rate=data["tax_rate"],
|
|
26
26
|
unit_totals=UnitTotals.from_dict(data["unit_totals"]),
|
|
27
27
|
totals=Totals.from_dict(data["totals"]),
|
|
28
|
-
product=
|
|
28
|
+
product=TransactionPreviewProduct.from_dict(data["product"]),
|
|
29
29
|
proration=Proration.from_dict(data["proration"]) if data.get("proration") else None,
|
|
30
30
|
)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
|
|
5
|
+
from paddle_billing.Entities.Entity import Entity
|
|
6
|
+
from paddle_billing.Entities.Shared import CatalogType, CustomData, ImportMeta, Status, TaxCategory
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class TransactionPreviewProduct(Entity):
|
|
11
|
+
id: str | None
|
|
12
|
+
name: str
|
|
13
|
+
description: str | None
|
|
14
|
+
tax_category: TaxCategory
|
|
15
|
+
image_url: str | None
|
|
16
|
+
status: Status
|
|
17
|
+
created_at: datetime
|
|
18
|
+
updated_at: datetime
|
|
19
|
+
type: CatalogType | None = None
|
|
20
|
+
custom_data: CustomData | None = None
|
|
21
|
+
import_meta: ImportMeta | None = None
|
|
22
|
+
|
|
23
|
+
@staticmethod
|
|
24
|
+
def from_dict(data: dict) -> TransactionPreviewProduct:
|
|
25
|
+
return TransactionPreviewProduct(
|
|
26
|
+
id=data.get("id"),
|
|
27
|
+
name=data["name"],
|
|
28
|
+
description=data.get("description"),
|
|
29
|
+
tax_category=TaxCategory(data["tax_category"]),
|
|
30
|
+
image_url=data.get("image_url"),
|
|
31
|
+
status=Status(data["status"]),
|
|
32
|
+
created_at=datetime.fromisoformat(data["created_at"]),
|
|
33
|
+
updated_at=datetime.fromisoformat(data["updated_at"]),
|
|
34
|
+
type=CatalogType(data["type"]) if data.get("type") else None,
|
|
35
|
+
custom_data=CustomData(data["custom_data"]) if data.get("custom_data") else None,
|
|
36
|
+
import_meta=ImportMeta.from_dict(data["import_meta"]) if data.get("import_meta") else None,
|
|
37
|
+
)
|
|
@@ -9,7 +9,7 @@ class SubscriptionAdjustmentItem:
|
|
|
9
9
|
item_id: str
|
|
10
10
|
type: AdjustmentType
|
|
11
11
|
amount: str | None
|
|
12
|
-
proration: Proration
|
|
12
|
+
proration: Proration | None
|
|
13
13
|
totals: AdjustmentItemTotals
|
|
14
14
|
|
|
15
15
|
@staticmethod
|
|
@@ -18,6 +18,6 @@ class SubscriptionAdjustmentItem:
|
|
|
18
18
|
item_id=data["item_id"],
|
|
19
19
|
type=AdjustmentType(data["type"]),
|
|
20
20
|
amount=data.get("amount"),
|
|
21
|
-
proration=Proration.from_dict(data["proration"]),
|
|
21
|
+
proration=Proration.from_dict(data["proration"]) if data.get("proration") else None,
|
|
22
22
|
totals=AdjustmentItemTotals.from_dict(data["totals"]),
|
|
23
23
|
)
|
|
@@ -6,15 +6,8 @@ from paddle_billing.Entities.Subscriptions.SubscriptionDiscount import Subscript
|
|
|
6
6
|
from paddle_billing.Entities.Subscriptions.SubscriptionEffectiveFrom import SubscriptionEffectiveFrom
|
|
7
7
|
from paddle_billing.Entities.Subscriptions.SubscriptionItem import SubscriptionItem
|
|
8
8
|
from paddle_billing.Entities.Subscriptions.SubscriptionItemStatus import SubscriptionItemStatus
|
|
9
|
-
from paddle_billing.Entities.Subscriptions.SubscriptionItems import SubscriptionItems
|
|
10
|
-
from paddle_billing.Entities.Subscriptions.SubscriptionItemsWithPrice import SubscriptionItemsWithPrice
|
|
11
9
|
from paddle_billing.Entities.Subscriptions.SubscriptionManagementUrls import SubscriptionManagementUrls
|
|
12
10
|
from paddle_billing.Entities.Subscriptions.SubscriptionNextTransaction import SubscriptionNextTransaction
|
|
13
|
-
from paddle_billing.Entities.Subscriptions.SubscriptionNonCatalogPrice import SubscriptionNonCatalogPrice
|
|
14
|
-
from paddle_billing.Entities.Subscriptions.SubscriptionNonCatalogPriceWithProduct import (
|
|
15
|
-
SubscriptionNonCatalogPriceWithProduct,
|
|
16
|
-
)
|
|
17
|
-
from paddle_billing.Entities.Subscriptions.SubscriptionNonCatalogProduct import SubscriptionNonCatalogProduct
|
|
18
11
|
from paddle_billing.Entities.Subscriptions.SubscriptionOnPaymentFailure import SubscriptionOnPaymentFailure
|
|
19
12
|
from paddle_billing.Entities.Subscriptions.SubscriptionPreviewSubscriptionUpdateSummary import (
|
|
20
13
|
SubscriptionPreviewSubscriptionUpdateSummary,
|
|
@@ -26,4 +19,3 @@ from paddle_billing.Entities.Subscriptions.SubscriptionResumeEffectiveFrom impor
|
|
|
26
19
|
from paddle_billing.Entities.Subscriptions.SubscriptionScheduledChange import SubscriptionScheduledChange
|
|
27
20
|
from paddle_billing.Entities.Subscriptions.SubscriptionScheduledChangeAction import SubscriptionScheduledChangeAction
|
|
28
21
|
from paddle_billing.Entities.Subscriptions.SubscriptionStatus import SubscriptionStatus
|
|
29
|
-
from paddle_billing.Entities.Subscriptions.SubscriptionUpdateItem import SubscriptionUpdateItem
|
|
@@ -8,7 +8,6 @@ from paddle_billing.Entities.Shared.Proration import Proration
|
|
|
8
8
|
|
|
9
9
|
@dataclass
|
|
10
10
|
class TransactionItem:
|
|
11
|
-
price_id: str | None
|
|
12
11
|
price: Price
|
|
13
12
|
quantity: int
|
|
14
13
|
proration: Proration | None
|
|
@@ -16,7 +15,6 @@ class TransactionItem:
|
|
|
16
15
|
@staticmethod
|
|
17
16
|
def from_dict(data: dict) -> TransactionItem:
|
|
18
17
|
return TransactionItem(
|
|
19
|
-
price_id=data.get("price_id"),
|
|
20
18
|
price=Price.from_dict(data["price"]),
|
|
21
19
|
quantity=data["quantity"],
|
|
22
20
|
proration=Proration.from_dict(data["proration"]) if data.get("proration") else None,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from dataclasses import dataclass
|
|
3
3
|
|
|
4
|
-
from paddle_billing.Entities.
|
|
4
|
+
from paddle_billing.Entities.Transactions.TransactionPreviewPrice import TransactionPreviewPrice
|
|
5
5
|
|
|
6
6
|
from paddle_billing.Entities.Shared.Proration import Proration
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
@dataclass
|
|
10
10
|
class TransactionItemPreviewWithPrice:
|
|
11
|
-
price:
|
|
11
|
+
price: TransactionPreviewPrice
|
|
12
12
|
quantity: int
|
|
13
13
|
include_in_totals: bool
|
|
14
14
|
proration: Proration | None
|
|
@@ -16,7 +16,7 @@ class TransactionItemPreviewWithPrice:
|
|
|
16
16
|
@staticmethod
|
|
17
17
|
def from_dict(data: dict) -> TransactionItemPreviewWithPrice:
|
|
18
18
|
return TransactionItemPreviewWithPrice(
|
|
19
|
-
price=
|
|
19
|
+
price=TransactionPreviewPrice.from_dict(data["price"]),
|
|
20
20
|
quantity=data["quantity"],
|
|
21
21
|
include_in_totals=data["include_in_totals"],
|
|
22
22
|
proration=Proration.from_dict(data["proration"]) if data.get("proration") else None,
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
|
|
5
|
+
from paddle_billing.Entities.Entity import Entity
|
|
6
|
+
from paddle_billing.Entities.Shared import (
|
|
7
|
+
CatalogType,
|
|
8
|
+
CustomData,
|
|
9
|
+
Duration,
|
|
10
|
+
ImportMeta,
|
|
11
|
+
Money,
|
|
12
|
+
PriceQuantity,
|
|
13
|
+
Status,
|
|
14
|
+
TaxMode,
|
|
15
|
+
UnitPriceOverride,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class TransactionPreviewPrice(Entity):
|
|
21
|
+
id: str | None
|
|
22
|
+
product_id: str | None
|
|
23
|
+
name: str | None
|
|
24
|
+
description: str
|
|
25
|
+
type: CatalogType
|
|
26
|
+
billing_cycle: Duration | None
|
|
27
|
+
trial_period: Duration | None
|
|
28
|
+
tax_mode: TaxMode
|
|
29
|
+
unit_price: Money
|
|
30
|
+
unit_price_overrides: list[UnitPriceOverride]
|
|
31
|
+
quantity: PriceQuantity
|
|
32
|
+
status: Status
|
|
33
|
+
custom_data: CustomData | None
|
|
34
|
+
import_meta: ImportMeta | None
|
|
35
|
+
created_at: datetime
|
|
36
|
+
updated_at: datetime
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def from_dict(data: dict) -> TransactionPreviewPrice:
|
|
40
|
+
return TransactionPreviewPrice(
|
|
41
|
+
id=data.get("id"),
|
|
42
|
+
product_id=data.get("product_id"),
|
|
43
|
+
name=data.get("name"),
|
|
44
|
+
description=data["description"],
|
|
45
|
+
unit_price=Money.from_dict(data["unit_price"]),
|
|
46
|
+
quantity=PriceQuantity.from_dict(data["quantity"]),
|
|
47
|
+
status=Status(data["status"]),
|
|
48
|
+
tax_mode=TaxMode(data.get("tax_mode")),
|
|
49
|
+
created_at=datetime.fromisoformat(data["created_at"]),
|
|
50
|
+
updated_at=datetime.fromisoformat(data["updated_at"]),
|
|
51
|
+
unit_price_overrides=[
|
|
52
|
+
UnitPriceOverride.from_dict(override) for override in data.get("unit_price_overrides", [])
|
|
53
|
+
],
|
|
54
|
+
type=CatalogType(data.get("type")) if data.get("type") else None,
|
|
55
|
+
billing_cycle=Duration.from_dict(data["billing_cycle"]) if data.get("billing_cycle") else None,
|
|
56
|
+
trial_period=Duration.from_dict(data["trial_period"]) if data.get("trial_period") else None,
|
|
57
|
+
custom_data=CustomData(data["custom_data"]) if data.get("custom_data") else None,
|
|
58
|
+
import_meta=ImportMeta.from_dict(data["import_meta"]) if data.get("import_meta") else None,
|
|
59
|
+
)
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
from paddle_billing.Entities.Transactions.TransactionAdjustmentsTotals import TransactionAdjustmentsTotals
|
|
2
2
|
from paddle_billing.Entities.Transactions.TransactionBreakdown import TransactionBreakdown
|
|
3
3
|
from paddle_billing.Entities.Transactions.TransactionCardType import TransactionCardType
|
|
4
|
-
from paddle_billing.Entities.Transactions.TransactionCreateItem import TransactionCreateItem
|
|
5
|
-
from paddle_billing.Entities.Transactions.TransactionCreateItemWithPrice import TransactionCreateItemWithPrice
|
|
6
|
-
from paddle_billing.Entities.Transactions.TransactionItemPreviewWithNonCatalogPrice import (
|
|
7
|
-
TransactionItemPreviewWithNonCatalogPrice,
|
|
8
|
-
)
|
|
9
|
-
from paddle_billing.Entities.Transactions.TransactionItemPreviewWithPriceId import TransactionItemPreviewWithPriceId
|
|
10
|
-
from paddle_billing.Entities.Transactions.TransactionNonCatalogPrice import TransactionNonCatalogPrice
|
|
11
|
-
from paddle_billing.Entities.Transactions.TransactionNonCatalogPriceWithProduct import (
|
|
12
|
-
TransactionNonCatalogPriceWithProduct,
|
|
13
|
-
)
|
|
14
|
-
from paddle_billing.Entities.Transactions.TransactionNonCatalogProduct import TransactionNonCatalogProduct
|
|
15
4
|
from paddle_billing.Entities.Shared.TimePeriod import TimePeriod
|
|
16
|
-
from paddle_billing.Entities.Transactions.TransactionUpdateTransactionItem import TransactionUpdateTransactionItem
|
|
17
5
|
|
|
18
6
|
|
|
19
7
|
# These cause circular imports
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
-
from dataclasses import
|
|
2
|
+
from dataclasses import dataclass
|
|
3
3
|
|
|
4
4
|
from paddle_billing.Notifications.Entities.Reports import ReportFilterName, ReportFilterOperator
|
|
5
5
|
|
|
@@ -13,6 +13,3 @@ class ReportFilter:
|
|
|
13
13
|
@staticmethod
|
|
14
14
|
def from_dict(data: dict) -> ReportFilter:
|
|
15
15
|
return ReportFilter(**data)
|
|
16
|
-
|
|
17
|
-
def get_parameters(self) -> dict:
|
|
18
|
-
return asdict(self)
|
|
@@ -35,15 +35,13 @@ class AddressesClient:
|
|
|
35
35
|
return Address.from_dict(parser.get_data())
|
|
36
36
|
|
|
37
37
|
def create(self, customer_id: str, operation: CreateAddress) -> Address:
|
|
38
|
-
self.response = self.client.post_raw(f"/customers/{customer_id}/addresses", operation
|
|
38
|
+
self.response = self.client.post_raw(f"/customers/{customer_id}/addresses", operation)
|
|
39
39
|
parser = ResponseParser(self.response)
|
|
40
40
|
|
|
41
41
|
return Address.from_dict(parser.get_data())
|
|
42
42
|
|
|
43
43
|
def update(self, customer_id: str, address_id: str, operation: UpdateAddress) -> Address:
|
|
44
|
-
self.response = self.client.patch_raw(
|
|
45
|
-
f"/customers/{customer_id}/addresses/{address_id}", operation.get_parameters()
|
|
46
|
-
)
|
|
44
|
+
self.response = self.client.patch_raw(f"/customers/{customer_id}/addresses/{address_id}", operation)
|
|
47
45
|
parser = ResponseParser(self.response)
|
|
48
46
|
|
|
49
47
|
return Address.from_dict(parser.get_data())
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
from dataclasses import
|
|
1
|
+
from dataclasses import dataclass
|
|
2
2
|
|
|
3
|
+
from paddle_billing.Operation import Operation
|
|
3
4
|
from paddle_billing.Undefined import Undefined
|
|
4
5
|
from paddle_billing.Entities.Shared import CountryCode, CustomData
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
@dataclass
|
|
8
|
-
class CreateAddress:
|
|
9
|
+
class CreateAddress(Operation):
|
|
9
10
|
country_code: CountryCode
|
|
10
11
|
description: str | None = Undefined()
|
|
11
12
|
first_line: str | None = Undefined()
|
|
@@ -14,6 +15,3 @@ class CreateAddress:
|
|
|
14
15
|
postal_code: str | None = Undefined()
|
|
15
16
|
region: str | None = Undefined()
|
|
16
17
|
custom_data: CustomData | None = Undefined()
|
|
17
|
-
|
|
18
|
-
def get_parameters(self) -> dict:
|
|
19
|
-
return asdict(self)
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
from dataclasses import
|
|
1
|
+
from dataclasses import dataclass
|
|
2
2
|
|
|
3
|
+
from paddle_billing.Operation import Operation
|
|
3
4
|
from paddle_billing.Undefined import Undefined
|
|
4
5
|
from paddle_billing.Entities.Shared import CountryCode, CustomData, Status
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
@dataclass
|
|
8
|
-
class UpdateAddress:
|
|
9
|
+
class UpdateAddress(Operation):
|
|
9
10
|
country_code: CountryCode | Undefined = Undefined()
|
|
10
11
|
description: str | None | Undefined = Undefined()
|
|
11
12
|
first_line: str | None | Undefined = Undefined()
|
|
@@ -15,6 +16,3 @@ class UpdateAddress:
|
|
|
15
16
|
region: str | None | Undefined = Undefined()
|
|
16
17
|
custom_data: CustomData | None | Undefined = Undefined()
|
|
17
18
|
status: Status | None | Undefined = Undefined()
|
|
18
|
-
|
|
19
|
-
def get_parameters(self) -> dict:
|
|
20
|
-
return asdict(self)
|
|
@@ -29,7 +29,7 @@ class AdjustmentsClient:
|
|
|
29
29
|
)
|
|
30
30
|
|
|
31
31
|
def create(self, operation: CreateAdjustment) -> Adjustment:
|
|
32
|
-
self.response = self.client.post_raw("/adjustments", operation
|
|
32
|
+
self.response = self.client.post_raw("/adjustments", operation)
|
|
33
33
|
parser = ResponseParser(self.response)
|
|
34
34
|
|
|
35
35
|
return Adjustment.from_dict(parser.get_data())
|
|
@@ -1,30 +1,15 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
2
|
|
|
3
|
+
from paddle_billing.Operation import Operation
|
|
4
|
+
|
|
3
5
|
from paddle_billing.Entities.Shared import Action
|
|
4
6
|
|
|
5
7
|
from paddle_billing.Resources.Adjustments.Operations import CreateAdjustmentItem
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
@dataclass
|
|
9
|
-
class CreateAdjustment:
|
|
11
|
+
class CreateAdjustment(Operation):
|
|
10
12
|
action: Action
|
|
11
13
|
items: list[CreateAdjustmentItem]
|
|
12
14
|
reason: str
|
|
13
15
|
transaction_id: str
|
|
14
|
-
|
|
15
|
-
def get_parameters(self) -> dict:
|
|
16
|
-
items = [
|
|
17
|
-
{
|
|
18
|
-
"item_id": item.item_id,
|
|
19
|
-
"type": item.type,
|
|
20
|
-
"amount": item.amount,
|
|
21
|
-
}
|
|
22
|
-
for item in self.items
|
|
23
|
-
]
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
"action": self.action.value,
|
|
27
|
-
"items": items,
|
|
28
|
-
"reason": self.reason,
|
|
29
|
-
"transaction_id": self.transaction_id,
|
|
30
|
-
}
|
|
@@ -35,15 +35,13 @@ class BusinessesClient:
|
|
|
35
35
|
return Business.from_dict(parser.get_data())
|
|
36
36
|
|
|
37
37
|
def create(self, customer_id: str, operation: CreateBusiness) -> Business:
|
|
38
|
-
self.response = self.client.post_raw(f"/customers/{customer_id}/businesses", operation
|
|
38
|
+
self.response = self.client.post_raw(f"/customers/{customer_id}/businesses", operation)
|
|
39
39
|
parser = ResponseParser(self.response)
|
|
40
40
|
|
|
41
41
|
return Business.from_dict(parser.get_data())
|
|
42
42
|
|
|
43
43
|
def update(self, customer_id: str, business_id: str, operation: UpdateBusiness) -> Business:
|
|
44
|
-
self.response = self.client.patch_raw(
|
|
45
|
-
f"/customers/{customer_id}/businesses/{business_id}", operation.get_parameters()
|
|
46
|
-
)
|
|
44
|
+
self.response = self.client.patch_raw(f"/customers/{customer_id}/businesses/{business_id}", operation)
|
|
47
45
|
parser = ResponseParser(self.response)
|
|
48
46
|
|
|
49
47
|
return Business.from_dict(parser.get_data())
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
from dataclasses import
|
|
1
|
+
from dataclasses import dataclass
|
|
2
2
|
|
|
3
|
+
from paddle_billing.Operation import Operation
|
|
3
4
|
from paddle_billing.Undefined import Undefined
|
|
4
5
|
from paddle_billing.Entities.Shared import Contacts, CustomData
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
@dataclass
|
|
8
|
-
class CreateBusiness:
|
|
9
|
+
class CreateBusiness(Operation):
|
|
9
10
|
name: str
|
|
10
11
|
company_number: str | None | Undefined = Undefined()
|
|
11
12
|
tax_identifier: str | None | Undefined = Undefined()
|
|
12
13
|
contacts: list[Contacts] | Undefined = Undefined()
|
|
13
14
|
custom_data: CustomData | None | Undefined = Undefined()
|
|
14
|
-
|
|
15
|
-
def get_parameters(self) -> dict:
|
|
16
|
-
return asdict(self)
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
from dataclasses import
|
|
1
|
+
from dataclasses import dataclass
|
|
2
2
|
|
|
3
|
+
from paddle_billing.Operation import Operation
|
|
3
4
|
from paddle_billing.Undefined import Undefined
|
|
4
5
|
from paddle_billing.Entities.Shared import Contacts, CustomData, Status
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
@dataclass
|
|
8
|
-
class UpdateBusiness:
|
|
9
|
+
class UpdateBusiness(Operation):
|
|
9
10
|
name: str | Undefined = Undefined()
|
|
10
11
|
company_number: str | None | Undefined = Undefined()
|
|
11
12
|
tax_identifier: str | None | Undefined = Undefined()
|
|
12
13
|
contacts: list[Contacts] | Undefined = Undefined()
|
|
13
14
|
custom_data: CustomData | None | Undefined = Undefined()
|
|
14
15
|
status: Status | Undefined = Undefined()
|
|
15
|
-
|
|
16
|
-
def get_parameters(self) -> dict:
|
|
17
|
-
return asdict(self)
|
|
@@ -40,13 +40,13 @@ class CustomersClient:
|
|
|
40
40
|
return Customer.from_dict(parser.get_data())
|
|
41
41
|
|
|
42
42
|
def create(self, operation: CreateCustomer) -> Customer:
|
|
43
|
-
self.response = self.client.post_raw("/customers", operation
|
|
43
|
+
self.response = self.client.post_raw("/customers", operation)
|
|
44
44
|
parser = ResponseParser(self.response)
|
|
45
45
|
|
|
46
46
|
return Customer.from_dict(parser.get_data())
|
|
47
47
|
|
|
48
48
|
def update(self, customer_id: str, operation: UpdateCustomer) -> Customer:
|
|
49
|
-
self.response = self.client.patch_raw(f"/customers/{customer_id}", operation
|
|
49
|
+
self.response = self.client.patch_raw(f"/customers/{customer_id}", operation)
|
|
50
50
|
parser = ResponseParser(self.response)
|
|
51
51
|
|
|
52
52
|
return Customer.from_dict(parser.get_data())
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
from dataclasses import
|
|
1
|
+
from dataclasses import dataclass
|
|
2
2
|
|
|
3
|
+
from paddle_billing.Operation import Operation
|
|
3
4
|
from paddle_billing.Undefined import Undefined
|
|
4
5
|
from paddle_billing.Entities.Shared import CustomData
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
@dataclass
|
|
8
|
-
class CreateCustomer:
|
|
9
|
+
class CreateCustomer(Operation):
|
|
9
10
|
email: str
|
|
10
11
|
name: str | None | Undefined = Undefined()
|
|
11
12
|
custom_data: CustomData | None | Undefined = Undefined()
|
|
12
13
|
locale: str | Undefined = Undefined()
|
|
13
|
-
|
|
14
|
-
def get_parameters(self) -> dict:
|
|
15
|
-
return asdict(self)
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
from dataclasses import
|
|
1
|
+
from dataclasses import dataclass
|
|
2
2
|
|
|
3
|
+
from paddle_billing.Operation import Operation
|
|
3
4
|
from paddle_billing.Undefined import Undefined
|
|
4
5
|
from paddle_billing.Entities.Shared import CustomData, Status
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
@dataclass
|
|
8
|
-
class UpdateCustomer:
|
|
9
|
+
class UpdateCustomer(Operation):
|
|
9
10
|
email: str | Undefined = Undefined()
|
|
10
11
|
name: str | None | Undefined = Undefined()
|
|
11
12
|
custom_data: CustomData | None | Undefined = Undefined()
|
|
12
13
|
locale: str | Undefined = Undefined()
|
|
13
14
|
status: Status | Undefined = Undefined()
|
|
14
|
-
|
|
15
|
-
def get_parameters(self) -> dict:
|
|
16
|
-
return asdict(self)
|
|
@@ -35,13 +35,13 @@ class DiscountsClient:
|
|
|
35
35
|
return Discount.from_dict(parser.get_data())
|
|
36
36
|
|
|
37
37
|
def create(self, operation: CreateDiscount) -> Discount:
|
|
38
|
-
self.response = self.client.post_raw("/discounts", operation
|
|
38
|
+
self.response = self.client.post_raw("/discounts", operation)
|
|
39
39
|
parser = ResponseParser(self.response)
|
|
40
40
|
|
|
41
41
|
return Discount.from_dict(parser.get_data())
|
|
42
42
|
|
|
43
43
|
def update(self, discount_id: str, operation: UpdateDiscount) -> Discount:
|
|
44
|
-
self.response = self.client.patch_raw(f"/discounts/{discount_id}", operation
|
|
44
|
+
self.response = self.client.patch_raw(f"/discounts/{discount_id}", operation)
|
|
45
45
|
parser = ResponseParser(self.response)
|
|
46
46
|
|
|
47
47
|
return Discount.from_dict(parser.get_data())
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
from dataclasses import
|
|
1
|
+
from dataclasses import dataclass
|
|
2
2
|
|
|
3
|
+
from paddle_billing.Operation import Operation
|
|
3
4
|
from paddle_billing.Undefined import Undefined
|
|
5
|
+
from paddle_billing.Entities.DateTime import DateTime
|
|
4
6
|
from paddle_billing.Entities.Discounts import DiscountType
|
|
5
7
|
from paddle_billing.Entities.Shared import CurrencyCode, CustomData
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
@dataclass
|
|
9
|
-
class CreateDiscount:
|
|
11
|
+
class CreateDiscount(Operation):
|
|
10
12
|
amount: str
|
|
11
13
|
description: str
|
|
12
14
|
type: DiscountType
|
|
@@ -17,8 +19,5 @@ class CreateDiscount:
|
|
|
17
19
|
maximum_recurring_intervals: int | None | Undefined = Undefined()
|
|
18
20
|
usage_limit: int | None | Undefined = Undefined()
|
|
19
21
|
restrict_to: list[str] | None | Undefined = Undefined()
|
|
20
|
-
expires_at:
|
|
22
|
+
expires_at: DateTime | None | Undefined = Undefined()
|
|
21
23
|
custom_data: CustomData | None | Undefined = Undefined()
|
|
22
|
-
|
|
23
|
-
def get_parameters(self) -> dict:
|
|
24
|
-
return asdict(self)
|