update resources

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

No files matched your search

+7 -11
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);
}
}