Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.

Commit 9cc7515

Browse files
committed
paddle-php-sdk PR# 44 - Product and Prices entities now support created_at and updated_at fields
1 parent da5de43 commit 9cc7515

25 files changed

+438
-151
lines changed

paddle_billing/Entities/Price.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from __future__ import annotations
22
from dataclasses import dataclass
3+
from datetime import datetime
34

4-
from paddle_billing.Entities.Entity import Entity
5-
5+
from paddle_billing.Entities.Entity import Entity
66
from paddle_billing.Entities.Shared import (
77
CatalogType,
88
CustomData,
@@ -36,6 +36,8 @@ class Price(Entity):
3636
custom_data: CustomData | None
3737
import_meta: ImportMeta | None
3838
product: Product | None
39+
created_at: datetime
40+
updated_at: datetime
3941

4042

4143
@classmethod
@@ -49,6 +51,8 @@ def from_dict(cls, data: dict) -> Price:
4951
quantity = PriceQuantity.from_dict(data['quantity']),
5052
status = Status(data['status']),
5153
tax_mode = TaxMode(data.get('tax_mode')),
54+
created_at = datetime.fromisoformat(data['created_at']),
55+
updated_at = datetime.fromisoformat(data['updated_at']),
5256
unit_price_overrides = [UnitPriceOverride.from_dict(override) for override in data.get('unit_price_overrides', [])],
5357
type = CatalogType(data.get('type')) if data.get('type') else None,
5458
billing_cycle = TimePeriod.from_dict(data['billing_cycle']) if data.get('billing_cycle') else None,

paddle_billing/Entities/Product.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ class Product(Entity):
1212
name: str
1313
status: Status
1414
tax_category: TaxCategory
15+
created_at: datetime
16+
updated_at: datetime
1517
description: str | None
1618
image_url: str | None
17-
created_at: datetime | None = None
1819
custom_data: CustomData | None = None
1920
import_meta: ImportMeta | None = None
2021
prices: list[Price] | None = None
@@ -30,10 +31,11 @@ def from_dict(cls, data: dict) -> Product:
3031
name = data['name'],
3132
status = Status(data['status']),
3233
tax_category = TaxCategory(data['tax_category']),
34+
created_at = datetime.fromisoformat(data['created_at']),
35+
updated_at = datetime.fromisoformat(data['updated_at']),
3336
prices = [Price.from_dict(price) for price in data.get('prices', [])],
3437
type = CatalogType(data['type']) if data.get('type') else None,
3538
custom_data = CustomData(data['custom_data']) if data.get('custom_data') else None,
36-
created_at = datetime.fromisoformat(data['created_at']) if data.get('created_at') else None,
3739
import_meta = ImportMeta.from_dict(data['import_meta']) if data.get('import_meta') else None,
3840
)
3941

paddle_billing/Notifications/Entities/Price.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22
from dataclasses import dataclass
3+
from datetime import datetime
34

45
from paddle_billing.Notifications.Entities.Entity import Entity
56
from paddle_billing.Notifications.Entities.Shared import (
@@ -34,7 +35,8 @@ class Price(Entity):
3435
status: Status
3536
custom_data: CustomData | None
3637
import_meta: ImportMeta | None
37-
# product: Product | None
38+
created_at: datetime | None
39+
updated_at: datetime | None
3840

3941

4042
@classmethod
@@ -54,7 +56,8 @@ def from_dict(cls, data: dict) -> Price:
5456
trial_period = TimePeriod.from_dict(data['trial_period']) if data.get('trial_period') else None,
5557
custom_data = CustomData(data['custom_data']) if data.get('custom_data') else None,
5658
import_meta = ImportMeta.from_dict(data['import_meta']) if data.get('import_meta') else None,
57-
# product = Product.from_dict(data['product']) if data.get('product') else None,
59+
created_at = datetime.fromisoformat(data['created_at']) if data.get('created_at') else None,
60+
updated_at = datetime.fromisoformat(data['updated_at']) if data.get('updated_at') else None,
5861
)
5962

6063

paddle_billing/Notifications/Entities/Product.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ class Product(Entity):
1414
tax_category: TaxCategory
1515
description: str | None
1616
image_url: str | None
17-
created_at: datetime | None = None
1817
custom_data: CustomData | None = None
1918
import_meta: ImportMeta | None = None
2019
prices: list[Price] | None = None
2120
type: CatalogType | None = None
21+
created_at: datetime | None = None
22+
updated_at: datetime | None = None
2223

2324

2425
@classmethod
@@ -33,8 +34,9 @@ def from_dict(cls, data: dict) -> Product:
3334
prices = [Price.from_dict(price) for price in data.get('prices', [])],
3435
type = CatalogType(data['type']) if data.get('type') else None,
3536
custom_data = CustomData(data['custom_data']) if data.get('custom_data') else None,
36-
created_at = datetime.fromisoformat(data['created_at']) if data.get('created_at') else None,
3737
import_meta = ImportMeta.from_dict(data['import_meta']) if data.get('import_meta') else None,
38+
created_at = datetime.fromisoformat(data['created_at']) if data.get('created_at') else None,
39+
updated_at = datetime.fromisoformat(data['updated_at']) if data.get('updated_at') else None,
3840
)
3941

