update resources

Signed-off-by: Maurice Preuß (envoyr) <hello@envoyr.com>
This commit is contained in:
2025-05-02 06:27:53 +02:00
parent 1725ec68de
commit 1d2119a32b
33 changed files with 303 additions and 320 deletions

View File

@@ -3,9 +3,7 @@
namespace Anikeen\Id\Resources;
use Anikeen\Id\Concerns\HasBillable;
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
use Anikeen\Id\Result;
use GuzzleHttp\Exception\GuzzleException;
use Throwable;
/**
* @property string $id
@@ -63,20 +61,18 @@ class Address extends BaseResource
* - email: Email address (optional, e.g. for delivery notifications)
* - primary: Whether this address should be the primary address (optional)
* - primary_billing_address: Whether this address should be the primary billing address (optional)
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function update(array $attributes = []): self
{
return (new self($this->billable->request('PUT', sprintf('v1/addresses/%s', $this->id), $attributes)))
return (new self(fn() => $this->billable->request('PUT', sprintf('v1/addresses/%s', $this->id), $attributes)))
->setBillable($this->billable);
}
/**
* Delete given address from the current user.
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function delete(): bool
{

View File

@@ -3,9 +3,7 @@
namespace Anikeen\Id\Resources;
use Anikeen\Id\Concerns\HasBillable;
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
use Anikeen\Id\Result;
use GuzzleHttp\Exception\GuzzleException;
use Throwable;
class Addresses extends BaseCollection
{
@@ -44,12 +42,11 @@ class Addresses extends BaseCollection
*   - email: Email address (optional, e.g. for delivery notifications)
*   - primary: Whether this address should be the primary address (optional)
*   - primary_billing_address: Whether this address should be the primary billing address (optional)
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function create(array $attributes = []): Address
{
return (new Address($this->billable->request('POST', 'v1/addresses', $attributes)))
return (new Address(fn() => $this->billable->request('POST', 'v1/addresses', $attributes)))
->setBillable($this->billable);
}
@@ -58,31 +55,25 @@ class Addresses extends BaseCollection
*/
public function find(string $id): ?Address
{
$result = $this->billable->request('GET', sprintf('v1/addresses/%s', $id));
return $result->success() ?
(new Address($result))
->setBillable($this->billable)
: null;
return (new Address(fn() => $this->billable->request('GET', sprintf('v1/addresses/%s', $id))))
->setBillable($this->billable);
}
/**
* Get default address from the current user.
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function defaultBillingAddress(): Address
{
return (new Address($this->billable->request('GET', sprintf('v1/addresses/%s', $this->billable->getUserData()->billing_address_id))))
return (new Address(fn() => $this->billable->request('GET', sprintf('v1/addresses/%s', $this->billable->getUserData()->billing_address_id))))
->setBillable($this->billable);
}
/**
* Check if the current user has a default billing address.
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function hasDefaultBillingAddress(): bool
{

View File

@@ -2,17 +2,51 @@
namespace Anikeen\Id\Resources;
use Anikeen\Id\Concerns\MagicProperties;
use Anikeen\Id\AnikeenId;
use Anikeen\Id\Exceptions\CollectionException;
use Anikeen\Id\Exceptions\ResourceException;
use Anikeen\Id\Helpers\Paginator;
use Anikeen\Id\Result;
use Closure;
use GuzzleHttp\Psr7\Response;
use JsonSerializable;
use Throwable;
/**
* @property bool $success
* @property mixed $data
* @property int $total
* @property int $status
* @property null|array $links
* @property null|array $meta
* @property null|Paginator $paginator
* @property AnikeenId $anikeenId
* @property Response $response
* @property null|Throwable $exception
*/
abstract class BaseCollection implements JsonSerializable
{
use MagicProperties;
private Closure $callable;
public ?Result $result = null;
public function __construct(protected Result $result)
/**
* @throws CollectionException
*/
protected function __construct(callable $callable)
{
//
$this->result = $callable();
if (!$this->result->success()) {
throw new CollectionException(sprintf('%s for collection [%s]', rtrim($this->result->data->message, '.'), get_called_class()), $this->result->response->getStatusCode());
}
}
/**
* @throws CollectionException
*/
public static function builder(callable $callable): static
{
return new static($callable, false);
}
/**
@@ -43,4 +77,14 @@ abstract class BaseCollection implements JsonSerializable
* Returns the Resource based on the ID.
*/
abstract public function find(string $id): ?BaseResource;
public function __get(string $name)
{
return $this->result->{$name} ?? null;
}
public function __isset(string $name): bool
{
return isset($this->result->{$name});
}
}

