Skip to content

Commit

Permalink
Feature: SDK-API sync (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
vifer authored Mar 13, 2024
1 parent 79c1c5c commit 8f70f6f
Show file tree
Hide file tree
Showing 24 changed files with 436 additions and 146 deletions.
4 changes: 4 additions & 0 deletions src/Entities/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ private function __construct(
public CustomData|null $customData,
public ImportMeta|null $importMeta,
public Product|null $product,
public \DateTimeInterface $createdAt,
public \DateTimeInterface $updatedAt,
) {
}

Expand All @@ -66,6 +68,8 @@ public static function from(array $data): self
customData: isset($data['custom_data']) ? new CustomData($data['custom_data']) : null,
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null,
product: isset($data['product']) ? Product::from($data['product']) : null,
createdAt: DateTime::from($data['created_at']),
updatedAt: DateTime::from($data['updated_at']),
);
}
}
6 changes: 4 additions & 2 deletions src/Entities/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ private function __construct(
public string|null $imageUrl,
public CustomData|null $customData,
public Status $status,
public \DateTimeInterface|null $createdAt,
public ImportMeta|null $importMeta,
public array $prices,
public \DateTimeInterface $createdAt,
public \DateTimeInterface $updatedAt,
) {
}

Expand All @@ -48,9 +49,10 @@ public static function from(array $data): self
imageUrl: $data['image_url'] ?? null,
customData: isset($data['custom_data']) ? new CustomData($data['custom_data']) : null,
status: Status::from($data['status']),
createdAt: isset($data['created_at']) ? DateTime::from($data['created_at']) : null,
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null,
prices: array_map(fn (array $price): Price => Price::from($price), $data['prices'] ?? []),
createdAt: DateTime::from($data['created_at']),
updatedAt: DateTime::from($data['updated_at']),
);
}
}
5 changes: 5 additions & 0 deletions src/Notifications/Entities/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Paddle\SDK\Notifications\Entities;

use Paddle\SDK\Entities\DateTime;
use Paddle\SDK\Notifications\Entities\Shared\CatalogType;
use Paddle\SDK\Notifications\Entities\Shared\CustomData;
use Paddle\SDK\Notifications\Entities\Shared\ImportMeta;
Expand Down Expand Up @@ -41,6 +42,8 @@ private function __construct(
public Status $status,
public CustomData|null $customData,
public ImportMeta|null $importMeta,
public \DateTimeInterface|null $createdAt,
public \DateTimeInterface|null $updatedAt,
) {
}

Expand All @@ -64,6 +67,8 @@ public static function from(array $data): self
status: Status::from($data['status']),
customData: isset($data['custom_data']) ? new CustomData($data['custom_data']) : null,
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null,
createdAt: isset($data['created_at']) ? DateTime::from($data['created_at']) : null,
updatedAt: isset($data['updated_at']) ? DateTime::from($data['updated_at']) : null,
);
}
}
7 changes: 5 additions & 2 deletions src/Notifications/Entities/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Paddle\SDK\Notifications\Entities;

use Paddle\SDK\Entities\DateTime;
use Paddle\SDK\Notifications\Entities\Shared\CatalogType;
use Paddle\SDK\Notifications\Entities\Shared\CustomData;
use Paddle\SDK\Notifications\Entities\Shared\ImportMeta;
Expand All @@ -28,8 +29,9 @@ private function __construct(
public string|null $imageUrl,
public CustomData|null $customData,
public Status $status,
public \DateTimeInterface|null $createdAt,
public ImportMeta|null $importMeta,
public \DateTimeInterface|null $createdAt,
public \DateTimeInterface|null $updatedAt,
) {
}

