mirror of
https://github.com/anikeen-com/id.git
synced 2026-11-02 05:39:35 +00:00
update resources
Signed-off-by: Maurice Preuß (envoyr) <hello@envoyr.com>
This commit is contained in:
33 files changed
+303
-320
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user