View File

@@ -2,17 +2,38 @@
namespace Anikeen\Id\Resources;
use Anikeen\Id\Concerns\MagicProperties;
use Anikeen\Id\Exceptions\ResourceException;
use Anikeen\Id\Result;
use JsonSerializable;
abstract class BaseResource implements JsonSerializable
{
use MagicProperties;
public Result $result;
public function __construct(protected Result $result)
/**
* @throws ResourceException
*/
public function __construct(callable $callable)
{
$this->setMagicProperties($this->result->data);
$this->result = $callable();
if (!$this->result->success()) {
throw new ResourceException(sprintf('%s for resource [%s]', rtrim($this->result->data->message, '.'), get_called_class()), $this->result->response->getStatusCode());
}
foreach ($this->result->data as $key => $value) {
if (!property_exists($this, $key)) {
$this->{$key} = $value;
}
}
}
/**
* Returns the collection of resources as a JSON string.
*/
public function jsonSerialize(): array
{
return $this->toArray();
}
/**
@@ -23,11 +44,13 @@ abstract class BaseResource implements JsonSerializable
return (array)$this->result->data;
}
/**
* Returns the collection of resources as a JSON string.
*/
public function jsonSerialize(): array
public function __get(string $name)
{
return $this->toArray();
return null;
}
public function __isset(string $name): bool
{
return false;
}
}

View File

@@ -3,8 +3,7 @@
namespace Anikeen\Id\Resources;
use Anikeen\Id\Concerns\HasBillable;
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
use GuzzleHttp\Exception\GuzzleException;
use Throwable;
/**
* @property string $id
@@ -16,8 +15,7 @@ class Invoice extends BaseResource
/**
* Get temporary download url from given invoice.
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function getInvoiceTemporaryUrl(): string
{

View File

@@ -3,9 +3,6 @@
namespace Anikeen\Id\Resources;
use Anikeen\Id\Concerns\HasBillable;
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
use Anikeen\Id\Result;
use GuzzleHttp\Exception\GuzzleException;
class Invoices extends BaseCollection
{
@@ -16,11 +13,7 @@ class Invoices extends BaseCollection
*/
public function find(string $id): ?Invoice
{
$result = $this->billable->request('GET', sprintf('v1/invoices/%s', $id));
return $result->success()
? (new Invoice($result))
->setBillable($this->billable)
: null;
return (new Invoice(fn() => $this->billable->request('GET', sprintf('v1/invoices/%s', $id))))
->setBillable($this->billable);
}
}

View File

