Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/refactor operation naming #5

Merged
merged 3 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ 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-php-sdk) for information about changes to the Paddle Billing platform, the Paddle API, and other developer tools.

## 0.1.1 - 2024-01-15
## [0.2.0] - 2024-01-22

### Changed

- Operations have been renamed to reduce import conflicts and the use of aliases
- Unused and abandoned dependency `php-http/message-factory` was removed

## [0.1.1] - 2024-01-15

### Fixed

Expand Down
10 changes: 5 additions & 5 deletions examples/catalog_management.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
// │ Create Product │
// └────────────────┘
try {
$product = $paddle->products->create(new Products\Operations\CreateOperation(
$product = $paddle->products->create(new Products\Operations\CreateProduct(
name: 'Kitten Service',
taxCategory: TaxCategory::Standard,
description: 'Simply an awesome product',
Expand All @@ -57,7 +57,7 @@
// ┌───
// │ Update Product │
// └────────────────┘
$update = new Products\Operations\UpdateOperation(
$update = new Products\Operations\UpdateProduct(
name: 'Bear Service',
imageUrl: 'https://placebear.com/200/300',
customData: new CustomData(['beep' => 'boop']),
Expand All @@ -76,7 +76,7 @@
// │ Create Price │
// └──────────────┘
try {
$price = $paddle->prices->create(new Prices\Operations\CreateOperation(
$price = $paddle->prices->create(new Prices\Operations\CreatePrice(
description: 'Bear Hug',
productId: $product->id,
unitPrice: new Money('1000', CurrencyCode::GBP),
Expand All @@ -101,7 +101,7 @@
// ┌───
// │ Update Price │
// └──────────────┘
$update = new Prices\Operations\UpdateOperation(
$update = new Prices\Operations\UpdatePrice(
description: 'One-off Bear Hug',
unitPrice: new Money('500', CurrencyCode::GBP),
customData: new CustomData(['beep' => 'boop']),
Expand Down Expand Up @@ -154,7 +154,7 @@
// │ Get Products │
// └──────────────┘
try {
$products = $paddle->products->list(new Products\Operations\ListOperation(
$products = $paddle->products->list(new Products\Operations\ListProducts(
includes: [ProductIncludes::Prices],
statuses: [Status::Active],
));
Expand Down
4 changes: 2 additions & 2 deletions examples/event_polling.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Paddle\SDK\Exceptions\ApiError;
use Paddle\SDK\Exceptions\SdkExceptions\MalformedResponse;
use Paddle\SDK\Resources\Events\Operations\ListOperation;
use Paddle\SDK\Resources\Events\Operations\ListEvents;
use Paddle\SDK\Resources\Shared\Operations\List\Pager;

require __DIR__ . '/../vendor/autoload.php';
Expand All @@ -25,7 +25,7 @@
$lastProcessedEventId = 'evt_01hfxx8t6ek9h399srcrp36jt3';

try {
$events = $paddle->events->list(new ListOperation(new Pager(after: $lastProcessedEventId)));
$events = $paddle->events->list(new ListEvents(new Pager(after: $lastProcessedEventId)));
} catch (ApiError|MalformedResponse $e) {
// Handle an error, terminate the poll
var_dump($e->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

class Client
{
private const SDK_VERSION = '0.1.1';
private const SDK_VERSION = '0.2.0';

public readonly LoggerInterface $logger;
public readonly Options $options;
Expand Down
14 changes: 7 additions & 7 deletions src/Resources/Addresses/AddressesClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
use Paddle\SDK\Entities\Shared\Status;
use Paddle\SDK\Exceptions\ApiError;
use Paddle\SDK\Exceptions\SdkExceptions\MalformedResponse;
use Paddle\SDK\Resources\Addresses\Operations\CreateOperation;
use Paddle\SDK\Resources\Addresses\Operations\ListOperation;
use Paddle\SDK\Resources\Addresses\Operations\UpdateOperation;
use Paddle\SDK\Resources\Addresses\Operations\CreateAddress;
use Paddle\SDK\Resources\Addresses\Operations\ListAddresses;
use Paddle\SDK\Resources\Addresses\Operations\UpdateAddress;
use Paddle\SDK\ResponseParser;

class AddressesClient
Expand All @@ -34,7 +34,7 @@ public function __construct(
* @throws ApiError On a generic API error
* @throws MalformedResponse If the API response was not parsable
*/
public function list(string $customerId, ListOperation $listOperation = new ListOperation()): AddressCollection
public function list(string $customerId, ListAddresses $listOperation = new ListAddresses()): AddressCollection
{
$parser = new ResponseParser(
$this->client->getRaw("/customers/{$customerId}/addresses", $listOperation),
Expand Down Expand Up @@ -64,7 +64,7 @@ public function get(string $customerId, string $id): Address
* @throws ApiError\AddressApiError On an address specific API error
* @throws MalformedResponse If the API response was not parsable
*/
public function create(string $customerId, CreateOperation $createOperation): Address
public function create(string $customerId, CreateAddress $createOperation): Address
{
$parser = new ResponseParser(
$this->client->postRaw("/customers/{$customerId}/addresses", $createOperation),
Expand All @@ -78,7 +78,7 @@ public function create(string $customerId, CreateOperation $createOperation): Ad
* @throws ApiError\AddressApiError On an address specific API error
* @throws MalformedResponse If the API response was not parsable
*/
public function update(string $customerId, string $id, UpdateOperation $operation): Address
public function update(string $customerId, string $id, UpdateAddress $operation): Address
{
$parser = new ResponseParser(
$this->client->patchRaw("/customers/{$customerId}/addresses/{$id}", $operation),
Expand All @@ -94,6 +94,6 @@ public function update(string $customerId, string $id, UpdateOperation $operatio
*/
public function archive(string $customerId, string $id): Address
{
return $this->update($customerId, $id, new UpdateOperation(status: Status::Archived));
return $this->update($customerId, $id, new UpdateAddress(status: Status::Archived));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Paddle\SDK\FiltersUndefined;
use Paddle\SDK\Undefined;

class CreateOperation implements \JsonSerializable
class CreateAddress implements \JsonSerializable
{
use FiltersUndefined;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Paddle\SDK\HasParameters;
use Paddle\SDK\Resources\Shared\Operations\List\Pager;

class ListOperation implements HasParameters
class ListAddresses implements HasParameters
{
public function __construct(
private readonly ?Pager $pager = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Paddle\SDK\FiltersUndefined;
use Paddle\SDK\Undefined;

class UpdateOperation implements \JsonSerializable
class UpdateAddress implements \JsonSerializable
{
use FiltersUndefined;

Expand Down
8 changes: 4 additions & 4 deletions src/Resources/Adjustments/AdjustmentsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
use Paddle\SDK\Entities\Collections\Paginator;
use Paddle\SDK\Exceptions\ApiError;
use Paddle\SDK\Exceptions\SdkExceptions\MalformedResponse;
use Paddle\SDK\Resources\Adjustments\Operations\CreateOperation;
use Paddle\SDK\Resources\Adjustments\Operations\ListOperation;
use Paddle\SDK\Resources\Adjustments\Operations\CreateAdjustment;
use Paddle\SDK\Resources\Adjustments\Operations\ListAdjustments;
use Paddle\SDK\ResponseParser;

class AdjustmentsClient
Expand All @@ -32,7 +32,7 @@ public function __construct(
* @throws ApiError On a generic API error
* @throws MalformedResponse If the API response was not parsable
*/
public function list(ListOperation $listOperation = new ListOperation()): AdjustmentsAdjustmentCollection
public function list(ListAdjustments $listOperation = new ListAdjustments()): AdjustmentsAdjustmentCollection
{
$parser = new ResponseParser(
$this->client->getRaw('/adjustments', $listOperation),
Expand All @@ -49,7 +49,7 @@ public function list(ListOperation $listOperation = new ListOperation()): Adjust
* @throws ApiError\AdjustmentApiError On an adjustment specific API error
* @throws MalformedResponse If the API response was not parsable
*/
public function create(CreateOperation $createOperation): Adjustment
public function create(CreateAdjustment $createOperation): Adjustment
{
$parser = new ResponseParser(
$this->client->postRaw('/adjustments', $createOperation),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Paddle\SDK\Entities\Adjustment\AdjustmentItem;
use Paddle\SDK\Entities\Shared\Action;

class CreateOperation implements \JsonSerializable
class CreateAdjustment implements \JsonSerializable
{
/**
* @param array<AdjustmentItem> $items
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Paddle\SDK\HasParameters;
use Paddle\SDK\Resources\Shared\Operations\List\Pager;

class ListOperation implements HasParameters
class ListAdjustments implements HasParameters
{
/**
* @param array<string> $ids
Expand Down
14 changes: 7 additions & 7 deletions src/Resources/Businesses/BusinessesClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
use Paddle\SDK\Entities\Shared\Status;
use Paddle\SDK\Exceptions\ApiError;
use Paddle\SDK\Exceptions\SdkExceptions\MalformedResponse;
use Paddle\SDK\Resources\Businesses\Operations\CreateOperation;
use Paddle\SDK\Resources\Businesses\Operations\ListOperation;
use Paddle\SDK\Resources\Businesses\Operations\UpdateOperation;
use Paddle\SDK\Resources\Businesses\Operations\CreateBusiness;
use Paddle\SDK\Resources\Businesses\Operations\ListBusinesses;
use Paddle\SDK\Resources\Businesses\Operations\UpdateBusiness;
use Paddle\SDK\ResponseParser;

class BusinessesClient
Expand All @@ -34,7 +34,7 @@ public function __construct(
* @throws ApiError On a generic API error
* @throws MalformedResponse If the API response was not parsable
*/
public function list(string $customerId, ListOperation $listOperation = new ListOperation()): BusinessCollection
public function list(string $customerId, ListBusinesses $listOperation = new ListBusinesses()): BusinessCollection
{
$parser = new ResponseParser(
$this->client->getRaw("/customers/{$customerId}/businesses", $listOperation),
Expand Down Expand Up @@ -64,7 +64,7 @@ public function get(string $customerId, string $id): Business
* @throws ApiError\BusinessApiError On an business specific API error
* @throws MalformedResponse If the API response was not parsable
*/
public function create(string $customerId, CreateOperation $createOperation): Business
public function create(string $customerId, CreateBusiness $createOperation): Business
{
$parser = new ResponseParser(
$this->client->postRaw("/customers/{$customerId}/businesses", $createOperation),
Expand All @@ -78,7 +78,7 @@ public function create(string $customerId, CreateOperation $createOperation): Bu
* @throws ApiError\BusinessApiError On an business specific API error
* @throws MalformedResponse If the API response was not parsable
*/
public function update(string $customerId, string $id, UpdateOperation $operation): Business
public function update(string $customerId, string $id, UpdateBusiness $operation): Business
{
$parser = new ResponseParser(
$this->client->patchRaw("/customers/{$customerId}/businesses/{$id}", $operation),
Expand All @@ -94,6 +94,6 @@ public function update(string $customerId, string $id, UpdateOperation $operatio
*/
public function archive(string $customerId, string $id): Business
{
return $this->update($customerId, $id, new UpdateOperation(status: Status::Archived));
return $this->update($customerId, $id, new UpdateBusiness(status: Status::Archived));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Paddle\SDK\FiltersUndefined;
use Paddle\SDK\Undefined;

class CreateOperation implements \JsonSerializable
class CreateBusiness implements \JsonSerializable
{
use FiltersUndefined;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Paddle\SDK\HasParameters;
use Paddle\SDK\Resources\Shared\Operations\List\Pager;

class ListOperation implements HasParameters
class ListBusinesses implements HasParameters
{
/**
* @param array<string> $ids
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Paddle\SDK\FiltersUndefined;
use Paddle\SDK\Undefined;

class UpdateOperation implements \JsonSerializable
class UpdateBusiness implements \JsonSerializable
{
use FiltersUndefined;

Expand Down
14 changes: 7 additions & 7 deletions src/Resources/Customers/CustomersClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
use Paddle\SDK\Entities\Shared\Status;
use Paddle\SDK\Exceptions\ApiError;
use Paddle\SDK\Exceptions\SdkExceptions\MalformedResponse;
use Paddle\SDK\Resources\Customers\Operations\CreateOperation;
use Paddle\SDK\Resources\Customers\Operations\ListOperation;
use Paddle\SDK\Resources\Customers\Operations\UpdateOperation;
use Paddle\SDK\Resources\Customers\Operations\CreateCustomer;
use Paddle\SDK\Resources\Customers\Operations\ListCustomers;
use Paddle\SDK\Resources\Customers\Operations\UpdateCustomer;
use Paddle\SDK\ResponseParser;

class CustomersClient
Expand All @@ -35,7 +35,7 @@ public function __construct(
* @throws ApiError On a generic API error
* @throws MalformedResponse If the API response was not parsable
*/
public function list(ListOperation $listOperation = new ListOperation()): CustomerCollection
public function list(ListCustomers $listOperation = new ListCustomers()): CustomerCollection
{
$parser = new ResponseParser(
$this->client->getRaw('/customers', $listOperation),
Expand Down Expand Up @@ -65,7 +65,7 @@ public function get(string $id): Customer
* @throws ApiError\CustomerApiError On a customer specific API error
* @throws MalformedResponse If the API response was not parsable
*/
public function create(CreateOperation $createOperation): Customer
public function create(CreateCustomer $createOperation): Customer
{
$parser = new ResponseParser(
$this->client->postRaw('/customers', $createOperation),
Expand All @@ -79,7 +79,7 @@ public function create(CreateOperation $createOperation): Customer
* @throws ApiError\CustomerApiError On a customer specific API error
* @throws MalformedResponse If the API response was not parsable
*/
public function update(string $id, UpdateOperation $operation): Customer
public function update(string $id, UpdateCustomer $operation): Customer
{
$parser = new ResponseParser(
$this->client->patchRaw("/customers/{$id}", $operation),
Expand All @@ -95,7 +95,7 @@ public function update(string $id, UpdateOperation $operation): Customer
*/
public function archive(string $id): Customer
{
return $this->update($id, new UpdateOperation(status: Status::Archived));
return $this->update($id, new UpdateCustomer(status: Status::Archived));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Paddle\SDK\FiltersUndefined;
use Paddle\SDK\Undefined;

class CreateOperation implements \JsonSerializable
class CreateCustomer implements \JsonSerializable
{
use FiltersUndefined;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Paddle\SDK\HasParameters;
use Paddle\SDK\Resources\Shared\Operations\List\Pager;

class ListOperation implements HasParameters
class ListCustomers implements HasParameters
{
/**
* @param array<string> $ids
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Paddle\SDK\FiltersUndefined;
use Paddle\SDK\Undefined;

class UpdateOperation implements \JsonSerializable
class UpdateCustomer implements \JsonSerializable
{
use FiltersUndefined;

Expand Down
Loading