46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Apoloz\AlfaBank\Requests\Webhooks;
|
|
|
|
use Apoloz\AlfaBank\Data\Webhooks\Subscriptions\WebhookSubscriptionData;
|
|
use Apoloz\AlfaBank\Traits\HasAlfaPagination;
|
|
use Saloon\Enums\Method;
|
|
use Saloon\Http\Request;
|
|
use Saloon\Http\Response;
|
|
use Spatie\LaravelData\DataCollection;
|
|
|
|
class GetWebhooksRequest extends Request
|
|
{
|
|
use HasAlfaPagination;
|
|
|
|
protected Method $method = Method::GET;
|
|
|
|
public function __construct(
|
|
protected ?string $object = null,
|
|
?int $limit = 20,
|
|
?int $offset = 0
|
|
) {
|
|
$this->limit = $limit;
|
|
$this->offset = $offset;
|
|
}
|
|
|
|
public function resolveEndpoint(): string
|
|
{
|
|
return '/api/v2/webhooks';
|
|
}
|
|
|
|
protected function defaultQuery(): array
|
|
{
|
|
return array_filter(array_merge([
|
|
'object' => $this->object,
|
|
], $this->getPaginationQuery()));
|
|
}
|
|
|
|
public function createDtoFromResponse(Response $response): DataCollection
|
|
{
|
|
return WebhookSubscriptionData::collect($response->json(), DataCollection::class);
|
|
}
|
|
}
|