@@ -3,8 +3,7 @@
namespace Anikeen\Id\Resources;
use Anikeen\Id\Concerns\HasBillable;
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
use GuzzleHttp\Exception\GuzzleException;
use Throwable;
/**
* @property string $id
@@ -55,44 +54,40 @@ class Order extends BaseResource
* } $attributes The order data:
* - billing_address: Billing address (ISO 3166-1 alpha-2 country code)
* - shipping_address: Shipping address (first name, last name, ISO 3166-1 alpha-2 country code)
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function update(array $attributes = []): self
{
return (new self($this->billable->request('PUT', sprintf('v1/orders/%s', $this->id), $attributes)))
return (new self(fn() => $this->billable->request('PUT', sprintf('v1/orders/%s', $this->id), $attributes)))
->setBillable($this->billable);
}
/**
* Checkout given order from the current user.
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function checkout(string $orderId): self
public function checkout(): self
{
return (new self($this->billable->request('PUT', sprintf('v1/orders/%s/checkout', $this->id))))
return (new self(fn() => $this->billable->request('PUT', sprintf('v1/orders/%s/checkout', $this->id))))
->setBillable($this->billable);
}
/**
* Revoke given order from the current user.
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function revoke(string $orderId): self
public function revoke(): self
{
return (new self($this->billable->request('PUT', sprintf('v1/orders/%s/revoke', $this->id))))
return (new self(fn() => $this->billable->request('PUT', sprintf('v1/orders/%s/revoke', $this->id))))
->setBillable($this->billable);
}
/**
* Delete given order from the current user.
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function delete(): bool
{
@@ -102,12 +97,11 @@ class Order extends BaseResource
/**
* Get order items from given order.
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function orderItems(array $parameters = []): OrderItems
{
return (new OrderItems($this->billable->request('GET', sprintf('v1/orders/%s/items', $this->id), [], $parameters)))
return OrderItems::builder(fn() => $this->billable->request('GET', sprintf('v1/orders/%s/items', $this->id), [], $parameters))
->setBillable($this->billable)
->setParent($this);
}

View File

@@ -4,8 +4,7 @@ namespace Anikeen\Id\Resources;
use Anikeen\Id\Concerns\HasBillable;
use Anikeen\Id\Concerns\HasParent;
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
use GuzzleHttp\Exception\GuzzleException;
use Throwable;
/**
* @property string $id
@@ -31,12 +30,11 @@ class OrderItem extends BaseResource
* }>
* } $attributes The order data:
* - items: Array of order items, each with type, name, description, price, unit, and quantity
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function update(array $attributes = []): self
{
return (new self($this->billable->request('PUT', sprintf('v1/orders/%s/items/%s', $this->parent->id, $this->id), $attributes)))
return (new self(fn() => $this->billable->request('PUT', sprintf('v1/orders/%s/items/%s', $this->parent->id, $this->id), $attributes)))
->setBillable($this->billable)
->setParent($this->parent);
}
@@ -44,8 +42,7 @@ class OrderItem extends BaseResource
/**
* Delete given order item from given order.
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function delete(): bool
{

View File

@@ -4,9 +4,8 @@ namespace Anikeen\Id\Resources;
use Anikeen\Id\Concerns\HasBillable;
use Anikeen\Id\Concerns\HasParent;
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
use Anikeen\Id\Result;
use GuzzleHttp\Exception\GuzzleException;
use Throwable;
class OrderItems extends BaseCollection
{
@@ -30,12 +29,11 @@ class OrderItems extends BaseCollection
* }>
* } $attributes The order data:
* - items: Array of order items, each with type, name, description, price, unit, and quantity
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function create(string $orderId, array $attributes = []): OrderItem
{
return (new OrderItem($this->billable->request('POST', sprintf('v1/orders/%s', $orderId), $attributes)))
return (new OrderItem(fn() => $this->billable->request('POST', sprintf('v1/orders/%s', $orderId), $attributes)))
->setBillable($this->billable)
->setParent($this->parent);
}
@@ -45,13 +43,8 @@ class OrderItems extends BaseCollection
*/
public function find(string $id): ?OrderItem
{
/** @var Result $result */
$result = $this->parent->request('GET', sprintf('v1/orders/%s/items/%s', $this->parent->id, $id));
return $result->success() ?
(new OrderItem($result))
->setBillable($this->billable)
->setParent($this->parent)
: null;
return (new OrderItem(fn() => $this->parent->request('GET', sprintf('v1/orders/%s/items/%s', $this->parent->id, $id))))
->setBillable($this->billable)
->setParent($this->parent);
}
}

View File

@@ -3,9 +3,8 @@
namespace Anikeen\Id\Resources;
use Anikeen\Id\Concerns\HasBillable;
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
use Anikeen\Id\Result;
use GuzzleHttp\Exception\GuzzleException;
use Throwable;
class Orders extends BaseCollection
{
@@ -62,29 +61,22 @@ class Orders extends BaseCollection
* - billing_address: Billing address (ISO 3166-1 alpha-2 country code)
* - shipping_address: Shipping address (first name, last name, ISO 3166-1 alpha-2 country code)
* - items: Array of order items (each with type, name, price, unit, units, and quantity)
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function create(array $attributes = []): Order
{
return (new Order($this->billable->request('POST', 'v1/orders', $attributes)))
return (new Order(fn() => $this->billable->request('POST', 'v1/orders', $attributes)))
->setBillable($this->billable);
}
/**
* Get given order from the current user.
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function find(string $id): ?Order
{
/** @var Result $result */
$result = $this->billable->request('GET', sprintf('v1/orders/%s', $id));
return $result->success()
? (new Order($result))
->setBillable($this->billable)
: null;
return (new Order(fn() => $this->billable->request('GET', sprintf('v1/orders/%s', $id))))
->setBillable($this->billable);
}
}

View File