Expand All @@ -44,8 +46,9 @@ public static function from(array $data): self
imageUrl: $data['image_url'] ?? null,
customData: isset($data['custom_data']) ? new CustomData($data['custom_data']) : null,
status: Status::from($data['status']),
createdAt: isset($data['created_at']) ? DateTime::from($data['created_at']) : null,
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null,
createdAt: isset($data['created_at']) ? DateTime::from($data['created_at']) : null,
updatedAt: isset($data['updated_at']) ? DateTime::from($data['updated_at']) : null,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
"quantity": {
"minimum": 1,
"maximum": 1
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
"meta": {
"request_id": "c5f89594-9551-47b5-a946-6030942b6080"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@
"upgrade_description": "Move from Basic to Pro to take advantage of advanced reporting and a CRM that's right where you're chatting."
},
"status": "active",
"created_at": "2023-02-23T12:43:46.605Z"
}
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
"meta": {
"request_id": "aad79720-fb1b-4cf5-a770-15505251eb9e"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
"quantity": {
"minimum": 1,
"maximum": 1
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
{
"id": "pri_01he6fm50df5cjmwdy3v3p1z1t",
Expand All @@ -60,7 +62,9 @@
"quantity": {
"minimum": 1,
"maximum": 100
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
{
"id": "pri_01he5kxqey1k8ankgef29cj4bv",
Expand All @@ -83,7 +87,9 @@
"quantity": {
"minimum": 1,
"maximum": 100
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
{
"id": "pri_01h982194qx6az312q4jc7pb7y",
Expand All @@ -103,7 +109,9 @@
"quantity": {
"minimum": 1,
"maximum": 100
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
{
"id": "pri_01h95tv9jar7paw64xf2f9vdpt",
Expand All @@ -123,7 +131,9 @@
"quantity": {
"minimum": 1,
"maximum": 100
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
{
"id": "pri_01h1vjg3sqjj1y9tvazkdqe5vt",
Expand All @@ -146,7 +156,9 @@
"quantity": {
"minimum": 1,
"maximum": 1
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
{
"id": "pri_01h1vjfevh5etwq3rb416a23h2",
Expand Down Expand Up @@ -181,7 +193,9 @@
"quantity": {
"minimum": 1,
"maximum": 100
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
{
"id": "pri_01gvne87kv8vbqa9jkfbmgtsed",
Expand All @@ -204,7 +218,9 @@
"quantity": {
"minimum": 1,
"maximum": 100
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
{
"id": "pri_01gsz98e27ak2tyhexptwc58yk",
Expand Down Expand Up @@ -234,7 +250,9 @@
"quantity": {
"minimum": 1,
"maximum": 1
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
{
"id": "pri_01gsz96z29d88jrmsf2ztbfgjg",
Expand All @@ -257,7 +275,9 @@
"quantity": {
"minimum": 1,
"maximum": 1
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
{
"id": "pri_01gsz95g2zrkagg294kpstx54r",
Expand Down Expand Up @@ -326,7 +346,9 @@
"quantity": {
"minimum": 1,
"maximum": 1
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
{
"id": "pri_01gsz91wy9k1yn7kx82aafwvea",
Expand All @@ -349,7 +371,9 @@
"quantity": {
"minimum": 1,
"maximum": 100
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
{
"id": "pri_01gsz8z1q1n00f12qt82y31smh",
Expand Down Expand Up @@ -383,7 +407,9 @@
"quantity": {
"minimum": 1,
"maximum": 999
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
{
"id": "pri_01gsz8x8sawmvhz1pv30nge1ke",
Expand Down Expand Up @@ -427,7 +453,9 @@
"quantity": {
"minimum": 1,
"maximum": 999
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
{
"id": "pri_01gsz8s48pyr4mbhvv2xfggesg",
Expand Down Expand Up @@ -496,7 +524,9 @@
"quantity": {
"minimum": 1,
"maximum": 100
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
{
"id": "pri_01gsz8ntc6z7npqqp6j4ys0w1w",
Expand All @@ -519,7 +549,9 @@
"quantity": {
"minimum": 1,
"maximum": 100
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
}
],
"meta": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"quantity": {
"minimum": 1,
"maximum": 100
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
"meta": {
"request_id": "119db08f-5a82-4993-9dfa-72ec694af98b"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
"maximum": 999
},
"status": "active",
"custom_data": null
"custom_data": null,
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
"quantity": 20,
"tax_rate": "0",
Expand Down Expand Up @@ -69,7 +71,9 @@
"tax_category": "standard",
"image_url": "https://paddle-sandbox.s3.amazonaws.com/user/10889/2nmP8MQSret0aWeDemRw_icon1.png",
"status": "active",
"custom_data": null
"custom_data": null,
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
"discounts": [
{
Expand Down Expand Up @@ -123,7 +127,9 @@
"maximum": 1
},
"status": "active",
"custom_data": null
"custom_data": null,
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
"quantity": 1,
"tax_rate": "0",
Expand Down Expand Up @@ -158,7 +164,9 @@
"tax_category": "standard",
"image_url": "https://paddle-sandbox.s3.amazonaws.com/user/10889/SW3OevDQ92dUHSkN5a2x_icon3.png",
"status": "active",
"custom_data": null
"custom_data": null,
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
"discounts": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
}
},
"status": "active",
"created_at": "2023-08-16T14:38:08.3Z"
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
},
"meta": {
"request_id": "ed738012-b8b3-4b4a-8761-ca708a01e400"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"status": "active",
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z",
"prices": [
{
"id": "pri_01he5kxqey1k8ankgef29cj4bv",
Expand All @@ -36,7 +37,9 @@
"quantity": {
"minimum": 1,
"maximum": 100
}
},
"created_at": "2023-08-16T14:38:08.3Z",
"updated_at": "2023-08-16T14:38:08.3Z"
}
]
},
Expand Down
Loading

0 comments on commit 8f70f6f

Please sign in to comment.