Skip to content

Commit 8f70f6f

Browse files
authored
Feature: SDK-API sync (#44)
1 parent 79c1c5c commit 8f70f6f

24 files changed

+436
-146
lines changed

src/Entities/Price.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ private function __construct(
4242
public CustomData|null $customData,
4343
public ImportMeta|null $importMeta,
4444
public Product|null $product,
45+
public \DateTimeInterface $createdAt,
46+
public \DateTimeInterface $updatedAt,
4547
) {
4648
}
4749

@@ -66,6 +68,8 @@ public static function from(array $data): self
6668
customData: isset($data['custom_data']) ? new CustomData($data['custom_data']) : null,
6769
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null,
6870
product: isset($data['product']) ? Product::from($data['product']) : null,
71+
createdAt: DateTime::from($data['created_at']),
72+
updatedAt: DateTime::from($data['updated_at']),
6973
);
7074
}
7175
}

src/Entities/Product.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ private function __construct(
3131
public string|null $imageUrl,
3232
public CustomData|null $customData,
3333
public Status $status,
34-
public \DateTimeInterface|null $createdAt,
3534
public ImportMeta|null $importMeta,
3635
public array $prices,
36+
public \DateTimeInterface $createdAt,
37+
public \DateTimeInterface $updatedAt,
3738
) {
3839
}
3940

@@ -48,9 +49,10 @@ public static function from(array $data): self
4849
imageUrl: $data['image_url'] ?? null,
4950
customData: isset($data['custom_data']) ? new CustomData($data['custom_data']) : null,
5051
status: Status::from($data['status']),
51-
createdAt: isset($data['created_at']) ? DateTime::from($data['created_at']) : null,
5252
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null,
5353
prices: array_map(fn (array $price): Price => Price::from($price), $data['prices'] ?? []),
54+
createdAt: DateTime::from($data['created_at']),
55+
updatedAt: DateTime::from($data['updated_at']),
5456
);
5557
}
5658
}

src/Notifications/Entities/Price.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Paddle\SDK\Notifications\Entities;
1313

14+
use Paddle\SDK\Entities\DateTime;
1415
use Paddle\SDK\Notifications\Entities\Shared\CatalogType;
1516
use Paddle\SDK\Notifications\Entities\Shared\CustomData;
1617
use Paddle\SDK\Notifications\Entities\Shared\ImportMeta;
@@ -41,6 +42,8 @@ private function __construct(
4142
public Status $status,
4243
public CustomData|null $customData,
4344
public ImportMeta|null $importMeta,
45+
public \DateTimeInterface|null $createdAt,
46+
public \DateTimeInterface|null $updatedAt,
4447
) {
4548
}
4649

@@ -64,6 +67,8 @@ public static function from(array $data): self
6467
status: Status::from($data['status']),
6568
customData: isset($data['custom_data']) ? new CustomData($data['custom_data']) : null,
6669
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null,
70+
createdAt: isset($data['created_at']) ? DateTime::from($data['created_at']) : null,
71+
updatedAt: isset($data['updated_at']) ? DateTime::from($data['updated_at']) : null,
6772
);
6873
}
6974
}

src/Notifications/Entities/Product.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Paddle\SDK\Notifications\Entities;
1313

14+
use Paddle\SDK\Entities\DateTime;
1415
use Paddle\SDK\Notifications\Entities\Shared\CatalogType;
1516
use Paddle\SDK\Notifications\Entities\Shared\CustomData;
1617
use Paddle\SDK\Notifications\Entities\Shared\ImportMeta;
@@ -28,8 +29,9 @@ private function __construct(
2829
public string|null $imageUrl,
2930
public CustomData|null $customData,
3031
public Status $status,
31-
public \DateTimeInterface|null $createdAt,
3232
public ImportMeta|null $importMeta,
33+
public \DateTimeInterface|null $createdAt,
34+
public \DateTimeInterface|null $updatedAt,
3335
) {
3436
}
3537

@@ -44,8 +46,9 @@ public static function from(array $data): self
4446
imageUrl: $data['image_url'] ?? null,
4547
customData: isset($data['custom_data']) ? new CustomData($data['custom_data']) : null,
4648
status: Status::from($data['status']),
47-
createdAt: isset($data['created_at']) ? DateTime::from($data['created_at']) : null,
4849
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null,
50+
createdAt: isset($data['created_at']) ? DateTime::from($data['created_at']) : null,
51+
updatedAt: isset($data['updated_at']) ? DateTime::from($data['updated_at']) : null,
4952
);
5053
}
5154
}

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
{

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
}
1414
},
1515
"status": "active",
16-
"created_at": "2023-08-16T14:38:08.3Z"
16+
"created_at": "2023-08-16T14:38:08.3Z",
17+
"updated_at": "2023-08-16T14:38:08.3Z"
1718
},
1819
"meta": {
1920
"request_id": "ed738012-b8b3-4b4a-8761-ca708a01e400"

0 commit comments

Comments
 (0)