@@ -3,65 +3,53 @@
namespace Anikeen\Id\Resources;
use Anikeen\Id\Concerns\HasBillable;
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
use Anikeen\Id\Result;
use GuzzleHttp\Exception\GuzzleException;
use Throwable;
class PaymentMethods extends BaseCollection
{
use HasBillable;
private ?PaymentMethod $cachedDefaultPaymentMethod = null;
/**
* Check if current user has at least one payment method.
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function hasPaymentMethod(): bool
{
return $this->result->count() > 0;
}
/**
* Get default payment method from the current user.
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
*/
public function defaultPaymentMethod(): PaymentMethod
{
if ($this->cachedDefaultPaymentMethod === null) {
$this->cachedDefaultPaymentMethod = (new PaymentMethod(
$this->billable->request('GET', 'v1/payment-methods/default')
))->setBillable($this->billable);
}
return $this->cachedDefaultPaymentMethod;
}
/**
* Check if the current user has a default payment method.
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function hasDefaultPaymentMethod(): bool
{
return $this->defaultPaymentMethod()?->id !== null;
}
/**
* Get default payment method from the current user.
*
* @throws Throwable
*/
public function defaultPaymentMethod(): PaymentMethod
{
if (!isset($this->defaultPaymentMethodCache)) {
$this->defaultPaymentMethodCache = (new PaymentMethod(fn() => $this->billable->request('GET', 'v1/payment-methods/default')))
->setBillable($this->billable);
}
return $this->defaultPaymentMethodCache;
}
/**
* {@inheritDoc}
*/
public function find(string $id): ?PaymentMethod
{
$result = $this->billable->request('GET', sprintf('v1/payment-methods/%s', $id));
return $result->success()
? (new PaymentMethod($result))
->setBillable($this->billable)
: null;
return (new PaymentMethod(fn() => $this->billable->request('GET', sprintf('v1/payment-methods/%s', $id))))
->setBillable($this->billable);
}
}

View File

@@ -3,8 +3,7 @@
namespace Anikeen\Id\Resources;
use Anikeen\Id\Concerns\HasParent;
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
use GuzzleHttp\Exception\GuzzleException;
use Throwable;
/**
* @property string $id
@@ -16,8 +15,7 @@ class SshKey extends BaseResource
/**
* Deletes a given ssh key for the currently authed user.
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function delete(): bool
{

View File

@@ -3,9 +3,8 @@
namespace Anikeen\Id\Resources;
use Anikeen\Id\Concerns\HasParent;
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
use Anikeen\Id\Result;
use GuzzleHttp\Exception\GuzzleException;
use Throwable;
class SshKeys extends BaseCollection
{
@@ -16,12 +15,11 @@ class SshKeys extends BaseCollection
*
* @param string $publicKey The public key to be added
* @param string|null $name The name of the key (optional)
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function create(string $publicKey, ?string $name = null): SshKey
{
return (new SshKey($this->parent->post('v1/ssh-keys', [
return (new SshKey(fn() => $this->parent->post('v1/ssh-keys', [
'public_key' => $publicKey,
'name' => $name,
])))->setParent($this->parent);
@@ -32,12 +30,6 @@ class SshKeys extends BaseCollection
*/
public function find(string $id): ?SshKey
{
/** @var Result $result */
$result = $this->parent->get(sprintf('v1/ssh-keys/%s', $id));
return $result->success()
? (new SshKey($result))
->setParent($this->parent)
: null;
return (new SshKey(fn() => $this->parent->get(sprintf('v1/ssh-keys/%s', $id))));
}
}

View File

