Skip to content

Commit 21831c8

Browse files
authored
Sync API spec with SDK (#7)
1 parent 551ded5 commit 21831c8

29 files changed

+158
-18
lines changed

CHANGELOG.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88
99
Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx&utm_medium=paddle-php-sdk) for information about changes to the Paddle Billing platform, the Paddle API, and other developer tools.
1010

11+
## [0.2.1] - 2024-01-24
12+
13+
### Added
14+
15+
- Added `importMeta` to product, price, address, business, customer, discount and subscription entities
16+
- Added `creditToBalance` to `transaction.details.payoutTotals` and `transaction.details.totals`
17+
- Added `origin` query parameter to list transactions, see [related changelog](https://developer.paddle.com/changelog/2023/filter-transactions-origin?utm_source=dx&utm_medium=paddle-php-sdk).
18+
- Added `available_payment_methods` to transaction with includes entity
19+
- Added `email` query parameter to list customers, see [related changelog](https://developer.paddle.com/changelog/2024/filter-customers-email#filter-customers-by-email-address?utm_source=dx&utm_medium=paddle-php-sdk)
20+
1121
## [0.2.0] - 2024-01-23
1222

1323
### Changed
@@ -25,10 +35,10 @@ Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx
2535

2636
### Added
2737

28-
- Added `available_payment_methods` to [transaction preview and pricing preview](https://developer.paddle.com/changelog/2023/available-payment-methods?utm_source=dx&utm_medium=paddle-node-sdk)
29-
- Added non-catalog items to [subscriptions](https://developer.paddle.com/changelog/2023/bill-custom-items-one-time-subscription-charge?utm_source=dx&utm_medium=paddle-node-sdk)
30-
- Added non catalog items to [transactions](https://developer.paddle.com/changelog/2023/add-custom-items-transaction?utm_source=dx&utm_medium=paddle-node-sdk)
31-
- Added `on_payment_failure` to [subscriptions](https://developer.paddle.com/changelog/2023/payment-failure-behavior-update-subscription?utm_source=dx&utm_medium=paddle-node-sdk)
38+
- Added `available_payment_methods` to [transaction preview and pricing preview](https://developer.paddle.com/changelog/2023/available-payment-methods?utm_source=dx&utm_medium=paddle-php-sdk)
39+
- Added non-catalog items to [subscriptions](https://developer.paddle.com/changelog/2023/bill-custom-items-one-time-subscription-charge?utm_source=dx&utm_medium=paddle-php-sdk)
40+
- Added non catalog items to [transactions](https://developer.paddle.com/changelog/2023/add-custom-items-transaction?utm_source=dx&utm_medium=paddle-php-sdk)
41+
- Added `on_payment_failure` to [subscriptions](https://developer.paddle.com/changelog/2023/payment-failure-behavior-update-subscription?utm_source=dx&utm_medium=paddle-php-sdk)
3242

3343
### Fixed
3444

src/Client.php

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

5252
class Client
5353
{
54-
private const SDK_VERSION = '0.2.0';
54+
private const SDK_VERSION = '0.2.1';
5555

5656
public readonly LoggerInterface $logger;
5757
public readonly Options $options;

src/Entities/Address.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Paddle\SDK\Entities\Shared\CountryCode;
1515
use Paddle\SDK\Entities\Shared\CustomData;
16+
use Paddle\SDK\Entities\Shared\ImportMeta;
1617
use Paddle\SDK\Entities\Shared\Status;
1718

1819
class Address implements Entity
@@ -30,6 +31,7 @@ public function __construct(
3031
public Status $status,
3132
public \DateTimeInterface $createdAt,
3233
public \DateTimeInterface $updatedAt,
34+
public ImportMeta|null $importMeta,
3335
) {
3436
}
3537

@@ -48,6 +50,7 @@ public static function from(array $data): self
4850
status: Status::from($data['status']),
4951
createdAt: DateTime::from($data['created_at']),
5052
updatedAt: DateTime::from($data['updated_at']),
53+
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null,
5154
);
5255
}
5356
}

src/Entities/Business.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Paddle\SDK\Entities\Shared\Contacts;
1515
use Paddle\SDK\Entities\Shared\CustomData;
16+
use Paddle\SDK\Entities\Shared\ImportMeta;
1617
use Paddle\SDK\Entities\Shared\Status;
1718

1819
class Business implements Entity
@@ -30,6 +31,7 @@ public function __construct(
3031
public \DateTimeInterface $createdAt,
3132
public \DateTimeInterface $updatedAt,
3233
public CustomData|null $customData,
34+
public ImportMeta|null $importMeta,
3335
) {
3436
}
3537

@@ -45,6 +47,7 @@ public static function from(array $data): self
4547
createdAt: DateTime::from($data['created_at']),
4648
updatedAt: DateTime::from($data['updated_at']),
4749
customData: isset($data['custom_data']) ? new CustomData($data['custom_data']) : null,
50+
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null,
4851
);
4952
}
5053
}

src/Entities/Customer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Paddle\SDK\Entities;
1313

1414
use Paddle\SDK\Entities\Shared\CustomData;
15+
use Paddle\SDK\Entities\Shared\ImportMeta;
1516
use Paddle\SDK\Entities\Shared\Status;
1617

1718
class Customer implements Entity
@@ -26,6 +27,7 @@ public function __construct(
2627
public string $locale,
2728
public \DateTimeInterface $createdAt,
2829
public \DateTimeInterface $updatedAt,
30+
public ImportMeta|null $importMeta,
2931
) {
3032
}
3133

@@ -41,6 +43,7 @@ public static function from(array $data): self
4143
locale: $data['locale'],
4244
createdAt: DateTime::from($data['created_at']),
4345
updatedAt: DateTime::from($data['updated_at']),
46+
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null,
4447
);
4548
}
4649
}

src/Entities/Discount.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Paddle\SDK\Entities\Discount\DiscountStatus;
1515
use Paddle\SDK\Entities\Discount\DiscountType;
1616
use Paddle\SDK\Entities\Shared\CurrencyCode;
17+
use Paddle\SDK\Entities\Shared\ImportMeta;
1718

1819
class Discount implements Entity
1920
{
@@ -34,6 +35,7 @@ public function __construct(
3435
public int $timesUsed,
3536
public \DateTimeInterface $createdAt,
3637
public \DateTimeInterface $updatedAt,
38+
public ImportMeta|null $importMeta,
3739
) {
3840
}
3941

@@ -56,6 +58,7 @@ public static function from(array $data): self
5658
timesUsed: $data['times_used'],
5759
createdAt: DateTime::from($data['created_at']),
5860
updatedAt: DateTime::from($data['updated_at']),
61+
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null,
5962
);
6063
}
6164
}

