Skip to content

Commit

Permalink
fix: Discount expires_at is now DateTime
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgrayston-paddle committed Nov 7, 2024
1 parent 2def986 commit 4822a70
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 8 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx&utm_medium=paddle-python-sdk) for information about changes to the Paddle Billing platform, the Paddle API, and other developer tools.

## 1.0.0 - 2024-11-07

### Changed

- `paddle_billing.Resources.Discounts.Operations.CreateDiscount` `expires_at` is now `paddle_billing.Entities.DateTime`
- `paddle_billing.Resources.Discounts.Operations.UpdateDiscount` `expires_at` is now `paddle_billing.Entities.DateTime`

## 0.3.2 - 2024-11-07

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion paddle_billing/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def build_request_session(self) -> Session:
"Authorization": f"Bearer {self.__api_key}",
"Content-Type": "application/json",
"Paddle-Version": str(self.use_api_version),
"User-Agent": "PaddleSDK/python 0.3.2",
"User-Agent": "PaddleSDK/python 1.0.0",
}
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from dataclasses import asdict, dataclass

from paddle_billing.Undefined import Undefined
from paddle_billing.Entities.DateTime import DateTime
from paddle_billing.Entities.Discounts import DiscountType
from paddle_billing.Entities.Shared import CurrencyCode, CustomData

Expand All @@ -17,7 +18,7 @@ class CreateDiscount:
maximum_recurring_intervals: int | None | Undefined = Undefined()
usage_limit: int | None | Undefined = Undefined()
restrict_to: list[str] | None | Undefined = Undefined()
expires_at: str | None | Undefined = Undefined()
expires_at: DateTime | None | Undefined = Undefined()
custom_data: CustomData | None | Undefined = Undefined()

def get_parameters(self) -> dict:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from dataclasses import asdict, dataclass

from paddle_billing.Undefined import Undefined
from paddle_billing.Entities.DateTime import DateTime
from paddle_billing.Entities.Discounts import DiscountStatus, DiscountType
from paddle_billing.Entities.Shared import CurrencyCode, CustomData

Expand All @@ -17,7 +18,7 @@ class UpdateDiscount:
maximum_recurring_intervals: int | None | Undefined = Undefined()
usage_limit: int | None | Undefined = Undefined()
restrict_to: list[str] | None | Undefined = Undefined()
expires_at: str | None | Undefined = Undefined()
expires_at: DateTime | None | Undefined = Undefined()
status: DiscountStatus | Undefined = Undefined()
custom_data: CustomData | None | Undefined = Undefined()

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


setup(
version="0.3.2",
version="1.0.0",
author="Paddle and contributors",
author_email="[email protected]",
description="Paddle's Python SDK for Paddle Billing",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"pro_01gsz4t5hdjse780zja8vvr7jg",
"pro_01gsz4s0w61y0pp88528f1wvvb"
],
"expires_at": "2025-01-01 10:00:00",
"expires_at": "2025-01-01T10:00:00.000000Z",
"custom_data": {
"key": "value"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"pro_01gsz4t5hdjse780zja8vvr7jg",
"pro_01gsz4s0w61y0pp88528f1wvvb"
],
"expires_at": "2025-01-01 10:00:00",
"expires_at": "2025-01-01T10:00:00.000000Z",
"status": "active",
"custom_data": {
"key": "value"
Expand Down
5 changes: 3 additions & 2 deletions tests/Functional/Resources/Discounts/test_DiscountsClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from urllib.parse import unquote

from paddle_billing.Entities.Collections import DiscountCollection
from paddle_billing.Entities.DateTime import DateTime
from paddle_billing.Entities.Discount import Discount
from paddle_billing.Entities.Discounts import DiscountStatus, DiscountType
from paddle_billing.Entities.Shared import CurrencyCode, Status, CustomData
Expand Down Expand Up @@ -43,7 +44,7 @@ class TestDiscountsClient:
maximum_recurring_intervals=5,
usage_limit=1000,
restrict_to=["pro_01gsz4t5hdjse780zja8vvr7jg", "pro_01gsz4s0w61y0pp88528f1wvvb"],
expires_at="2025-01-01 10:00:00",
expires_at=DateTime("2025-01-01 10:00:00"),
custom_data=CustomData({"key": "value"}),
),
ReadsFixtures.read_raw_json_fixture("request/create_full"),
Expand Down Expand Up @@ -144,7 +145,7 @@ def test_create_discount_response_has_custom_data(
code="ABCDE12345",
maximum_recurring_intervals=5,
usage_limit=1000,
expires_at="2025-01-01 10:00:00",
expires_at=DateTime("2025-01-01 10:00:00"),
status=DiscountStatus.Active,
restrict_to=[
"pro_01gsz4t5hdjse780zja8vvr7jg",
Expand Down

0 comments on commit 4822a70

Please sign in to comment.