@@ -3,8 +3,7 @@
namespace Anikeen\Id\Resources;
use Anikeen\Id\Concerns\HasBillable;
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
use GuzzleHttp\Exception\GuzzleException;
use Throwable;
/**
* @property string $id
@@ -26,6 +25,7 @@ class Subscription extends BaseResource
* Update a given subscription from the current user.
*
* @param array{
* group: string,
* name: string,
* description: null|string,
* unit: string,
@@ -36,6 +36,7 @@ class Subscription extends BaseResource
* webhook_url: null|string,
* webhook_secret: null|string
* } $attributes The subscription data:
* - group: The group (optional)
* - name: The name (required when set)
* - description: The description (optional)
* - unit: The unit (required when set, e.g. "hour", "day", "week", "month", "year")
@@ -45,56 +46,62 @@ class Subscription extends BaseResource
* - ends_at: The end date (optional)
* - webhook_url: The webhook URL (optional)
* - webhook_secret: The webhook secret (optional)
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function update(array $attributes): self
{
return (new self($this->billable->request('PUT', sprintf('v1/subscriptions/%s', $this->id), $attributes)))
return (new self(fn() => $this->billable->request('PUT', sprintf('v1/subscriptions/%s', $this->id), $attributes)))
->setBillable($this->billable);
}
/**
* Force given subscription to check out (trusted apps only).
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function checkout(): self
{
return (new self($this->billable->request('PUT', sprintf('v1/subscriptions/%s/checkout', $this->id))))
return (new self(fn() => $this->billable->request('PUT', sprintf('v1/subscriptions/%s/checkout', $this->id))))
->setBillable($this->billable);
}
/**
* Revoke a given running subscription from the current user.
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function revoke(): self
{
return (new self($this->billable->request('PUT', sprintf('v1/subscriptions/%s/revoke', $this->id))))
return (new self(fn() => $this->billable->request('PUT', sprintf('v1/subscriptions/%s/revoke', $this->id))))
->setBillable($this->billable);
}
/**
* Pause a given running subscription from the current user.
*
* @throws Throwable
*/
public function pause(): self
{
return (new self(fn() => $this->billable->request('PUT', sprintf('v1/subscriptions/%s/pause', $this->id))))
->setBillable($this->billable);
}
/**
* Resume a given running subscription from the current user.
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function resume(): self
{
return (new self($this->billable->request('PUT', sprintf('v1/subscriptions/%s/resume', $this->id))))
return (new self(fn() => $this->billable->request('PUT', sprintf('v1/subscriptions/%s/resume', $this->id))))
->setBillable($this->billable);
}
/**
* Delete a given subscription from the current user.
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function delete(): bool
{

View File

@@ -3,8 +3,7 @@
namespace Anikeen\Id\Resources;
use Anikeen\Id\Concerns\HasBillable;
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
use GuzzleHttp\Exception\GuzzleException;
use Throwable;
class Subscriptions extends BaseCollection
{
@@ -14,6 +13,7 @@ class Subscriptions extends BaseCollection
* Create a new subscription for the current user.
*
* @param array{
* group: null|string,
* name: string,
* description: null|string,
* unit: string,
@@ -24,6 +24,7 @@ class Subscriptions extends BaseCollection
* webhook_url: null|string,
* webhook_secret: null|string
* } $attributes The subscription data:
* - group: The group (optional)
* - name: The name
* - description: The description (optional)
* - unit: The unit (e.g. "hour", "day", "week", "month", "year")
@@ -33,12 +34,11 @@ class Subscriptions extends BaseCollection
* - ends_at: The end date (optional)
* - webhook_url: The webhook URL (optional)
* - webhook_secret: The webhook secret (optional)
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function create(array $attributes): Subscription
{
return (new Subscription($this->billable->request('POST', 'v1/subscriptions', $attributes)))
return (new Subscription(fn() => $this->billable->request('POST', 'v1/subscriptions', $attributes)))
->setBillable($this->billable);
}
@@ -47,11 +47,7 @@ class Subscriptions extends BaseCollection
*/
public function find(string $id): ?Subscription
{
$result = $this->billable->request('GET', sprintf('v1/subscriptions/%s', $id));
return $result->success()
? (new Subscription($result))
->setBillable($this->billable)
: null;
return (new Subscription(fn() => $this->billable->request('GET', sprintf('v1/subscriptions/%s', $id))))
->setBillable($this->billable);
}
}

View File

@@ -3,9 +3,8 @@
namespace Anikeen\Id\Resources;
use Anikeen\Id\Concerns\HasBillable;
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
use Anikeen\Id\Result;
use GuzzleHttp\Exception\GuzzleException;
use Anikeen\Id\Exceptions\ResourceException;
use Throwable;
class Transactions extends BaseCollection
{
@@ -15,13 +14,13 @@ class Transactions extends BaseCollection
* Create a new transaction for the current user.
*
* @param array $attributes The attributes for the transaction.
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
* @todo Add type hinting for the attributes array.
*/
public function create(array $attributes = []): Transaction
{
return new Transaction($this->billable->request('POST', 'v1/transactions', $attributes));
return (new Transaction($this->billable->request('POST', 'v1/transactions', $attributes)))
->setBillable($this->billable);
}
/**
@@ -29,11 +28,7 @@ class Transactions extends BaseCollection
*/
public function find(string $id): ?Transaction
{
$result = $this->billable->request('GET', sprintf('v1/transactions/%s', $id));
return $result->success()
? (new Transaction($result))
->setBillable($this->billable)
: null;
return (new Transaction(fn() => $this->billable->request('GET', sprintf('v1/transactions/%s', $id))))
->setBillable($this->billable);
}
}