src/Entities/Price.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Paddle\SDK\Entities\Shared\CatalogType;
1515
use Paddle\SDK\Entities\Shared\CustomData;
16+
use Paddle\SDK\Entities\Shared\ImportMeta;
1617
use Paddle\SDK\Entities\Shared\Money;
1718
use Paddle\SDK\Entities\Shared\PriceQuantity;
1819
use Paddle\SDK\Entities\Shared\Status;
@@ -39,6 +40,7 @@ public function __construct(
3940
public PriceQuantity $quantity,
4041
public Status $status,
4142
public CustomData|null $customData,
43+
public ImportMeta|null $importMeta,
4244
) {
4345
}
4446

@@ -61,6 +63,7 @@ public static function from(array $data): self
6163
quantity: PriceQuantity::from($data['quantity']),
6264
status: Status::from($data['status']),
6365
customData: isset($data['custom_data']) ? new CustomData($data['custom_data']) : null,
66+
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null,
6467
);
6568
}
6669
}

src/Entities/Product.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Paddle\SDK\Entities\Shared\CatalogType;
1515
use Paddle\SDK\Entities\Shared\CustomData;
16+
use Paddle\SDK\Entities\Shared\ImportMeta;
1617
use Paddle\SDK\Entities\Shared\Status;
1718
use Paddle\SDK\Entities\Shared\TaxCategory;
1819

@@ -28,6 +29,7 @@ public function __construct(
2829
public CustomData|null $customData,
2930
public Status $status,
3031
public \DateTimeInterface|null $createdAt,
32+
public ImportMeta|null $importMeta,
3133
) {
3234
}
3335

@@ -43,6 +45,7 @@ public static function from(array $data): self
4345
customData: isset($data['custom_data']) ? new CustomData($data['custom_data']) : null,
4446
status: Status::from($data['status']),
4547
createdAt: isset($data['created_at']) ? DateTime::from($data['created_at']) : null,
48+
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null,
4649
);
4750
}
4851
}

src/Entities/Shared/ImportMeta.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* |------
7+
* | ! Generated code !
8+
* | Altering this code will result in changes being overwritten |
9+
* |-------------------------------------------------------------|.
10+
*/
11+
12+
namespace Paddle\SDK\Entities\Shared;
13+
14+
class ImportMeta
15+
{
16+
public function __construct(
17+
public readonly string|null $externalId,
18+
public readonly string $importedFrom,
19+
) {
20+
}
21+
22+
public static function from(array $data): self
23+
{
24+
return new self(
25+
externalId: $data['external_id'] ?? null,
26+
importedFrom: $data['imported_from'],
27+
);
28+
}
29+
}

src/Entities/Shared/TransactionPayoutTotals.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,24 @@ public function __construct(
2424
public string $fee,
2525
public string $earnings,
2626
public CurrencyCodePayouts $currencyCode,
27+
public string $creditToBalance,
2728
) {
2829
}
2930

3031
public static function from(array $data): self
3132
{
3233
return new self(
33-
$data['subtotal'],
34-
$data['discount'],
35-
$data['tax'],
36-
$data['total'],
37-
$data['credit'],
38-
$data['balance'],
39-
$data['grand_total'],
40-
$data['fee'] ?? null,
41-
$data['earnings'] ?? null,
42-
CurrencyCodePayouts::from($data['currency_code']),
34+
subtotal: $data['subtotal'],
35+
discount: $data['discount'],
36+
tax: $data['tax'],
37+
total: $data['total'],
38+
credit: $data['credit'],
39+
balance: $data['balance'],
40+
grandTotal: $data['grand_total'],
41+
fee: $data['fee'] ?? null,
42+
earnings: $data['earnings'] ?? null,
43+
currencyCode: CurrencyCodePayouts::from($data['currency_code']),
44+
creditToBalance: $data['credit_to_balance'],
4345
);
4446
}
4547
}

0 commit comments

Comments
 (0)