4042

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
setup(
5-
version = '0.1.0b1',
5+
version = '0.1.0b2',
66

77
author = 'Corey Regan',
88
author_email = 'regan.corey@gmail.com',

tests/Functional/Resources/Prices/_fixtures/response/full_entity.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
"quantity": {
3737
"minimum": 1,
3838
"maximum": 1
39-
}
39+
},
40+
"created_at": "2023-08-16T14:38:08.3Z",
41+
"updated_at": "2023-08-16T14:38:08.3Z"
4042
},
4143
"meta": {
4244
"request_id": "c5f89594-9551-47b5-a946-6030942b6080"

tests/Functional/Resources/Prices/_fixtures/response/full_entity_with_includes.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@
5656
"upgrade_description": "Move from Basic to Pro to take advantage of advanced reporting and a CRM that's right where you're chatting."
5757
},
5858
"status": "active",
59-
"created_at": "2023-02-23T12:43:46.605Z"
60-
}
59+
"created_at": "2023-08-16T14:38:08.3Z",
60+
"updated_at": "2023-08-16T14:38:08.3Z"
61+
},
62+
"created_at": "2023-08-16T14:38:08.3Z",
63+
"updated_at": "2023-08-16T14:38:08.3Z"
6164
},
6265
"meta": {
6366
"request_id": "aad79720-fb1b-4cf5-a770-15505251eb9e"

tests/Functional/Resources/Prices/_fixtures/response/list_default.json

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
"quantity": {
3838
"minimum": 1,
3939
"maximum": 1
40-
}
40+
},
41+
"created_at": "2023-08-16T14:38:08.3Z",
42+
"updated_at": "2023-08-16T14:38:08.3Z"
4143
},
4244
{
4345
"id": "pri_01he6fm50df5cjmwdy3v3p1z1t",
@@ -60,7 +62,9 @@
6062
"quantity": {
6163
"minimum": 1,
6264
"maximum": 100
63-
}
65+
},
66+
"created_at": "2023-08-16T14:38:08.3Z",
67+
"updated_at": "2023-08-16T14:38:08.3Z"
6468
},
6569
{
6670
"id": "pri_01he5kxqey1k8ankgef29cj4bv",
@@ -83,7 +87,9 @@
8387
"quantity": {
8488
"minimum": 1,
8589
"maximum": 100
86-
}
90+
},
91+
"created_at": "2023-08-16T14:38:08.3Z",
92+
"updated_at": "2023-08-16T14:38:08.3Z"
8793
},
8894
{
8995
"id": "pri_01h982194qx6az312q4jc7pb7y",
@@ -103,7 +109,9 @@
103109
"quantity": {
104110
"minimum": 1,
105111
"maximum": 100
106-
}
112+
},
113+
"created_at": "2023-08-16T14:38:08.3Z",
114+
"updated_at": "2023-08-16T14:38:08.3Z"
107115
},
108116
{
109117
"id": "pri_01h95tv9jar7paw64xf2f9vdpt",
@@ -123,7 +131,9 @@
123131
"quantity": {
124132
"minimum": 1,
125133
"maximum": 100
126-
}
134+
},
135+
"created_at": "2023-08-16T14:38:08.3Z",
136+
"updated_at": "2023-08-16T14:38:08.3Z"
127137
},
128138
{
129139
"id": "pri_01h1vjg3sqjj1y9tvazkdqe5vt",
@@ -146,7 +156,9 @@
146156
"quantity": {
147157
"minimum": 1,
148158
"maximum": 1
149-
}
159+
},
160+
"created_at": "2023-08-16T14:38:08.3Z",
161+
"updated_at": "2023-08-16T14:38:08.3Z"
150162
},
151163
{
152164
"id": "pri_01h1vjfevh5etwq3rb416a23h2",
@@ -181,7 +193,9 @@
181193
"quantity": {
182194
"minimum": 1,
183195
"maximum": 100
184-
}
196+
},
197+
"created_at": "2023-08-16T14:38:08.3Z",
198+
"updated_at": "2023-08-16T14:38:08.3Z"
185199
},
186200
{
187201
"id": "pri_01gvne87kv8vbqa9jkfbmgtsed",
@@ -204,7 +218,9 @@
204218
"quantity": {
205219
"minimum": 1,
206220
"maximum": 100
207-
}
221+
},
222+
"created_at": "2023-08-16T14:38:08.3Z",
223+
"updated_at": "2023-08-16T14:38:08.3Z"
208224
},
209225
{
210226
"id": "pri_01gsz98e27ak2tyhexptwc58yk",
@@ -234,7 +250,9 @@
234250
"quantity": {
235251
"minimum": 1,
236252
"maximum": 1
237-
}
253+
},
254+
"created_at": "2023-08-16T14:38:08.3Z",
255+
"updated_at": "2023-08-16T14:38:08.3Z"
238256
},
239257
{
240258
"id": "pri_01gsz96z29d88jrmsf2ztbfgjg",
@@ -257,7 +275,9 @@
257275
"quantity": {
258276
"minimum": 1,
259277
"maximum": 1
260-
}
278+
},
279+
"created_at": "2023-08-16T14:38:08.3Z",
280+
"updated_at": "2023-08-16T14:38:08.3Z"
261281
},
262282
{
263283
"id": "pri_01gsz95g2zrkagg294kpstx54r",
@@ -326,7 +346,9 @@
326346
"quantity": {
327347
"minimum": 1,
328348
"maximum": 1
329-
}
349+
},
350+
"created_at": "2023-08-16T14:38:08.3Z",
351+
"updated_at": "2023-08-16T14:38:08.3Z"
330352
},
331353
{
332354
"id": "pri_01gsz91wy9k1yn7kx82aafwvea",
@@ -349,7 +371,9 @@
349371
"quantity": {
350372
"minimum": 1,
351373
"maximum": 100
352-
}
374+
},
375+
"created_at": "2023-08-16T14:38:08.3Z",
376+
"updated_at": "2023-08-16T14:38:08.3Z"
353377
},
354378
{
355379
"id": "pri_01gsz8z1q1n00f12qt82y31smh",
@@ -383,7 +407,9 @@
383407
"quantity": {
384408
"minimum": 1,
385409
"maximum": 999
386-
}
410+
},
411+
"created_at": "2023-08-16T14:38:08.3Z",
412+
"updated_at": "2023-08-16T14:38:08.3Z"
387413
},
388414
{
389415
"id": "pri_01gsz8x8sawmvhz1pv30nge1ke",
@@ -427,7 +453,9 @@
427453
"quantity": {
428454
"minimum": 1,
429455
"maximum": 999
430-
}
456+
},
457+
"created_at": "2023-08-16T14:38:08.3Z",
458+
"updated_at": "2023-08-16T14:38:08.3Z"
431459
},
432460
{
433461
"id": "pri_01gsz8s48pyr4mbhvv2xfggesg",
@@ -496,7 +524,9 @@
496524
"quantity": {
497525
"minimum": 1,
498526
"maximum": 100
499-
}
527+
},
528+
"created_at": "2023-08-16T14:38:08.3Z",
529+
"updated_at": "2023-08-16T14:38:08.3Z"
500530
},
501531
{
502532
"id": "pri_01gsz8ntc6z7npqqp6j4ys0w1w",
@@ -519,7 +549,9 @@
519549
"quantity": {
520550
"minimum": 1,
521551
"maximum": 100
522-
}
552+
},
553+
"created_at": "2023-08-16T14:38:08.3Z",
554+
"updated_at": "2023-08-16T14:38:08.3Z"
523555
}
524556
],
525557
"meta": {

tests/Functional/Resources/Prices/_fixtures/response/minimal_entity.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
"quantity": {
2121
"minimum": 1,
2222
"maximum": 100
23-
}
23+
},
24+
"created_at": "2023-08-16T14:38:08.3Z",
25+
"updated_at": "2023-08-16T14:38:08.3Z"
2426
},
2527
"meta": {
2628
"request_id": "119db08f-5a82-4993-9dfa-72ec694af98b"

tests/Functional/Resources/PricingPreviews/_fixtures/response/full_entity.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
"maximum": 999
3535
},
3636
"status": "active",
37-
"custom_data": null
37+
"custom_data": null,
38+
"created_at": "2023-08-16T14:38:08.3Z",
39+
"updated_at": "2023-08-16T14:38:08.3Z"
3840
},
3941
"quantity": 20,
4042
"tax_rate": "0",
@@ -69,7 +71,9 @@
6971
"tax_category": "standard",
7072
"image_url": "https://paddle-sandbox.s3.amazonaws.com/user/10889/2nmP8MQSret0aWeDemRw_icon1.png",
7173
"status": "active",
72-
"custom_data": null
74+
"custom_data": null,
75+
"created_at": "2023-08-16T14:38:08.3Z",
76+
"updated_at": "2023-08-16T14:38:08.3Z"
7377
},
7478
"discounts": [
7579
{
@@ -123,7 +127,9 @@
123127
"maximum": 1
124128
},
125129
"status": "active",
126-
"custom_data": null
130+
"custom_data": null,
131+
"created_at": "2023-08-16T14:38:08.3Z",
132+
"updated_at": "2023-08-16T14:38:08.3Z"
127133
},
128134
"quantity": 1,
129135
"tax_rate": "0",
@@ -158,7 +164,9 @@
158164
"tax_category": "standard",
159165
"image_url": "https://paddle-sandbox.s3.amazonaws.com/user/10889/SW3OevDQ92dUHSkN5a2x_icon3.png",
160166
"status": "active",
161-
"custom_data": null
167+
"custom_data": null,
168+
"created_at": "2023-08-16T14:38:08.3Z",
169+
"updated_at": "2023-08-16T14:38:08.3Z"
162170
},
163171
"discounts": [
164172
{

0 commit comments

Comments
 (0)